Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Simulate Command within an ado file
From
Stas Kolenikov <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Simulate Command within an ado file
Date
Fri, 14 Jun 2013 17:34:31 -0500
-ry1-, -ry2-, -r12- and -n- are all required options according to the
syntax you specified in -powersim3-, so Stata is entirely right in its
complaining about these options not being specified in your call to
-powersim3- from under -simulate-. You need to tighten the syntax:
remove the spaces between ry1 and (, ry2 and (, etc.; have all the
required options go first, and all non-required options, after that in
the single bracket range. If I were doing this, I would also add -min
0- to the standard deviations, and check that the r matrix thus formed
is invertible.
-- Stas Kolenikov, PhD, PStat (SSC)
-- Senior Survey Statistician, Abt SRBI
-- Opinions stated in this email are mine only, and do not reflect the
position of my employer
-- http://stas.kolenikov.name
On Fri, Jun 14, 2013 at 5:19 PM, Christopher L. Aberson
<[email protected]> wrote:
> I've written a tiny program for simulation of multiple regression
> results. I can run this on a line by line basis (using actual values
> instead of the syntax command), but when I put it in an ado, it
> doesn't work.
>
> The basic idea is use drawnorm to generate a dataset, run regression
> on it, then do it over and over using the simulate option.
>
>
> program define powersim3, rclass
> syntax, ry1 (real) ry2 (real) r12 (real) [my(real 0) m1(real 0)
> m2(real 0) m3(real 0)] [sy (real 1) ///
> s1 (real 1) s2 (real 1) s3 (real 1)] n(real) [alpha(real .05) help ]
> matrix m = (`my', `m1', `m2')
> matrix sd = (`sy', `s1', `s2')
> matrix r = (1, `ry1', `ry2'\ `ry1' , 1 , `r12'\ `ry2' , `r12', 1)
> drawnorm y x1 x2, n(`n') corr(r) means(m) sds(sd)
> regress y x1 x2
> end
>
> simulate _b _se, reps(10000): powersim3
>
> .powersim3, ry1(.30) ry2(.30) r12 (.30) n (282)
>
> This yields an error saying "ry1" required. If I take out the simulate
> command I get a single regression but not the repeated
> sampling/simulation I want.
>
> Any help would be appreciated.
>
>
>
> --
> Chris Aberson, Ph.D.
> Professor
> Department of Psychology
> Humboldt State University
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/