I want to create a dataset from FRED series and I use the quantmod
package like so:
library(quantmod)
getSymbols(c('FEDFUNDS', 'GDPPOT', 'DGS10'), src='FRED')
dat <- buildData(FEDFUNDS ~ DGS10 + GDPPOT, na.rm=FALSE)
What I need is an xts object with observations for all dates in the longest time series, and missing values to fill-in the shorter time series. In the example above, I get:
> head(dat, 2)
FEDFUNDS DGS10 GDPPOT
1962-10-01 2.90 3.93 3141.6
1963-01-01 2.92 NA 3173.9
> head(FEDFUNDS, 2)
FEDFUNDS
1954-07-01 0.80
1954-08-01 1.22
> head(DGS10, 2)
DGS10
1962-01-02 4.06
1962-01-03 4.03
> head(GDPPOT, 2)
GDPPOT
1949-01-01 1864.8
1949-04-01 1885.2
The FEDFUNDS series was truncated to match the minimum date value of the DGS10 series. I like the convenience of the buildData()
function, and would love to use it for this task, but I'm wondering how I can keep missing observations.
Thanks a lot for your time!
EDIT: The reason I don't want to use merge is that some of the data series have different periodicity and that buildData()
takes care of that automatically.