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: using bootstrap for sample splitting and out-of-sample prediction


From   Tirthankar Chakravarty <tirthankar.chakravarty@gmail.com>
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/


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