| mean.piar_index | R Documentation |
Aggregate an index over subperiods by taking the (usually arithmetic) mean of index values over consecutive windows of subperiods.
## S3 method for class 'chainable_piar_index'
mean(
x,
...,
weights = NULL,
window = NULL,
na.rm = FALSE,
contrib = TRUE,
r = 1,
duplicate_contrib = c("sum", "make.unique")
)
## S3 method for class 'direct_piar_index'
mean(
x,
...,
weights = NULL,
window = NULL,
na.rm = FALSE,
contrib = TRUE,
r = 1,
duplicate_contrib = c("sum", "make.unique")
)
x |
A price index, as made by, e.g., |
... |
Not currently used. |
weights |
A numeric vector of weights for the index values in |
window |
A positive integer giving the size of the window used to
average index values across subperiods. The default averages over all
periods in |
na.rm |
Should missing values be removed? By default, missing values
are not removed. Setting |
contrib |
Aggregate percent-change contributions in |
r |
Order of the generalized mean to aggregate index values. 0 for a
geometric index (the default for making elementary indexes), 1 for an
arithmetic index (the default for aggregating elementary indexes and
averaging indexes over subperiods), or -1 for a harmonic index (usually for
a Paasche index). Other values are possible; see
|
duplicate_contrib |
The method to deal with duplicate product
contributions. Either |
The mean() method constructs a set of non-overlapping windows of
length window, starting in the first period of the index, and takes
the mean of each index value in these windows for each level of the index.
The last window is discarded if it is incomplete (with a warning), so that
index values are
always averaged over window periods. The names for the first time
period in each window form the new names for the aggregated time periods.
Percent-change contributions are aggregated if contrib = TRUE following the
same approach as aggregate().
An optional vector of weights can be specified when aggregating index values over subperiods, which is often useful when aggregating a Paasche index; see section 4.3 of Balk (2008) for details.
A price index, averaged over subperiods, that inherits from the same
class as x.
Balk, B. M. (2008). Price and Quantity Index Numbers. Cambridge University Press.
Other index methods:
[.piar_index(),
aggregate.piar_index,
as.data.frame.piar_index(),
as.ts.piar_index(),
chain(),
contrib(),
head.piar_index(),
is.na.piar_index(),
levels.piar_index(),
merge.piar_index(),
split.piar_index(),
stack.piar_index(),
time.piar_index(),
window.piar_index()
index <- as_index(matrix(c(1:12, 12:1), 2, byrow = TRUE), chainable = FALSE)
# Turn a monthly index into a quarterly index
mean(index, window = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.