Given a state space model on a fine scale, the Harvey cumulator aggregates the model to a coarser scale (e.g. from days to weeks, or weeks to months).
1 2 3  HarveyCumulator(fine.series,
contains.end,
membership.fraction)

fine.series 
The finescale time series to be aggregated. 
contains.end 
A logical vector, with length matching

membership.fraction 
The fraction of each finescale time
observation belonging to the coarse scale time observation at the
beginning of the time interval. For example, if week i started in
March and ended in April, 
Returns a vector containing the course scale partial aggregates
of fine.series
.
Steven L. Scott stevescott@google.com
Harvey (1990), "Forecasting, structural time series, and the Kalman filter", Cambridge University Press.
Durbin and Koopman (2001), "Time series analysis by state space methods", Oxford University Press.
1 2 3 4 5 6 7 8 9 10 11 12 13 14  data(goog)
days < factor(weekdays(index(goog)),
levels = c("Monday", "Tuesday", "Wednesday",
"Thursday", "Friday"),
ordered = TRUE)
## Because of holidays, etc the days do not always go in sequence.
## (Sorry, Rebecca Black! https://www.youtube.com/watch?v=kfVsfOSbJY0)
## diff.days[i] is the number of days between days[i1] and days[i].
## We know that days[i] is the end of a week if diff.days[i] < 0.
diff.days < tail(as.numeric(days), 1)  head(as.numeric(days), 1)
contains.end < c(FALSE, diff.days < 0)
goog.weekly < HarveyCumulator(goog, contains.end, 1)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.