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]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: programming syntax problem [was: Re: st: From: "Christopher L. Aberson" ...] |

Date |
Tue, 18 Jun 2013 10:32:50 +0100 |

Now a fuller answer by Maarten Buis at http://stackoverflow.com/questions/17156909/user-program-not-recognized-in-simulation-command-in-stata Nick njcoxstata@gmail.com On 18 June 2013 08:14, Nick Cox <njcoxstata@gmail.com> wrote: > If you look again at the help for -simulate- the main example is a > program with options. The -simulate- call shows that program being > called with arguments for its options. > > No option calls are given in your -simulate- call. This seems > especially important as you have required options in -powersim3-. How > is -powersim3- supposed to operate then? > > For my part, I don't understand why this basic point is not clear to > you. If this doesn't help, or I in turn am misunderstanding, sorry, > but I end there. > > Nick > njcoxstata@gmail.com > > > On 18 June 2013 05:11, Christopher L. Aberson > <Christopher.Aberson@humboldt.edu> wrote: >> Respectfully -- I don't understand what needs to be supplied. That's >> why I've been posting here. No matter how many times you say "look at >> this or that" I'm not going to be able to figure this out on my own. >> That is why I am seeking help. >> >> >> >>>Look again at your line >>> >>>simulate _b _se, reps(100): powersim3 >>> >>>-powersim3- has compulsory options but you don't supply them. >>> >>>Nick >>>njcoxstata@gmail.com >> >> >> On 18 June 2013 00:39, Christopher L. Aberson >> <Christopher.Aberson@humboldt.edu> wrote: >>> Not sure I follow you. If I run this without using the single command line >>> approach (i.e., just plug in numbers I want here) the Simulate command is >>> getting fed. >>> >>> clear all >>> program define powersim3 >>> drop _all >>> matrix r = (1.0,.30,.30\.30,1.0,.30\.30,.30,1.0) >>> matrix m = (0,0,0) >>> matrix sd = (1,1,1) >>> drawnorm y x1 x2, n(282) corr(r) means(m) sds(sd) >>> >>> regress y x1 x2 >>> end >>> >>> simulate _b _se, reps(100): powersim3 >>> >>> Yet when I try to execute this using a command line as shown in the previous >>> posts, simulate isn't getting fed. >>> >>> Can you clarify how I can tweak the original code to make this run? >>> >>> >>> <You are using -simulate- to call your -powersim3-, but not feeding it >>> anything. >>> <Nick >>> <njcoxstata@gmail.com >>> >>> >>> On 17 June 2013 21:56, Christopher L. Aberson >>> <Christopher.Aberson@humboldt.edu> wrote: >>>> Thank you for the feedback. The approaches suggested made the code >>>> more elegant but did not solve the core issue. >>>> >>>> To recap, I wand to run the code noted below (encased in *****) using >>>> this line powersim3, ry1(.30) ry2(.30) r12 (.30) n (282) >>>> that defines the required characteristics. >>>> >>>> It appears the issue is that the simulate command isn't recognizing >>>> the powersim3 command above. I expect there is a simple solution here >>>> -- but I'm not proficient enough in Stata to know what the simple >>>> answer is. Any additional suggestions would be very helpful. >>>> >>>> ****** >>>> program define powersim3, rclass >>>> syntax, ry1(real)ry2(real)r12(real)n( >>>> 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)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 >>>> ***** >>>> >>>> >>>>> Please use meaningful titles for your postings. >>>>> >>>>> Try editing out the spaces between option names and option details in >>>>> the cases of the options >>>>> >>>>> ry1 (real) ry2 (real) r12 (real) sy (real 1) s1 (real 1) s2 (real 1) >>>>> s3 (real 1) >>>>> >>>>> Incidentally, your program does nothing with the options >>>>> >>>>> alpha(real .05) help >>>>> >>>>> although you may be planning to add details later. >>>>> >>>>> Nick >>>>> njcoxstata@gmail.com >>>>> >>>>> >>>>> On 14 June 2013 23:18, <owner-statalist@hsphsun2.harvard.edu> 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.> * * 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/

**References**:**Re: programming syntax problem [was: Re: st: From: "Christopher L. Aberson" ...]***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**Re: AW: st: WG: XML TAB - inconsistent p-value output** - Next by Date:
**Re: st: RE: RE: margins, marginsplot and piecewise regression** - Previous by thread:
**Re: programming syntax problem [was: Re: st: From: "Christopher L. Aberson" ...]** - Next by thread:
**st: coefficient explanation** - Index(es):