Paul Silcocks BM MSc FRCPath FFPHM CStat
>
> I'm trying to estimate power of a non-linear regression by
> simulation.
> There are three parameters of interest and I can generate
> samples under H0
> (no trend) and H1 (particular model of interest).
>
> The problem is how to write the parameter estimates under
> H0 and H1 to a
> file. In the code below, the estimation is performed twice
> - under H0 and
> H1. What I would like to do is post the 6 estimates in one
> go to the output
> file, rather than output to two separate files which would
> be merged.
>
> forvalues i=1/5000 {
> /* evaluate when H0 true */
> replace err = 0 + 3.5*invnorm(uniform())
> replace tempy = 0 +err
> nl hyp tempy dose, iterate(30) eps(0.0001)
>
> /* How do I save parameter estimates from H0 ? */
>
> /* evaluate when H1 true */
> replace tempy = yh +err
> nl hyp tempy dose, iterate(30) eps(0.0001)
>
> /* here I save the results from estimate given H1 */
>
> post `powerdat' (_b[B0]) (_b[B1]) (e(r2_a))
>
>
> Any thoughts anybody? Ideally the last statement would be like:
>
> post `powerdat' (_b[B0]) (_b[B1]) (e(r2_a))
> (_b[B0]) (_b[B1])
> (e(r2_a))
>
> Where the first 3 are from the estimate under H0 and the
> second 3 are from
> H1
>
Put those first estimates somewhere where they won't
be overwritten before being posted, e.g.
scalar B0 = _b[B0]
scalar B1 = _b[B1]
scalar r2_a = e(r2_a)
and then put those names in a single call to -postfile-.
Nick
n.j.cox@durham.ac.uk
*
* 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/