Hello everyone, how are you?
These days take good care of yourself .
As I was given an assignment to use a dataset contains quarterly unemployment rate data from 1957:q1-2013:q4.
Now the question is to use AR(8) model to forecast unemploymen rate of change in 2012:q4-2013:q1.
Here is my command,however it went wrong when I tried to use forvalue loop.
And also the twoway tsline just have one actual line, there also should be a forecast line.
Could you please give some suggestions on my command?
Best wishes,
Ann
tsset quarter, quarterly
gen unrate1=ln(unrate)
gen deltaunrate=400*(ln(unrate)-ln(L.unrate))
capture drop deltaunrate_f
gen deltaunrate_f=.
forvalues t=`=tq(1957q1)'/`=tq(2012q4)' {
quietly {
regress deltaunrate L(1/8).deltaunrate L(1/8).if quarter>=tq(1957q1) & quarter<=`t'-1 (somehow this one is invalid???)
Predict fitted
replace deltaunrate_f=fitted if quarter==`t'
drop fitted
}
}
twoway tsline deltaunrate deltaunrate_f if tin(1957q1,2012q4), legend(order(1 "actual unemployment rate" 2 "forecast unemployment rate")) aspectratio(0.5)
These days take good care of yourself .
As I was given an assignment to use a dataset contains quarterly unemployment rate data from 1957:q1-2013:q4.
Now the question is to use AR(8) model to forecast unemploymen rate of change in 2012:q4-2013:q1.
Here is my command,however it went wrong when I tried to use forvalue loop.
And also the twoway tsline just have one actual line, there also should be a forecast line.
Could you please give some suggestions on my command?
Best wishes,
Ann
tsset quarter, quarterly
gen unrate1=ln(unrate)
gen deltaunrate=400*(ln(unrate)-ln(L.unrate))
capture drop deltaunrate_f
gen deltaunrate_f=.
forvalues t=`=tq(1957q1)'/`=tq(2012q4)' {
quietly {
regress deltaunrate L(1/8).deltaunrate L(1/8).if quarter>=tq(1957q1) & quarter<=`t'-1 (somehow this one is invalid???)
Predict fitted
replace deltaunrate_f=fitted if quarter==`t'
drop fitted
}
}
twoway tsline deltaunrate deltaunrate_f if tin(1957q1,2012q4), legend(order(1 "actual unemployment rate" 2 "forecast unemployment rate")) aspectratio(0.5)