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 on April 23, and its replacement, statalist.org is already up and running.


[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" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
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: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Lin, Bill
Sent: Montag, 26. April 2010 22:54
To: statalist@hsphsun2.harvard.edu
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/


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