Learn R Programming

bsts (version 0.9.5)

aggregate.weeks.to.months: Aggregate a weekly time series to monthly

Description

Aggregate measurements from a weekly time series into a monthly time series.

Usage

AggregateWeeksToMonths(weekly.series,
                          membership.fraction = NULL,
                          trim.left = TRUE,
                          trim.right = NULL)

Arguments

weekly.series

A numeric vector or matrix of class zoo giving the weekly time series to be aggregated. The index must be convertible to class Date.

membership.fraction

A optional numeric vector corresponding to weekly.series, giving the fraction of each week's observation attributable to the month containing the week's first day. If missing, then weeks will be split across months in proportion to the number of days in each month.

trim.left

Logical indicating whether the first observation in the monthly aggregate should be removed.

trim.right

Logical indicating whether the final observation in the monthly aggregate should be removed.

Value

A zoo-matrix (if weekly.series is a matrix) or vector (otherwise) containing the aggregated values of weekly.series.

See Also

AggregateTimeSeries

Examples

Run this code
# NOT RUN {
  week.ending <- as.Date(c("2011-11-05",
                           "2011-11-12",
                           "2011-11-19",
                           "2011-11-26",
                           "2011-12-03",
                           "2011-12-10",
                           "2011-12-17",
                           "2011-12-24",
                           "2011-12-31"))

  weekly.values <- zoo(rnorm(length(week.ending)), week.ending)
  monthly.values <- AggregateWeeksToMonths(weekly.values)
# }

Run the code above in your browser using DataLab