Statalist


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

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


From   "Steichen, Thomas J." <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: -using- option for program executed by -simulate-
Date   Fri, 28 Dec 2007 10:23:29 -0500

Phil,

I don't know about a restriction but there is a work-a-round:

program foo, rclass
    syntax varname, using(string) 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
local myfile "xxx.dta"
simul p = r(p), reps(100): foo group, using(`"`myfile'"') diff(1) sd(1)

Tom

-----------------------------------
Thomas J. Steichen
[email protected]
-----------------------------------

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Phil Schumm
Sent: Thursday, December 27, 2007 4:53 PM
To: [email protected]
Subject: st: -using- option for program executed by -simulate-

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/

-----------------------------------------
CONFIDENTIALITY NOTE: This e-mail message, including any
attachment(s), contains information that may be confidential,
protected by the attorney-client or other legal privileges, and/or
proprietary non-public information. If you are not an intended
recipient of this message or an authorized assistant to an intended
recipient, please notify the sender by replying to this message and
then delete it from your system. Use, dissemination, distribution,
or reproduction of this message and/or any of its attachments (if
any) by unintended recipients is not authorized and may be
unlawful.   

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