[R] help
Bill Dunlap
w||||@mwdun|@p @end|ng |rom gm@||@com
Tue Mar 16 19:08:56 CET 2021
The length of the mean vector must match the number of rows and
columns of the sigma matrix. Once you give 3 entries in the mean
vector you will run into the problem that the sigma you are using is
not positive (semi-)definite - a variance must be the product of a
matrix and its transpose.
-Bill
On Tue, Mar 16, 2021 at 10:55 AM hatice gürdil
<haticegurdil1985 using gmail.com> wrote:
>
> Code a is working. But code b is given error like given below. How can I
> write code b?
>
> > a<-rmvnorm(750, mean=c(0, 0),
> + sigma=matrix(c(1, .3, .3, 1), ncol=2))
>
> > head(a)
> [,1] [,2]
> [1,] -0.97622921 -0.87129405
> [2,] 0.54763494 0.16080131
> [3,] -1.16627647 0.31225125
> [4,] 1.72541168 2.06513939
> [5,] 0.05372489 -0.07525197
> [6,] -0.85062230 -1.02188473
>
> > b<-rmvnorm(round(500,0), mean=c(0,-1),
> + sigma=matrix(c(.3, 1,1,1,.3, 1, 1,1, .3), ncol=3))
>
> Error in rmvnorm(round(500, 0), mean = c(0, -1), sigma = matrix(c(0.3, :
> mean and sigma have non-conforming size
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
More information about the R-help
mailing list