Good afternoon,
I am trying to make -rolling- work on the basis of a programme provided in the -rolling- manual. I change one line, and it does not work anymore, and I do not see why. This is my code:
and the line that is apparently causing the problem is in red.
This is the code provided in the manual, and it works:
and it works.
I am trying to make -rolling- work on the basis of a programme provided in the -rolling- manual. I change one line, and it does not work anymore, and I do not see why. This is my code:
Code:
use ibm, clear
tsset t
cap prog drop myforecast
program myforecast, rclass
syntax [if]
regress ibm L.ibm L.spx `if'
// Find last time period of estimation sample and
// make forecast for period just after that
summ t if e(sample)
local last = r(max)
predict fcast in `=`last'+1'
return scalar forecast = fcast[`last'+1]
// Next period's actual return
// Will return missing value for final period
return scalar actual = ibm[`last'+1]
end
rolling actual=r(actual) forecast=r(forecast), recursive window(20): myforecast
This is the code provided in the manual, and it works:
Code:
use ibm, clear tsset t cap prog drop myforecast program myforecast, rclass syntax [if] regress ibm L.ibm L.spx `if' // Find last time period of estimation sample and // make forecast for period just after that summ t if e(sample) local last = r(max) local fcast = _b[_cons] + _b[L.ibm]*ibm[`last'] + /// _b[L.spx]*spx[`last'] return scalar forecast = `fcast' // Next period's actual return // Will return missing value for final period return scalar actual = ibm[`last'+1] end rolling actual=r(actual) forecast=r(forecast), recursive window(20): myforecast

Comment