Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: sample size program


From   "Sophie Barthel" <[email protected]>
To   <[email protected]>
Subject   st: sample size program
Date   Tue, 28 Jan 2003 11:01:58 -0000

Dear List

I tried to post this yesterday but dont think it worked.

The following program is one for a sample size calculation. I am not
using sampsi because I want to extend the program later. However, on
running it in stata it returns an error which I can't seem to spot at
the moment.

program define sampsi1

version 7.0

syntax [, ZAlpha (real 1.645) ZPower (real 0.8416) HRatio (real 1.5)
Censor (real 0.8) PControl (real 0.5)]

if "`ZAlpha'"=="{
ret local errmess "zalpha required"
exit 198
}

if `zalpha'<=0 {
ret local errmess "zalpha() out of range"
exit 198
}

if "`ZPower'"=="{
ret local errmess "zpower required"
exit 198
}

if `zpower'<=0 {
ret local errmess "zpower() out of range"
exit 198
}

if "`HRatio'"=="{
ret local errmess "hratio required"
exit 198
}

if `hratio'<=0 {
ret local errmess "hratio() out of range"
exit 198
}

if "`CEnsor'"=="{
ret local errmess "censor required"
exit 198
}

if `censor'<0 | `censor'>1 {
ret local errmess "censor() out of range"
exit 198
}

if "`PControl'"=="{
ret local errmess "pcontrol required"
exit 198
}

if `pcontrol'<0 | `pcontrol'>1 {
ret local errmess "pcontrol() out of range"
exit 198
}

tempname N0 N1 N2 N

scalar `N0' = (`ZAlpha'+`ZPower')^2

scalar `N1'=(log(`HRatio'))^2

scalar `N2'=`Censor'*`PControl'*(1-`PControl')

scalar `N'=`N0'/(`N1'*`N2')

return N=`N'

end 

exit

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index