[R] calculate power of test

Greg Snow Greg.Snow at imail.org
Wed Oct 20 20:55:09 CEST 2010


I generally use simulation to calculate power:

library(MASS)

out1 <- replicate(10000, 
 {tmp <- mvrnorm(100, mu=c(0,0), Sigma=matrix( c(1,.2,.2,1), 2 ) );
  cor.test( tmp[,1], tmp[,2] )$p.value } )

mean( out1 <= 0.05 )



-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Jumlong Vongprasert
> Sent: Tuesday, October 19, 2010 12:49 AM
> To: r-help at r-project.org
> Subject: [R] calculate power of test
> 
> Dear All
>     I want to calculate power of test. I want to test H0: Rho = 0 VS
> H1: Rho
> != 0.
>     Assume, I have r=0.2 and sample size = 100.
>     How I can do this.
> Many Thanks
> Jumlong
> 
> --
> Jumlong Vongprasert Assist, Prof.
> Institute of Research and Development
> Ubon Ratchathani Rajabhat University
> Ubon Ratchathani
> THAILAND
> 34000
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list