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

From |
"Michael Blasnik" <michael.blasnik@verizon.net> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: Re: sample partition issue & programming |

Date |
Wed, 30 Nov 2005 10:37:25 -0500 |

If this is a homework problem, you should probably figure it out yourself, but here are a few tips:

1) yes it can be easily done in a do file using a forvals loop

2) don't use -sample-, instead use -generate rand=uniform()- in your loop and then -sort rand- and use the -in- qualifier in the regress command to exclude the 20%

3) use predict, resid to get the residuals and decide on how you want to calc the estimation error

4) use either postfile or file to output the stats (r2, estimation error) from each of the 100 runs to a Stata file (no need for excel)

Michael Blasnik

michael.blasnik@verizon.net

----- Original Message ----- From: "Yang Li" <Yang.Li-4@uts.edu.au>

To: <statalist@hsphsun2.harvard.edu>

Sent: Wednesday, June 30, 2004 11:29 AM

Subject: st: sample partition issue & programming

Dear statalists,

I am required to randomly partition my sample into two groups with 80% and 20% split, and run the normal OLS regression on the 80% set (report R square, Parameters, significance indicators, MSE/(var expected)). Then for each of the observation in my 20% set, I need to use the parameters calculated (from the 80% set) to produce and report the estimation error (for the dependent variable). This process is required to run 100 times.

I encountered the following difficulties:

1. how to keep both (80% and 20%) partitioned sample for further estimation (I can only find the command "sample", but it drops the observations and does not allow to maintain the rest 20% for further test).

2. how to output the specific estimation results (e.g. R square of 'reg') into a spreadsheet (e.g. Excel) (I can assess the estimated results stored in e( ), but how can I output it automatically to a Excel for report purpose).

3. how to do it automatically 100 times (How could I store the each partitioned sample (for 100 times) separately? Is a do-file enough to handle this?)

Best Regards,

Yang Li

School of Accounting

University of Technology, Sydney

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

**References**:**st: sample partition issue & programming***From:*Yang Li <Yang.Li-4@uts.edu.au>

- Prev by Date:
**st: Sender: owner-statalist@hsphsun2.harvard.edu** - Next by Date:
**st: RE: RE: RE: Error Correction Model** - Previous by thread:
**st: sample partition issue & programming** - Next by thread:
**st: Sender: owner-statalist@hsphsun2.harvard.edu** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |