* * CONDITION.RPF * Example of conditional forecasting in a VAR * * RATS User's Guide, Example from Section 7.7.2. * open data oecdsample.rat calendar(q) 1981 data(format=rats) 1981:1 2006:4 can3mthpcp canexpgdpchs \$ canexpgdpds canm1s canusxsr usaexpgdpch * set logcangdp = log(canexpgdpchs) set logcandefl = log(canexpgdpds) set logcanm1 = log(canm1s) set logusagdp = log(usaexpgdpch) set logexrate = log(canusxsr) * system(model=canmodel) variables logcangdp logcandefl logcanm1 logexrate can3mthpcp logusagdp lags 1 to 4 det constant end(system) estimate * compute neqn=%nvar * * This is the forecast range * compute fstart=2007:1,fend=2009:4 * * This does the conditional forecast into the series CONDFORE(1) to * CONDFORE(6). Note that you use the name of the dependent variable on * the constraint. The first constraint has LOGUSAGDP at 2007:4 hitting * the value of the same series at 2006:4 plus .05 (for 5% year over year * growth), and the second has a 10% change over two years to 2008:4. * @condition(model=canmodel,from=fstart,to=fend,results=condfore) 2 # logusagdp 2007:4 logusagdp(2006:4)+.05 # logusagdp 2008:4 logusagdp(2006:4)+.10 * * This computes the unconditional forecasts into FORECAST(1) to * FORECAST(6). * forecast(model=canmodel,results=forecasts,from=fstart,to=fend) * * This graphs the conditional and uncondition forecasts for each of the * series. * do i=1,neqn compute [label] l=%modellabel(canmodel,i) graph(header="Forecasts of "+l,window=l,\$ key=below,klabels=||"Unconditional","Conditional"||) 2 # forecasts(i) # condfore(i) end do i * * This saves 1000 simulated values of Canadian Real GDP from the * distribution constrained to 5% real growth of US Real GDP. It uses a * series of vectors of dimension 1000; one for each time period during * the forecast range. * compute ndraws=1000 dec series[vect] can gset can fstart fend = %zeros(ndraws,1) do draw=1,ndraws @condition(simulate,model=canmodel,from=fstart,to=fend,\$ results=simfore) 2 # logusagdp 2007:4 logusagdp(2006:4)+.05 # logusagdp 2008:4 logusagdp(2006:4)+.10 * * Save the conditional simulation of Canadian RGP (variable 1 as this * model is ordered). * do t=fstart,fend compute can(t)(draw)=simfore(1)(t) end do t end do draw * * Compute the 84th and 16th percentiles of the distribution * set upper fstart fend = %fractiles(can(t),||.84||)(1) set lower fstart fend = %fractiles(can(t),||.16||)(1) graph(header="Canadian Real GDP with High Growth of US GDP",key=below,\$ klabels=||"Unconditional","Conditional","84%ile","16%ile"||) 4 # forecasts(1) # condfore(1) # upper / 3 # lower / 3 * * Transform the GDP numbers into average (annualized) growth rates from fstart-1. * set fgrowth fstart fend = 400.0*(forecasts(1)-logcangdp(fstart-1))/(t-fstart+1) set cgrowth fstart fend = 400.0*(condfore(1)-logcangdp(fstart-1))/(t-fstart+1) set ugrowth fstart fend = 400.0*(upper-logcangdp(fstart-1))/(t-fstart+1) set lgrowth fstart fend = 400.0*(lower-logcangdp(fstart-1))/(t-fstart+1) graph(header="Canadian Real GDP Average Growth with High Growth of US GDP",key=below,\$ klabels=||"Unconditional","Conditional","84%ile","16%ile"||) 4 # fgrowth # cgrowth # ugrowth / 3 # lgrowth / 3