FAQ/power/pPowN - CBU statistics Wiki

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment
In thi sntence, what word is mad fro the mising letters?

location: FAQ / power / pPowN

An on-line power calculator is available.

Computes total sample size needed for testing prop=const where prop and const are observed and expected (constant) proportions respectively and alpha is the (two-tailed) type I error for a given power. A calculator is available in a spreadsheet.

[COPY AND PASTE THE SYNTAX BELOW INTO A SPSS SYNTAX WINDOW AND RUN; SET DATA AS DESIRED]

DATA LIST free
/prop const alpha power. 
BEGIN DATA. 
0.45 0.5 .05 .85 
0.55 0.5 .05 .85
END DATA. 

set errors=none.
define propn (!pos !tokens(1)
                   / !pos !tokens(1)
                   / !pos !tokens(1)
                   / !pos !tokens(1)).
COMPUTE #POW = !4.
compute #conf = 1-!3.
compute #lc3 = 1.
compute #ind=0.
compute #chisq = 3.
comment COMPUTE #LC1 = 2.000.
COMPUTE #chisq1 = ((!1-!2)**2)/(!2*(1-!2)).
COMPUTE #CUMF2 =  1 - NCDF.CHISQ(IDF.CHISQ(#conf,1),1,#CHISQ).
compute #diff=1.
SET MXLOOPS=40000.
LOOP IF (#DIFF GT .00005) .
+       DO IF (#CUMF2 LT #pow) .
+               COMPUTE #LC3 = #CHISQ.
+               COMPUTE #CHISQ = (#chisq + 0.001).
+               COMPUTE #CUMF2 =  1 - NCDF.CHISQ(IDF.CHISQ(#conf,1),1,#CHISQ).
+       ELSE .
+               COMPUTE #LC1 = #chisq .
+               COMPUTE #chisq = (#chisq + #LC3)/2 .
+               COMPUTE #CUMF2 =  1 - NCDF.CHISQ(IDF.CHISQ(#conf,1),1,#CHISQ).
+       END IF .
+       COMPUTE #DIFF = ABS(#CUMF2 - #pow) .
END LOOP .
compute ntot = #chisq/#chisq1.
if (ntot-trunc(ntot) gt 0.5) #ind=1.
if (#ind eq 0) ntot=trunc(ntot)+1.
if (#ind eq 1) ntot=rnd(ntot).
EXECUTE .
compute prop=!1.
compute const=!2.
compute alpha=!3.
compute power=!4.
formats ntot (f7.0) alpha (f5.2) prop (f5.2) const (f5.2) power (f5.2).
variable labels ntot 'Sample Size Required' /alpha 'Alpha' /prop 'Observed Proportion' /const 'Constant' /power 'Power'.
report format=list automatic align(center)
  /variables=ntot alpha prop const power 
  /title "Sample Size required for a one sample binomial test" .
!enddefine.

matrix.
get m /variables=prop const alpha power  /missing=omit.
compute prop=make(1,1,0).
compute const=make(1,1,0).
compute alpha=make(1,1,0).
compute power=make(1,1,0).
compute prop=m(:,1).
compute const=m(:,2).
compute alpha=m(:,3).
compute power=m(:,4).  
end matrix.
propn prop const alpha power.