similar to: help about random generation of a Normal distribution of several variables

Displaying 20 results from an estimated 2000 matches similar to: "help about random generation of a Normal distribution of several variables"

2008 Jul 22
2
F test
Dear R users,   I need to do a F test on the hypothesis that a 2 by 1 vector (X_1, X_2)' has the mean vector  (M_1, M_2)'. Specifically, I would like to assume the X vector comes from a bivariate Normal distribution (M, Sigma). Then, given 1000 observations on X, I wanted to test if the means of X agree with the means of the target Normal distribution. Any function or package in R could do
2008 Oct 14
2
help about how can R compute AIC?
Hello. I need to know how can R compute AIC when I study a regression model? For example, if I use these data: growth tannin 1 12 0 2 10 1 3 8 2 4 11 3 5 6 4 6 7 5 7 2 6 8 3 7 9 3 8 and I do model <- lm (growth ~ tannin) AIC(model) R responses: 38.75990 I know the following formula to compute AIC: AIC=
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:
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
2004 Sep 22
5
Issue with predict() for glm models
[This email is either empty or too large to be displayed at this time]
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
2004 Jun 25
2
Simulating from a Multivariate Normal Distribution Using a Correlation Matrix
Hello, I would like to simulate randomly from a multivariate normal distribution using a correlation matrix, rho. I do not have sigma. I have searched the help archive and the R documentation as well as doing a standard google search. What I have seen is that one can either use rmvnorm in the package: mvtnorm or mvrnorm in the package: MASS. I believe I read somewhere that the latter was
2018 Mar 03
2
lmrob gives NA coefficients
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 <- matrix(rho, d, d); diag(Sigma) <- 1 x.clean <- mvrnorm(n, rep(0,d), Sigma) beta <- c(1.0, 2.0, 3.0, 4.0) error <- rnorm(n = n,
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 <-
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
2007 Feb 13
4
Generating MVN Data
Dear All I want to generate multivariate normal data in R for a given covariance matrix, i.e. my generated data must have the given covariance matrix. I know the rmvnorm command is to be used but may be I am failing to properly assign the covariance matrix. Any help will be greatly appreciated thanks. M. R. Ahmad
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
2008 Oct 04
3
How to plot countours with fixted densities?
Hello, I used the following codes to generate bivariate normal dependence structure with unit Frechet margins. Sigma <- matrix(c(1,.5*sqrt(1),.5*sqrt(1),1),2,2) # generate y <- mvrnorm(Nsam, c(0,0), Sigma) # random v <- cbind(pnorm(y[,1],mean = 0, sd = 1), pnorm(y[,2],mean = 0, sd = 1)) z <- cbind(-1/log(v[,1]),-1/log(v[,2])) z1 <- z[,1] z2 <- z[,2] And to
2006 Oct 31
2
Put a normal curve on plot
I would like to be able to place a normal distribution surrounding the predicted values at various places on a plot. Below is some toy code that creates a scatterplot and plots a regression line through the data. library(MASS) mu <- c(0,1) Sigma <- matrix(c(1,.8,.8,1), ncol=2) set.seed(123) x <- mvrnorm(50,mu,Sigma) plot(x) abline(lm(x[,2] ~ x[,1])) Say I want to add a normal
2007 Dec 17
2
regression towards the mean, AS paper November 2007
Dear friends, regression towards the mean is interesting in medical circles, and a very recent paper (The American Statistician November 2007;61:302-307 by Krause and Pinheiro) treats it at length. An initial example specifies (p 303): "Consider the following example: we draw 100 samples from a bivariate Normal distribution with X0~N(0,1), X1~N(0,1) and cov(X0,X1)=0.7, We then calculate
1999 Dec 22
1
No subject
Dear friends. I've forgotten how to simulate data with a known correlation, e.g. only two columns. I'd be most pleased to be told. Thanks in advance Troels Ring, M.D Department of Nephrology Aalborg, Denmark tring at mail1.stofanet.dk -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read
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 <-
2016 Jul 17
2
Muestrear de una normal multivariante.-
¡Hola a todos! Estoy intentando muestrear de una normal multivariante donde hay dos grupos de variables que deben tener una relación "manipulable" entre sí pero ignoro cómo hacerlo. Les cuento, he intentado lo siguiente: # covarianzas del primer grupo de variables: Sigma_U <- matrix(c(.25, .2, .2, .25), ncol=2) # covarianzas del segundo grupo de variables: Sigma_W <- diag(2) #
2008 May 09
1
Multivariate simulation
Dear everyone, I am having problem simulating multivariate data. Though I was able to simulate the data, but finding the variance-covariance matrix of simulated data did not give exact covariance matrix used in simulating the data. Unlike some other packages, like stata, using command "corr2data" will simulate data having the covariance matrix exactly with the specified covariance
2013 Oct 15
1
plotting a marginal distribution on the plane behind a persp() plot
R'istas: I am trying to plot a marginal distribution on the plane behind a persp() plot. My existing code is: library(MASS) X <- mvrnorm(1000,mu=c(0,0),Sigma=matrix(c(1,0,0,1),2)) X.kde <- kde2d(X[,1],X[,2],n=25) # X.kde is list: $x 1*n, $y 1*n, $z n*n persp(X.kde,phi=30,theta=60,xlab="x_b",ylab="x_a",zlab="f") ->res Any suggestions are very