wa {hacks}R Documentation

Weighted Average

Description

Calculates a weighted average for a given vector.

Usage

wa(x, w = 1, stdz = TRUE)

Arguments

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).

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. author{Nathan Stephens}

Author(s)

Nathan Stephens

Examples

wa(1:10,0.5)

[Package hacks version 0.1-5 Index]