Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

Re: st: using bootstrap for sample splitting and out-of-sample prediction

 From Tirthankar Chakravarty To statalist@hsphsun2.harvard.edu Subject Re: st: using bootstrap for sample splitting and out-of-sample prediction Date Tue, 27 Apr 2010 02:51:22 +0530

```Here is a solution:
**********************************************
clear*
sysuse auto, clear
forv i=1/1000 {
cap drop touse
cap drop pred_resid
qui g touse = runiform() < .5
qui reg mpg  length weight if touse
qui predict pred_resid if !touse, resid
qui su pred_resid
mat avdiff = (nullmat(avdiff)\ `r(mean)')
}
mat list avdiff
**********************************************

T

2010/4/27 Lin, Bill <bill.lin.79@gmail.com>:
> Hello All,
>
> I am trying to split my sample into two halves, use one half for
> estimation and another half for out-of sample prediction, and then
> calculate the average difference between fitted values and the
> observed values. I want to do it repeatedly, say 1000 times, using
> bootstrap. My problem is that I don't know how to store the average
> difference calculated each time in a matrice as in Matlab. Can any one
> give some suggestions? thanks,
>
>
> Bill Lin
> *
> *   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/
>

--
To every ω-consistent recursive class κ of formulae there correspond
recursive class signs r, such that neither v Gen r nor Neg(v Gen r)
belongs to Flg(κ) (where v is the free variable of r).

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