On 20-02-2013, at 21:21, "Yuan, Rebecca" <[email protected]> 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: library(zoo) yq <- zooreg(c(100,101,120,103), start=2000, frequency=4) # complicated method zm <- zooreg(rep(NA,12),start=2000,freq=12) merge(yq,zm) 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)) or na.approx(yq, xout=as.yearmon(start(yq)+(0:11)/12)) Berend ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

