Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: RE: using bootstrap for sample splitting and out-of-sample prediction
From
"Martin Weiss" <[email protected]>
To
<[email protected]>
Subject
st: RE: using bootstrap for sample splitting and out-of-sample prediction
Date
Tue, 27 Apr 2010 00:09:10 +0200
<>
Try this: (BTW, why is it not possible to -bootstrap r(mean), reps(50)
nodrop: myprog- on this thing? I have now searched for a solid hour for my
mistake, and cannot find it...)
*******
clear*
set obs 10000
gen x=rnormal()
//true model
gen y=2+3*x+rnormal()
sa myfile, replace
capt prog drop myprog
prog myprog
vers 10.1
u myfile, clear
gen forsort=runiform()
sort forsort
reg y x in 1/5000
predict res, res
su res in 5001/10000, mean
end
tempname hdle
tempfile info
postfile `hdle' iteration mean using `info'
qui forv i=0/1000{
myprog
post `hdle' (`i') (r(mean))
}
postclose `hdle'
use `info', clear
l, abbrev(12) noobs sep(0)
*
*bs mean=r(mean), reps(200) nodrop: myprog
*******
HTH
Martin
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Lin, Bill
Sent: Montag, 26. April 2010 22:54
To: [email protected]
Subject: st: using bootstrap for sample splitting and out-of-sample
prediction
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/
*
* 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/