Since the state space model has a zero measurement error (no SV option), the smoothed series will hit the exact values at those chosen points within the month.
Code: Select all
*
* Creates a daily series by interpolating a monthly series
*
calendar(daily) 1999:1:1
open data cpifens.xls
data(format=xls,org=columns) * 2009:12:31 cpilfens
*
set logcpi = log(cpilfens)
*
* Find the weekday closest to the 15th
*
set smpl = %day(t)==%closestweekday(%year(t),%month(t),15)
*
* RW-AR1 state space model estimated in logs
*
nonlin rho
dec frml[rect] af
frml af = ||1.0+rho,-rho|1.0,0.0||
compute f=||1.0|0.0||
compute c=||1.0|0.0||
compute rho=0.0
dlm(a=af,c=c,f=f,y=%if(smpl,logcpi,%na),sw=1.0,var=conc,$
g=||1.0,-1.0||,method=gauss,type=smooth) / xstates
*
* Exp interpolated data back. Create a series with just the monthly
* value used. Graph the interpolated data (using a light gray) with
* symbols at the observed data points.
*
set interp = exp(xstates(t)(1))
set monthly = %if(smpl,cpilfens,%na)
graph(overlay=symbols,ovsame) 2
# interp / 8
# monthly