Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Input data from keyboard combined with Monte Carlo


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Input data from keyboard combined with Monte Carlo
Date   Wed, 19 Jun 2013 18:11:51 +0100

You are quite correct. Thanks!

The matrix solution was one I mentioned earlier in the thread. There
is a kind of riff on the idea within

http://www.stata-journal.com/article.html?article=pr0054

Nick
njcoxstata@gmail.com


On 19 June 2013 17:54, Austin Nichols <austinnichols@gmail.com> wrote:
> Nick--
> A -program- cannot include -input- because -end- is ambiguous. Easy
> enough to put the data in a matrix, which the program turns into a
> variable.
>
> On Wed, Jun 19, 2013 at 12:50 PM, Nick Cox <njcoxstata@gmail.com> wrote:
>> I see. If n is not fixed, the -display- directive to input numbers
>> would need to be supplemented by input of how many numbers you intend
>> to give, which probably rules it out.
>>
>> I don't see why your program should not allow -input- in the middle,
>> but I've not tried that, or at least recently. Seems easiest to input
>> some numbers, then run the program.
>> Nick
>> njcoxstata@gmail.com
>>
>>
>> On 19 June 2013 17:42, John Antonakis <John.Antonakis@unil.ch> wrote:
>>> Hi Nick:
>>>
>>> Thanks for your suggestions.
>>>
>>> The n=11 was just indicative....I did not want to have a wieldy example.
>>>
>>> Best,
>>>
>>> J.
>>>
>>> __________________________________________
>>>
>>> John Antonakis
>>> Professor of Organizational Behavior
>>> Director, Ph.D. Program in Management
>>>
>>> Faculty of Business and Economics
>>> University of Lausanne
>>> Internef #618
>>> CH-1015 Lausanne-Dorigny
>>> Switzerland
>>> Tel ++41 (0)21 692-3438
>>> Fax ++41 (0)21 692-3305
>>> http://www.hec.unil.ch/people/jantonakis
>>>
>>> Associate Editor
>>> The Leadership Quarterly
>>> __________________________________________
>>>
>>> On 19.06.2013 12:36, Nick Cox wrote:
>>>>
>>>> You perhaps don't want to hear the advice not to do that, but
>>>> -display- has a _request() directive that is one way to do it.
>>>>
>>>> Even if you're the only user, either you'll crash this repeatedly with
>>>> silly little errors or you'll spend time writing code to catch such
>>>> errors. Perhaps you don't mind.
>>>>
>>>> With 11 as the sample size, I'd consider typing them as a Stata matrix
>>>> (vector) or as a numlist in an option. The two can be combined.
>>>>
>>>> Nick
>>>> njcoxstata@gmail.com
>>>>
>>>>
>>>> On 19 June 2013 11:20, John Antonakis <John.Antonakis@unil.ch> wrote:
>>>>>
>>>>> Suppose that I want to run the below program.
>>>>>
>>>>> clear
>>>>> capture program drop sim
>>>>> version 12
>>>>> program define sim, rclass
>>>>> drop _all
>>>>> set obs 11
>>>>> foreach var of newlist x1-x5 {
>>>>> gen `var' = rnormal()
>>>>> }
>>>>> reg y x*
>>>>> end
>>>>> simulate explvar=e(r2), reps(50) seed(123): sim
>>>>>
>>>>> Now I want to generate y by using fixed-values that I input, e.g.,
>>>>>
>>>>> input y
>>>>> 4.715581
>>>>> 4.296504
>>>>> 4.170745
>>>>> 2.065717
>>>>> 3.648136
>>>>> 8.156727
>>>>> 2.280866
>>>>> 2.817171
>>>>> 2.647611
>>>>> 3.272532
>>>>> end
>>>>>
>>>>> How can I combine inputting the data within the MC program so that the
>>>>> y-values are always fixed and that the x's are randomly generated?
*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index