Convert monthly data to daily

For questions and discussion related to reading in and working with data.

Convert monthly data to daily

Postby TomDoan » Tue Feb 02, 2010 8:28 am

This interpolates a monthly series to (business) day data. Note that you have to read the data into a DAILY calendar, and thus need to be reading from a file format with dates. The original monthly value (this is CPI less food and energy) will be repeated for each day within the month. In order to make the state space model work, you need to pick just one time period within the month to represent the observed data. Here, we take the weekday closest to the 15th since that corresponds roughly to the timing of the (sampling done for the) CPI. The %if(smpl,logcpi,%na) turns into NA all other data points within the month.

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


Data file:
cpifens.xls
(23.35 KiB) Downloaded 342 times
TomDoan
 
Posts: 2717
Joined: Wed Nov 01, 2006 5:36 pm

Re: Convert monthly data to daily

Postby ivory4 » Tue Dec 06, 2011 12:10 am

How g is chosen?
ivory4
 
Posts: 149
Joined: Mon Aug 24, 2009 12:16 pm

Re: Convert monthly data to daily

Postby TomDoan » Tue Dec 06, 2011 10:46 am

ivory4 wrote:How g is chosen?


You can now use PRESAMPLE=ERGODIC rather than using G. The state-space model has two states with one unit root so ||1.0,-1.0|| transforms the states to the stationary submodel.
TomDoan
 
Posts: 2717
Joined: Wed Nov 01, 2006 5:36 pm


Return to Data: Reading, Writing, Transforming

Who is online

Users browsing this forum: No registered users and 1 guest

cron