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: Regression with fixed random data from panel data set


From   Joerg Luedicke <joerg.luedicke@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Regression with fixed random data from panel data set
Date   Tue, 26 Apr 2011 16:50:27 -0400

On Tue, Apr 26, 2011 at 3:26 PM, vikramfinavker
<vikramfinavker@gmail.com> wrote:
> HI all,
>
> could someone please tell me how can i run a regression for say 20 firms out
> of my 1000 firms selected randomly. i want to do it many times. so, is there
> any command which i can use which will automatically selects 20 firms based
> on some unique id and run the regression.
>
> Thanks.
>

These are two separate steps: First you do the sampling and then you
run your analysis. Once you are clear about how to draw your sample
(see Scott's hint) and about the kind of analysis you want to run you
may want to analyze the results across your random draws. One way of
doing that would be to set up a program which runs the desired
regression using the desired sample and returning the desired results
that you are interested in. Then you you can use Stata's -simulate-
feature to run your program as often as you wish to draw your random
samples, save the results, and create a new datasets with the results
from the regression across your random draws. An example is given
below for the auto data set with 100 random draws of 10.


//Begin example

/*Define a program that runs a regression using the desired sample
and returns desired results*/
clear
program auto1, rclass
version 11.2
drop _all
sysuse auto.dta, clear
sample 10, count
regress  price mpg
return scalar b1=_b[mpg]
qui test mpg
return scalar p1=r(p)
end

/*Put the program in the simulation and create a new data set containing
desired results across random draws (100 draws in this case)*/
simulate beta=r(b1) pval=r(p1), reps(100) saving(auto_test1, replace): auto1

//End example

looking at the results:

. sum  beta pval

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        beta |       100   -241.6105    184.0235  -763.7193   237.2975
        pval |       100    .2497923    .2647623   .0010754    .998809

we see, for example, that the effect from the OLS regression varies
between -764 and 237 the p-value ranges from .001 to .999, and so on.

J
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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