Hi,
I run a prediction by the first 20 sample (y and x), and I would like to use the results to predict the 25th y_f (a special out of sample prediction). I think this is what I do in the programming, but it gives me the prediction for the 20th sample (in-sample). Why? How can I modify my program to obtain the out-of-sample (25th) prediction?
I have a loop, and I expect that it will give me prediction for 25th, 26th, 27th.
clear all
import excel "xyz1.xlsx", firstrow case(lower) clear
sca start_T = 20
sca n1 = 5
egen t1 = seq()
gen y_f = .
forvalues i = `=start_T'/`=start_T+2'{
reg y xa if t1<= `i' & t1> `i'-start_T // it works
predict temp in `i+n1'
replace y_f = temp in `i+n1'
drop temp
}
Thank you very much!!
Related Posts with prediction, unexpected results
Difference between clustering and fixed effects/adding control variables into the regressionI have observational data that was collected within the same year but on different days and in diffe…
Generating difference in meansHi all, I'm trying to solve what is likely a fairly easy problem but is tripping me up. I want to ch…
New Stata seminars and Structured Program on semHi everyone I wanted to let you know about some new Stata seminars that we're running in August thr…
ranking observations within a grouphow can i rank observations within a group? if i use the code: egen rank=group(var1), by(var2). i ge…
Sample Size using mcnemar test for two dependent binomial populationsHi Statalist users I need your help in estimating the sample size for an interventional study wher…
Subscribe to:
Post Comments (Atom)
0 Response to prediction, unexpected results
Post a Comment