Bookmark and Share

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: Input data from keyboard combined with Monte Carlo


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Input data from keyboard combined with Monte Carlo
Date   Wed, 19 Jun 2013 11:36:36 +0100

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
[email protected]


On 19 June 2013 11:20, John Antonakis <[email protected]> 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?
>
> Best,
> John.
>
>
> __________________________________________
>
> 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
> __________________________________________
>
> *
> *   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index