| wa {hacks} | R Documentation |
Calculates a weighted average for a given vector.
wa(x, w = 1, stdz = TRUE)
x |
a numeric vector. |
w |
weight value in (0, 1]. |
stdz |
should the weights sum to one? If
FALSE then the output resembles a weighted
sum (see Details). |
This function calculates a weighted average where the
first element represents the starting time period and
the last element represents the ending time period. The
unstandardized weights are calculated as wt[i] = w^(n-i).
If stdz = TRUE then the weights are standardized so
that they sum to one.
Nathan Stephens
wa(1:10,0.5)