similar to: Create simulated data's using mvrnorm

Displaying 20 results from an estimated 1100 matches similar to: "Create simulated data's using mvrnorm"

2011 Jan 22
1
faster mvrnorm alternative
Hello, does anybody know another faster function for random multivariate normal variable simulation? I'm using mvrnorm, but as profiling shows, my algorithm spends approximately 50 % in executing mvrnorm function. Maybe some of you knows much faster function for multivariate normal simulation? I would be very gratefull for advices. -- View this message in context:
2005 May 01
2
eigen() may fail for some symmetric matrices, affects mvrnorm()
Hi all, Recently our statistics students noticed that their Gibbs samplers were crashing due to some NaNs in some parameters. The NaNs came from mvrnorm (Ripley & Venables' MASS package multivariate normal sampling function) and with some more investigation it turned out that they were generated by function eigen, the eigenvalue computing function. The problem did not seem to happen
2004 Feb 02
3
mvrnorm problem
I am trying to simulate draws from a multivariate normal using mvrnorm, and am getting the following error message: Error in mu + eS$vectors %*% diag(sqrt(pmax(ev, 0)), p) %*% t(X) : non-conformable arrays I do not understand why I am getting this message, since the vector of means I am giving to the function is 13 by 1 and the variance matrix I am giving to the function is 13
2011 May 07
1
generate multiple mvrnorm samples using apply-like
I want to generate multiple multivariate normal samples with different mean vectors and common covariance matrix. I can do this with a loop, but can't quite figure out how to do it with apply and friends. In the example below, I want values to have 3 columns: group, x, y # number of groups, and group means x <- jitter(seq(2,10,by=2)) y <- x + rnorm(length(x), 0, .5) means <-
2012 Jun 10
2
mvrnorm limits
Dear All,   I am using the following commands to generate a given dataset:   a <-c(0.348,0.007,0.503,0.58,0.21) cov <-c(0.0448,0,0,0,0,0.0001,0.0001,0,0,0,-0.0055,-0.0005,0.0495,0,0,0.0218,0.0009,-0.0253,0.1103,0,-0.0102,-0.0007,0.00631,0.0067,0.0132) b <-matrix(cov,nrow=5, ncol = 5, byrow = TRUE,dimnames = NULL) g <-mvrnorm(10000,a,b)   is there a way to place limits on the simulated
2005 Jan 06
2
Generating Data mvrnorm and loops
Dear List: I am generating N datasets using the following Sigma<-matrix(c(400,80,80,80,80,400,80,80,80,80,400,80,80,80,80,400),4,4 ) mu<-c(100,150,200,250) N=100 for(i in 1:N) { assign(paste("Data.", i, sep=''), as.data.frame(cbind(seq(1:1000),(mvrnorm(n=1000, mu, Sigma))))) } With these datasets, I need to work on some of the variables and then run each dataset
2011 Aug 24
0
How to use mvrnorm?
Dear R community! I would like to simulate distributions based on a polynomial model. It consists of 96 values and I want to randomly select new normaly distributed values around the modeled values. Furthermore, each value should be correlated with the previous one. Is it correct to therefore use mvrnorm? How do I define sigma? Thank you very much for your help. All the best, Marianne -- View
2008 Jun 26
2
constructing arbitrary (positive definite) covariance matrix
Dear list, I am trying to use the 'mvrnorm' function from the MASS package for simulating multivariate Gaussian data with given covariance matrix. The diagonal elements of my covariance matrix should be the same, i.e., all variables have the same marginal variance. Also all correlations between all pair of variables should be identical, but could be any value in [-1,1]. The problem I am
2011 Feb 24
3
problem in for loop
Hi all. I was having some trouble with a for loop and I found the problem is the following. Does anyone have some idea why I got the following R result? Since mone is equal to 3, why mu1 only have 2 components? library(MASS) > p0 <- seq(0.1, 0.9,by=0.1) > m <- 10 > > > p0 <- p0[7] > > ## data generation > > mzero <- p0*m > mone <- m-mzero >
2008 Nov 11
1
simulate data with binary outcome and correlated predictors
Hi, I would like to simulate data with a binary outcome and a set of predictors that are correlated. I want to be able to fix the number of event (Y=1) vs. non-event (Y=0). Thus, I fix this and then simulate the predictors. I have 2 questions: 1. When the predictors are continuous, I can use mvrnorm(). However, if I have continuous, ordinal and binary predictors, I'm not sure how to simulate
2006 May 05
2
Including a single function from a package
Hello all. I'm building a package where I want to include a function from two different packages. In particular, I want to include mvrnorm and hyperg_2F1 from MASS and gsl, respectively (but the specific functions do not matter). With what I've tried after reading the "Specifying imports and exports" section from the "Writing R Extensions" manual, I get an error:
2003 Jul 22
6
variable names
Dear helpers I want to use rpart several times in a loop to build a classification tree. My problem is that rpart needs a formula as argument and for that the variables need to have names and this doesn't happen in my case. Every iteration in the loop has a different dataset with several variables (ex. 38 or more) and so I can't type the names by hand every time. Is there any function
2007 Mar 16
1
ideas to speed up code: converting a matrix of integers to a matrix of normally distributed values
Hi all, [this is a bit hard to describe, so if my initial description is confusing, please try running my code below] #WHAT I'M TRYING TO DO I'd appreciate any help in trying to speed up some code. I've written a script that converts a matrix of integers (usually between 1-10,000 - these represent allele names) into two new matrices of normally distributed values (representing
2018 Mar 04
2
lmrob gives NA coefficients
Thanks for your reply. I use mvrnorm from the *MASS* package and lmrob from the *robustbase* package. To further explain my data generating process, the idea is as follows. The explanatory variables are generated my a multivariate normal distribution where the covariance matrix of the variables is defined by Sigma in my code, with ones on the diagonal and rho = 0.15 on the non-diagonal. Then y
2018 Mar 04
0
lmrob gives NA coefficients
What is 'd'? What is 'n'? On Sun, Mar 4, 2018 at 12:14 PM, Christien Kerbert < christienkerbert at gmail.com> wrote: > Thanks for your reply. > > I use mvrnorm from the *MASS* package and lmrob from the *robustbase* > package. > > To further explain my data generating process, the idea is as follows. The > explanatory variables are generated my a
2007 Sep 17
1
Create correlated data with skew
Hi all, I understand that it is simple to create data with a specific correlation (say, .5) using mvrnorm from the MASS library: > library(MASS) > set.seed(1) > > a=mvrnorm( + n=10 + ,mu=rep(0,2) + ,Sigma=matrix(c(1,.5,.5,1),2,2) + ,empirical=T + ) > a [,1] [,2] [1,] -1.0008380 -1.233467875 [2,] -0.1588633 -0.003410001 [3,] 1.2054727 -0.620558768
2009 Nov 11
1
Loadings and scores from fastICA?
Hi all, Does anyone know how to get the independent components and loadings from an Independent Component Analysis (ICA), as well as principal components and loadings from a Pricipal Component analysis (PCA) using the fastICA package? Or perhaps if there's another way to do ICAs in R? Below is an example from the fastICA manual (http://cran.r-project.org/web/packages/fastICA/fastICA.pdf)
2018 Mar 03
0
lmrob gives NA coefficients
> On Mar 3, 2018, at 3:04 PM, Christien Kerbert <christienkerbert at gmail.com> wrote: > > Dear list members, > > I want to perform an MM-regression. This seems an easy task using the > function lmrob(), however, this function provides me with NA coefficients. > My data generating process is as follows: > > rho <- 0.15 # low interdependency > Sigma <-
2003 May 06
4
Questons about R capabilities
Hello, 1) I am interested in performing a limited-dependent variable linear regression. By this I mean a classical linear regression, but for the case where the values of the dependent variable cannot vary from -infinity to +infinity, but are truncated and so are between two finite limits L1 and L2. Does R1.7 have this capability? If so what is (are) the relevant command(s)? 2) I am also
2009 Feb 19
1
Bug in predict function for naiveBayes?
Dear all, I tried a simple naive Bayes classification on an artificial dataset, but I have troubles getting the predict function to work with the type="class" specification. With type= "raw", it works perfectly, but with type="class" I get following error : Error in as.vector(x, mode) : invalid 'mode' argument Data : mixture.train is a training set with 100