I'm currently working with a time series that has counts on a weekly basis, but with denominators only available as a monthly total. I'd like to merge them to work with rates.
A year of the data looks something like this:
173 173 169 180 173 167 187 175 174 154 163 163
Starting January 2010 and going to December.
I'd use something like PROC EXPAND in SAS normally, but with the goal of trying to learn R I'm trying to implement this project entirely in R.
It seems like I should use something like the following to interpolate those values as a cubic spline using zoo
, but after several attempts, I've run aground. I've got two implementation questions I'm hoping people can help with:
Using something like na.spline will give me interpolated values, but they're the wrong ones as far as I can tell. The data above isn't a single unit of time, sampled once a month. It's the month total, so a weekly series should have four interpolated points ~1/4th the magnitude.
Is there any methods that use the actual dates involved? While it makes sense in the abstract to expand a monthly series to a weekly series by creating four new entries, not all months have four weeks in them.
In SAS, for reference, it would involve something like the following:
PROC EXPAND data=work.denom out=work.weekly from=month to=week;
ID month;
CONVERT denominator / method=SPLINE observed=TOTAL;
run;
Where month
is a timeseries index for a particular date (I picked the 1st of the month), and denominator
is the variable being expanded from a monthly to a weekly series.