[R] To convert a quarterly data to a monthly data.

Berend Hasselman bhh at xs4all.nl
Wed Feb 20 21:55:34 CET 2013

On 20-02-2013, at 21:21, "Yuan, Rebecca" <rebecca.yuan at bankofamerica.com> wrote:

> Hello Rolf,
> Thanks for your kind reply!
> I figured out there is a function splint in fields that can do the cubic spine interpolation which would enable me to get the monthly series from the quarterly series.
> Problem solved.
> Here is the code I use the do the task:
> out <- cbind(out, splint(qtrly$rDate, qtrly[,names(qtrly)[i]] ,subset(mthly, rDate <= max(qtrly$rDate))$rDate ))
> where qtrly is the quarterly data and mthly is the monthly data.

Here is an example using package zoo:

yq <- zooreg(c(100,101,120,103), start=2000, frequency=4)

# complicated method
zm <- zooreg(rep(NA,12),start=2000,freq=12)
na.spline(merge(yq, zm)[, 1])

# Easy direct method taken from help pages of zoo

na.spline(yq, xout=as.yearmon(start(yq)+(0:11)/12)) 


na.approx(yq, xout=as.yearmon(start(yq)+(0:11)/12))  


More information about the R-help mailing list