search for: rmvnorm

Displaying 20 results from an estimated 73 matches for "rmvnorm".

2011 May 01
2
Question on where samples are grouped in rmvnorm{mvtnorm}
Dear All, For function: rmvnorm{mvtnorm} in (library mvtnorm, not splus2R), if I generate 2 bivariate normal samples as follows: > rmvnorm(2,mean=rep(0,2),sigma=diag(2)) [,1] [,2] [1,] 2.0749459 1.4932752 [2,] -0.9886333 0.3832266 Where is the first sample, it is stored in the first row or the first column?...
2007 May 26
1
Why ?rmvnorm not working
Hi, My R version is 2.4.1 and I installed the the packages MASS and run command library("MASS"), however when I type ?rmvnorm, no help topic found, it worked before. I tried to ype ?rinvgamma from "MCMCpack" which works great. Anybody have idea? I also reinstalled MASS package, but when I try to type rmvnorm(), no functions found. Pat
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
2006 Nov 30
1
data.frame within a function (PR#9294) (cont'd)
...t the same issue exists. Just copy and paste the following code under R, and compare the output of f1() and f2() and the output of f3() and f4(). Does anybody have any idea? Thanks. ################################################### # R code for demonstration only # ########################### rmvnorm<- function (n, mean = rep(0, nrow(sigma)), sigma = diag(length(mean))){ if (nrow(sigma) != ncol(sigma)) { stop("sigma must be a square matrix") } if (length(mean) != nrow(sigma)) { stop("mean and sigma have non-conforming size") } ev <- eigen(sigma, sym...
2012 Sep 27
2
Generating an autocorrelated binary variable
...aussian copula method. One variable is a binary variable, that should be autocorrelated. The autocorrelation should be rho = 0.2. Furthermore, the overall probability to get either outcome of the binary variable should be 0.5. Below you can see the R code (I use for simplicity a diagonal matrix in rmvnorm even if it produces no correlated sample): "sampleCop" <- function(n = 1000, rho = 0.2) { require(splus2R) mvrs <- rmvnorm(n + 1, mean = rep(0, 3), cov = diag(3)) pmvrs <- pnorm(mvrs, 0, 1) var1 <- matrix(0, nrow = n + 1, ncol = 1) var1[1] <- qbinom(pmvrs[1, 1], 1,...
2000 Jan 12
0
Problems creating a random sample
...a random sample bivariate normal variates of size > equal to 250 with mean vector (-1,1) and cov matrix (1,0.95,0.95,1) > > In S language I would write: > > > mean<-c(-1,1) > > cov<-c(1,0.95,0.95,1) > > covmat<-matrix(cov,nrow=2,ncol=2) > > mvnorm<-rmvnorm(250,mean,covmat) > ... and it should work > > I've tried this in R, but it does not recognize "rmvnorm". > > (Error: couldn't find function "rmvnorm") rmvnorm is an S-PLUS function, version 4.0 and later. It is not part of S. It is based on mvrnorm in...
2008 Oct 22
3
Help finding the proper function
...st or likelihood ratio-test (LR-test)? My colleague thought that the LR-test would be the best to use, but he was not sure. And in that case which function is best to use. I have found some LR tests but they use fits from glm models etc. Here is an example of my problem. library(mixtools) x.1<-rmvnorm(40, c(0, 0)) x.2<-rmvnorm(60, c(3, 4)) x.3<-rmvnorm(100, c(0, 0)) X.1<-cbind(rbind(x.1, x.2),x.3) colnames(X.1) =LETTERS[1:4] sample A and B is bivariate and C and D is not, so theoretically the best combination would be to use A and B in the model since they change at the same time, but...
2012 Aug 11
3
Problem when creating matrix of values based on covariance matrix
Hi, I want to simulate a data set with similar covariance structure as my observed data, and have calculated a covariance matrix (dimensions 8368*8368). So far I've tried two approaches to simulating data: rmvnorm from the mvtnorm package, and by using the Cholesky decomposition (http://www.cerebralmastication.com/2010/09/cholesk-post-on-correlated-random-normal-generation/). The problem is that the resulting covariance structure in my simulated data is very different from the original supplied covariance ve...
2008 Aug 11
2
generating a random signal with a known correlation
Hi, How can I generate a random signal that's correlated with a given signal at a given correlation (say 0.7)? I've been looking at rmvnorm etc but don't seem to figure it out. Thanks ----- Yasir H. Kaheil Columbia University -- View this message in context: http://www.nabble.com/generating-a-random-signal-with-a-known-correlation-tp18932541p18932541.html Sent from the R help mailing list archive at Nabble.com.
2010 Aug 24
3
generate random numbers from a multivariate distribution with specified correlation matrix
Hi all, rmvnorm()can be used to generate the random numbers from a multivariate normal distribution with specified means and covariance matrix, but i want to specify the correlation matrix instead of covariance matrix for the multivariate normal distribution. Does anybody know how to generate the random numbers fr...
2011 Sep 03
1
Bootstrapping a covariance matrix
...e to bootstrap a covariance matrix from a multivariate gaussian density. At face value that seemed like a very straightforward problem to solve but I somehow could not get the boot package to work and did not really understand the documentation so I tried to do the bootstrap manually. Hence: x<-rmvnorm(n = 5, mean, diag(1,length(mean))) Var<-function(a) var(a) Var(x) sample<-matrix(sample(x,replace=T),ncol=length(mean))#single BS sample Var(sample)# sqr matrix of length(mean) #generate 1000 bootstrap samples boot <- array(NA, c(1000, 3, 3)) #assign the var for bootstrap sample i as th...
2006 Jul 01
5
generate bi-variate normal data
Dear all, I would like to generate bi-variate normal data given that the first column of the data is known. for example: I first generate a set of data using the command, x <- rmvnorm(10, c(0, 0), matrix(c(1, 0, 0, 1), 2)) then I would like to sum up the two columns of x: x.sum <- apply(x, 1, sum) now with x.sum I would like to generate another column of data, say y, that makes cbind(x.sum, y) follow a bi-variate normal distribution with mean = c(0, 0) and sigma = matrix(c(...
2002 Oct 02
4
T-Distribution
Dear sir, I would ask if there are in R some code to generate a random sample from a mvariate student distribution like that one wich generate the multivariate normal one i mean( rmvnorm(n, mu, sigma) Second question : if R can plot density 3Dcurve I don't mean de histogram but de hole density function(normal for example). I use a windows version of The R software Thank you in advance wiyh kind regard -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-....
2003 Feb 15
2
(no subject)
Hi, Are there some packages which can generate multi-normal, multi-t, etc multivariate sampling? thanks! Best wishes, Peng ******************************* Peng Zhang Department of Biostatistics Harvard School of Public Health 655 Huntington Avenue Boston, Massachusetts 02115 ******************************* I believe I can fly I believe I can touch the sky
2004 May 04
2
Sampling 1000 times from a bivariate normal distibution
Dear expert, I have two coefficients and covariance matrix. My objective is sampling 1000 times from the mean and covariance matrix. In order to get that, what kind of commend should I use? If you do not mind, could you tell me the comment in detail about parameter used in that commend also? Thank you. Sung. [[alternative HTML version deleted]]
2010 Dec 09
1
Constraints when sampling from a distribution
 Dear R-helpers, My question is related to how to impose constraints when when sampling from a distribution. For example, suppose I'm sampling a vector from a multivariate normal distribution vbeta <- 100*diag(2) mbeta <- c(1,1) ans <- beta <- c(rmvnorm(1,mbeta,vbeta)) ans will thus be a vector with two elements. My question is how do I place a restriction on one of the elements of the ans vector. For example, suppose my goal is to reject any draw for ans[2] below -1 and above 1, how should I implement that in the above setting? Thanks in adva...
2010 May 10
1
Random walk
...two random walks of 200 time steps with a correlation 0.7. I built the random walks with: x<-cumsum(rnorm(200, mean=0,sd=1)) y<-cumsum(rnorm(200, mean=0,sd=1)) but I don't know how to fix the correlation between them. With white noise is easy to fix the correlation using the function rmvnorm in the package mvtnorm I surfed in the web in the searchable mail archives in the R web site but no references appears. If you have some advices to solve this problems I would be very thankful. Thanks in advance. Sergio A. Estay *CASEB * Departamento de Ecolog?a Universidad Catolica de Chile...
2011 Aug 25
2
Create two uniformly random variables correlated
Hello, I want to create two random variables (x1,x2) both with uniform distribution bounded by (-1) and (1) that has a correlation of 0.6 between them. Does somebody know how I can do it? For normal random variables I known how to implement it with the rmvnorm command but I don't know how to do it with variables uniformly distributed. Thanks a lot. Alexandra [[alternative HTML version deleted]]
2012 Jul 08
1
Data Simulation
Hi, I have great difficulty in simulation the a dataset based in a loading matrix [c(1,1,1,2,3,3,3,4,4,3,2,2,1,1), 7, 2) and an error covariance matrix is 2*I. I have to simulate a dataset with 7 variables and 50 rows. I search a lot and did find some information on this, for example, using rmvnorm(). But I could do it. Please help! -- View this message in context: http://r.789695.n4.nabble.com/Data-Simulation-tp4635803.html Sent from the R help mailing list archive at Nabble.com.
2010 Mar 17
2
How to use "ifelse" to generate random value from a distribution
I need use different parameters of distribution for different case to generate random value, but I use ifelse, the generated value is fixed without change. Here is example data1 y x 1 1 2 2 2 1 3 3 2 4 4 3 5 5 3 6 6 1 7 7 2 8 8 1 9 9 1 10 10 3 11 11 3 12 12 2 ifelse(data1$x==1,rnorm(1,2,1),ifelse(data1$x==2,rnorm(1,-2,1),rnorm(1,110,1))) [1] -1.8042172 0.8478681