Im trying to introduce a weekly sliding time-window into my dataset (i.e., days 1-7 then 2-8, 3-9, 4-10... and so on). I currently have non-overlapping weekly time windows in my code but can't figure out how to repeat the data (each =7) but apply a +1 shift.
This gives me a non-overlapping weekly time window, but i need to repeat the dataset, extending the df having 1-7,2-8,3-9... consecutively.
library(EpiEstim)
data(Flu2009)
data_infer <- data.frame(t = 1:length(Flu2009$incidence$I) ,
I = c(Flu2009$incidence$I),
OI = overall_infectivity(Flu2009$incidence, Flu2009$si_distr) )
data_infer$logOI <- log(data_infer$OI)
data_infer$Rt <- ceiling(nrow(data_infer)/7)
data_infer$Rt[ 1:(floor(nrow(data_infer)/7)*7) ] <- rep(1:floor(nrow(data_infer)/7),each = 7)
Any help or guidance greatly appreciated.