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

Re: st: sample size program


From   "Julian Fennema" <[email protected]>
To   [email protected]
Subject   Re: st: sample size program
Date   Tue, 28 Jan 2003 11:15:32 -0000

Sophie,

I'm not sure what kind of error is cropping up, but the first thing that 
strikes me is that when you are defining the error commands for, 
amongst others, `ZAlpha', you are not defining to what it should be 
equal before defining the return code.

I'm not sure if I'm seeing this at too elementary a level, but it may 
be worth a try.

Julian


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

> 
> 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/


---------------------------------------------------------
Julian A. Fennema
CERT (Centre for Economic Reform and Transformation)
School of Management and Languages
Heriot-Watt University
Riccarton
Edinburgh EH14 4AS

Tel: +44 (0)131 451 3492
Fax: +44 (0)131 451 3296

*
*   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