open data "Users/henrique/Desktop/Dados.xls"
cal(m) 1980:01
data(format=xls,org=columns) 1980:01 2010:05 prod ipca ipca_l ipca12m_e com_pib fin1
set dummy1 = t==2002:10.or.t==2002:11.or.t==2007:12.or.t==2008:5.or.t==2009:2
set inflacao = ((ipca/ipca{1})-1)*100
set livres = ((ipca_l/ipca_l{1})-1)*100
filter(type=hp,tuning=14400) prod / prod_hp
set hiato = ((prod/prod_hp)-1)*100
linreg livres 2001:11 2010:05
# inflacao{1} ipca12m_e hiato{1} com_pib{1} dummy1
equation(lastreg) mdeq
dec vect sigmav(%nreg)
dec real sigmae
compute sigmae=.5*sqrt(%seesq)
compute sigmav=.01*%stderrs
nonlin sigmae sigmav
dlm(y=livres,c=%eqnxvector(mdeq,t),sw=%diag(sigmav.^2),sv=sigmae^2,$
presample=diffuse,method=bfgs,condition=10) 2001:11 2010:05 xstates vstates
set b0 = xstates(t)(1)
graph(footer="Figure 3.9 Time-varying regression coefficient b0")
# b0 2001:11 *
set b1 = xstates(t)(2)
graph(footer="Figure 3.10 Time-varying regression coefficient b1")
# b1 2001:11 *
set b2 = xstates(t)(3)
graph(footer="Figure 3.11 Time-varying regression coefficient b2")
# b2 2001:11 *
set b3 = xstates(t)(4)
graph(footer="Figure 3.12 Time-varying regression coefficient b3")
# b3 2001:11 *
set b4 = xstates(t)(5)
graph(footer="Figure 3.13 Time-varying regression coefficient b4")
# b4 2001:11 *dec vect[series] b(5) lower(5) upper(5)
set b0 2001:11 2010:05 = xstates(t)(1)
set lower_b0 2001:11 2010:05 = b0-1.5*sqrt(vstates(t)(1,1))
set upper_b0 2001:11 2010:05 = b0+1.5*sqrt(vstates(t)(1,1))
graph(footer="Time-varying regression coefficient b0") 3
# b0
# lower_b0
# upper_b0
open data tvp.xls
cal(q) 1959:3
data(format=xls,org=columns) 1959:03 1985:04 m1gr dintlag inflag surplag m1lag
linreg m1gr 1961:1 *
# constant dintlag inflag surplag m1lag
declare vect[series] b(5) lower(5) upper(5)
equation(lastreg) mdeq
dec vect sigmav(%nreg)
dec real sigmae
compute sigmae=.5*sqrt(%seesq)
compute sigmav=.01*%stderrs
nonlin sigmae sigmav
dlm(y=m1gr,c=%eqnxvector(mdeq,t),sw=%diag(sigmav.^2),sv=sigmae^2,$
presample=diffuse,method=bfgs,condition=10) 1959:3 1985:4 xstates vstates
display "sigmae = " sigmae
* sigmae = 0.31310
display "sigmav = " sigmav
* sigmav = 0.00157 6.63841e-04 7.26744e-04 0.00203 8.22955e-04
declare vector sigmavALT ;* WHERE "ALT" STANDS FOR "ALTERNATIVE"
compute sigmavALT = (||0.00157,6.63841e-04,7.26744e-04,0.00203,8.22955e-04||)
compute sigmaeALT = 0.31310
nonlin sigmavALT sigmaeALT
dlm(y=m1gr,c=%eqnxvector(mdeq,t),sw=%diag(sigmavALT.^2),sv=sigmaeALT^2,presample=diffuse,$
method=bfgs,condition=10) 1959:3 1985:4 xstatesALT vstatesALTcompute sigmae=.5*sqrt(%seesq)
compute sigmav = (||0,0,0,0,8.22955e-04||)
nonlin sigmae sigmav
dlm(start=sigmav(5),y=m1gr,c=%eqnxvector(mdeq,t),sw=%diag(sigmav.^2),sv=sigmae^2,$
presample=diffuse,method=bfgs,condition=10,type=smooth) 1959:3 1985:4 xstates vstates
dlm(start=(sigmavalt(5)=sigmav5),y=m1gr,c=%eqnxvector(mdeq,t),sw=%diag(sigmavALT.^2),sv=sigmaeALT^2,presample=diffuse,$
method=bfgs,condition=10,type=smooth) 1959:3 1985:4 xstatesALT vstatesALTcompute sigmae=.5*sqrt(%seesq)
compute sigmav = (||0,0,0,0,8.22955e-04||)
nonlin sigmae sigmav
dlm(start=sigmav(5),y=m1gr,c=%eqnxvector(mdeq,t),sw=%diag(sigmav.^2),sv=sigmae^2,$
presample=diffuse,method=bfgs,condition=10,type=smooth) 1959:3 1985:4 xstates vstatesdlm(y=inf_f,c=c,mu=mu,sw=%diag(sigmav.^2),sv=sigmae^2,presample=diffuse,method=bfgs,$
condition=10,yhat=yhat,vhat=vhat,svhat=svhat) 2001:11 2010:12 xstates vstatesdlm(start=(sigmavalt(5)=sigmav5),y=m1gr,c=%eqnxvector(mdeq,t),$
sw=%diag(sigmavALT.^2),sv=sigmaeALT^2,presample=diffuse,$
method=bfgs,condition=10,type=smooth) 1959:3 1985:4 xstatesALT vstatesALTying2728 wrote:Can you provide the codes to get the forecast error series and the conditional variance of forecast error in your program, kimnp044.rpf?
Thanks.
Return to Other Time Series Analysis
Users browsing this forum: Bing [Bot] and 0 guests