-3

i am new with R and also in the area of Multivariate Statistics. i would like to sample 100 samples from this normal dist

mu = (0,1,0)' 
cov = (16,1,1;1,16,2;1,2,16)

and the mission is to check the hypothesis with 5% conf whether matrix cov is Diagonal matrix or not. also need to find the p-value.

the implementation should be in R

thanks

Marco Sandri
  • 23,289
  • 7
  • 54
  • 58
user6041789
  • 41
  • 1
  • 5
  • Where did you get stuck? Did you search for something like "sample from multivariate normal distribution"? When I did I got several possible duplicate questions, [like this one](https://stackoverflow.com/q/30931828/903061) and [this one](https://stackoverflow.com/q/13291308/903061). However, the code you've posted isn't valid syntax - if you need help defining vectors and matrices I would start with some of the introductory material [in the R tag wiki](https://stackoverflow.com/tags/r/info). – Gregor Thomas Nov 28 '17 at 22:13
  • i have been stuck after sampling the data from the given (mu,cov), i am not sure which test to run Hotteling or Likelihood ratios, (i am not sure also how to run those tests in R) – user6041789 Nov 29 '17 at 07:17
  • You should show the code you have, otherwise you will get answers (as below) providing what you already know. As for "what test should I run", that's a question better suited for stats.stackexchange. – Gregor Thomas Nov 29 '17 at 14:37

1 Answers1

0

Check the mvrnorm function from the MASS package.

library(MASS)

mu <- c(0,1,0)
cov <- matrix(c(16,1,1,1,16,2,1,2,16), ncol = 3)
random <- mvrnorm(n = 100, mu = mu, Sigma = cov)

With this code you should be able to draw the random numbers. I don't what you mean with testing the hypothesis...

dasds
  • 170
  • 1
  • 11