[R] Generating MVN Data
Robin Hankin
r.hankin at noc.soton.ac.uk
Tue Feb 13 15:39:31 CET 2007
Hi
give rmvnorm() any symmetric positive definite matrix and it should
work:
> rmvnorm(n=10,mean=1:2,sigma=matrix(c(1,0.5,0.5,1),2,2))
[,1] [,2]
[1,] -0.1118 2.514
[2,] 1.8667 1.628
[3,] 3.2477 2.263
[4,] 1.0166 2.381
[5,] -0.0888 -0.132
[6,] -0.9249 0.610
[7,] 1.5046 3.578
[8,] 0.8530 0.802
[9,] 2.2940 2.240
[10,] 1.1660 2.528
>
HTH
rksh
On 13 Feb 2007, at 14:14, Rauf Ahmad wrote:
> 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
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
tel 023-8059-7743
More information about the R-help
mailing list