[R] mvrnorm limits

David Winsemius dwinsemius at comcast.net
Sun Jun 10 05:42:06 CEST 2012


On Jun 9, 2012, at 11:00 PM, Andras Farkas wrote:

> 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 values so that they  
> all remain positive? I am simulating biological variables that  
> should never be 0.
>

Have you considered choosing a distribution that respects the  
characteristics of your data?

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list