| dfM1<-10 # degrees of freedom of M1 |
| dfM2<-12 # degrees of freedom of M2 |
| delta1<-dfM2*.033ˆ2 # define delta* in the alternative hypothesis |
| delta2<-dfM2*.064ˆ2 # define delta** in the alternative hypothesis |
| alpha<-.05 |
| for (n in 1:100000) { |
| cv<-qchisq(1-alpha,df=dfM2-dfM1,ncp=n*delta1) # Critical value under H0 |
| power<-1-pchisq(cv,df=dfM2-dfM1,ncp=n*delta2) |
| if (power>=.80) break # reach the desirable power |
| } |
| N<-n+1 |
| print(N) |