Multiple interpolations

I have a dataframe that I am trying to perform interpolations across multiple groups. A sample df is as follows:

library(tidyverse)
library(lubridate)
series_num <- c("1", "1", "1", "1", "1", "2", "2", "2", "2", "2", "3", "3", "3", "3", "3")
mth <-c("2019-11-01", "2019-11-10", "2019-12-01", "2020-01-13", "2020-05-03",
        "2019-11-15", "2019-11-30", "2019-12-15", "2020-01-28", "2020-05-28",
        "2019-11-30", "2019-12-15", "2019-12-28", "2020-01-29", "2020-06-14")
mth <- mth %>% as_date(mth)
rate <- c("1.3325", "1.3315", "1.2995", "1.2955", "1.2965",
         "1.3105", "1.31", "1.2985", "1.298", "1.2945",
         "1.32", "1.3195", "1.3155", "1.3125", "1.3155")
rate <- rate %>% as.numeric(rate)
df <- data.frame(series_num, mth, rate)

I need to expand the time series to a daily series and interpolate the rate within each series_num group using the mth and rate variables. The output should be daily time series for each series_num with the interpolated rate for each day. The mth and rate variables change within each series_num so the time intervals are not constant, and the rates vary.

The output would look similar to the following (with hypothetical interpolated values)

Any suggestions would be greatly appreciated.

Take a look at the tempdisagg package, which looks like it is designed for your problem. If not, c'mon back!

1 Like