> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of [email protected]
> Sent: Monday, September 05, 2005 1:57 PM
> To: [email protected]
> Subject: st: predictive model
>
> dear statalist members,
>
> I've set up a multiple linear regression model, and I've to evaluate the
> predictive power of the model: in order to obtain the prediction error,
> I'd use
> the 10 fold cross validation: is it possible with stata?
>
> thank,
>
> Marta
>
Does this method involve dividing the data into 10 subsets of equal size;
running the regression 10 times, each time leaving out one of the subsets
and using the omitted subset to compute the error criterion?
I believe this might work:
sysuse auto,clear
gen random = uniform()
sort random
gen group = group(10)
forv i = 1/10 {
qui {
reg mpg gear weight head if group != `i'
predict res if group == `i', res
replace res = res^2
sum res, meanonly
local mse = r(mean)
local error "`error' + `mse'"
drop res
}
}
disp "MSE (10 Fold) = "(`error')/10
Hope this helps,
Scott
*
* 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/