[R] question for mshapiro test

liuliang@stat.ohio-state.edu liuliang at stat.ohio-state.edu
Thu Jan 12 03:04:36 CET 2006


Hi,
I have a question about the p-value of mshapiro test. I simulated data
from bivariate normal 1000 times and used mshapiro test to see how many
times the test would reject the null hypothesis when the p-value is 0.05.
The answer should be around 50 since the p-value is 0.05. But I got a much
higher value. Here is the R code I used and the result.

library(mvnormtest,lib.loc="~/mshapiro")
library(MASS)
n=50
dim=2

      ntrial = 1000
      x<-matrix(1:(dim*n),ncol=dim)
      count = 0

      for( trial in 1:ntrial)
           {
              x<-mvrnorm(n,rep(0,dim),diag(1,dim,dim))
              data_hn<-x
              p<-mshapiro.test(t(data_hn))$p.value
              if( p<= 0.05)     count <- count+1
           }
print(count)
[1] 117

Can you help me out? Thank you very much.

Liang




More information about the R-help mailing list