Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: -using- option for program executed by -simulate-


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: -using- option for program executed by -simulate-
Date   Fri, 28 Dec 2007 11:23:31 -0500

Phil--
I can verify that -simulate- does not like -using- though the help for
-simulate- claims _command_ can be almost anything that follows
standard Stata syntax (including using presumably).  A workaround is
probably easy though:

clear all
input group
0
1
end
expand 16
tempfile myfile
save `"`myfile'"'
program foo, rclass
 syntax varname, using(str asis) diff(real) sd(real)
 drop _all
 use `using'
 tempvar y
 gen `y' = `diff'*`varlist' + (invnorm(uniform())*`sd')
 ttest `y', by(`varlist')
 ret scalar p = r(p)
end
simul p = r(p), reps(100): foo group, using(`"`myfile'"') diff(1) sd(1)


On Dec 27, 2007 4:52 PM, Phil Schumm <[email protected]> wrote:
> Often when performing simulations, it is helpful to start with an
> existing dataset and then add to it, rather than having to create the
> entire dataset from scratch at each iteration.  It would then seem
> logical to pass the location of the saved dataset into one's program
> via the -using- option.  However, for some reason, I can't seem to
> get that to work (as demonstrated by this simple example):
>
>
> . input group
>
>           group
>    1. 0
>    2. 1
>    3. end
>
> . expand 16
> (30 observations created)
>
> . tempfile myfile
>
> . save `"`myfile'"'
> file /tmp/S_03268.000001 saved
>
> .
> . program foo, rclass
>    1.     syntax varname using/, diff(real) sd(real)
>    2.     drop _all
>    3.     use `"`using'"'
>    4.     tempvar y
>    5.     gen `y' = `diff'*`varlist' + (invnorm(uniform())*`sd')
>    6.     ttest `y', by(`varlist')
>    7.     ret scalar p = r(p)
>    8. end
>
> .
> . simul p = r(p), reps(100): foo group using `"`myfile'"', diff(1) sd(1)
> using not allowed
> r(101);
>
>
> I believe this error is being thrown by -_prefix_command-, as called
> from within -simulate-.  Is there a known restriction against using
> the -using- option in this context?
>
>
> -- Phil
>
> *
> *   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/
>
*
*   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