# help Classic List Threaded 4 messages Reply | Threaded
Open this post in threaded view
|

## help

 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]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

## Re: help

 A 2 dim distribution must have a 2 x 2 covariance matrix. Your mean in b) specifies 2 dim, but your covariance matrix is 3x3. If you haven't just made a typo and you don't know what this means, then either consult statistics references or find someone to help you. Cheers, Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Mar 16, 2021 at 10:55 AM hatice gürdil <[hidden email]> 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]] > > ______________________________________________ > [hidden email] 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. >         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

## Re: help

 In reply to this post by hatice gürdil 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 <[hidden email]> 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]] > > ______________________________________________ > [hidden email] 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. ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

## Re: help

 Thank you so much I thought that ncol is for dimension . ncol= 2, 2x2 matris for 2 dimension ncol= 3, 3x3 matris for 3 dimention I have to work a little more considering what you said. Cheers, Hatice Gürdil. Bill Dunlap <[hidden email]>, 16 Mar 2021 Sal, 21:09 tarihinde şunu yazdı: > 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 > <[hidden email]> 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]] > > > > ______________________________________________ > > [hidden email] 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. >         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.