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!!