Jorge, It really helps. I appreciate your help a lot!
Chen On Fri, Dec 4, 2009 at 12:04 AM, Jorge Ivan Velez [via R] < ml-node+948281-1243760...@n4.nabble.com<ml-node%2b948281-1243760...@n4.nabble.com> > wrote: > Try this: > > a <- c(9,3,5) > b<-c(3,4,1) > cbind(a, b) > # a b > # [1,] 9 3 > # [2,] 3 4 > # [3,] 5 1 > > cov(cbind(a, b)) > # a b > # a 9.3333333 -0.6666667 > # b -0.6666667 2.3333333 > > HTH, > Jorge > > On Thu, Dec 3, 2009 at 11:29 PM, aegea <> wrote: > > > > > Hello, > > > > Sorry. It may be a stupid question. > > I have two vectors > > a<-c(9,3,5) > > b<-c(3,4,1) > > How can I get the variance-covariance matrix of these two vectors? > > I tried cov(a,b), I got a number not a matrix. > > I tried to transpose vector a and b as t(a) and t(b), it still cannot > work. > > > > Any suggestions? Thank a lot! > > -- > > View this message in context: > > > http://n4.nabble.com/how-to-calculate-covariance-matrix-in-R-why-cov-doesn-t-work-tp948253p948253.html > > Sent from the R help mailing list archive at Nabble.com. > > > > ______________________________________________ > > [hidden > > email]<http://n4.nabble.com/user/SendEmail.jtp?type=node&node=948281&i=0>mailing > > list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > > and provide commented, minimal, self-contained, reproducible code. > > > > [[alternative HTML version deleted]] > > ______________________________________________ > [hidden > email]<http://n4.nabble.com/user/SendEmail.jtp?type=node&node=948281&i=1>mailing > list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > > > ------------------------------ > View message @ > http://n4.nabble.com/how-to-calculate-covariance-matrix-in-R-why-cov-doesn-t-work-tp948253p948281.html > To unsubscribe from how to calculate covariance matrix in R? why cov > doesn't work, click here< (link removed) ==>. > > > -- Best, Chen -- View this message in context: http://n4.nabble.com/how-to-calculate-covariance-matrix-in-R-why-cov-doesn-t-work-tp948253p948858.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org 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.