Last active
January 8, 2026 03:12
-
-
Save tslumley/3a11d40b0c9cd7015c1d70c629658b86 to your computer and use it in GitHub Desktop.
RS power
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Shows the power of the Rao-Scott (Wald) test in a 2-d problem. | |
| Alternative is parametrised by displacement (fixed to give specified power for intrinsic test) and by angle theta. | |
| Purple circle indicates power for intrinsic test (constant) | |
| black points are corresponding power for RS-type test. | |
| Maybe facet this to get a three-d problem? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## find non-centrality with W0-power=85% | |
| power<-function(nu){ | |
| pchisq(qchisq(0.95,df=2),df=2,ncp=nu,lower.tail=FALSE) | |
| } | |
| nu_75<-uniroot(function(nu) power(nu)-0.75,interval=c(5,15))$root | |
| lambda<-eigen(W1)$values | |
| thetas<-seq(0,2*pi,length=100) | |
| powers<-numeric(100) | |
| for(i in 1:100){ | |
| theta<-thetas[i] | |
| ## evaluate W1-power by simulation | |
| beta<-MASS::mvrnorm(10000,mu=sqrt(nu_75)*c(cos(theta),sin(theta)),S=diag(2)) | |
| Qstat<-rowSums((beta%*%W1)*beta) | |
| powers[i]<-mean(pchisqsum(Qstat,c(1,1),lambda,lower.tail=FALSE,method="int")<0.05) | |
| } | |
| plot(powers*cos(thetas),powers*sin(thetas),xlim=c(-1,1),ylim=c(-1,1)) | |
| points(0.75*cos(thetas),0.75*sin(thetas),col="purple") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment