slideWeight {BurStFin} | R Documentation |
Generate Time Weights Flexiibly
Description
Returns a vector of weights between 1 and 0 (inclusive). The general form is: some recent weights are 1, some early weights are 0, and weights between these vary linearly. It is allowable for no points to be specified as 0 or 1.
Usage
slideWeight(n, fractions = c(0, 1), observations = NULL,
locations = NULL)
Arguments
n |
the length of the result – the number of observations. |
fractions |
length 2 numeric vector giving the fraction of the way
between 0 and This is ignored if |
observations |
length 2 numeric vector giving the number of observations that should be 1 and the number of observations that should have any weight. The smaller is taken to be the former and the larger as the latter. |
locations |
length 2 numeric vector giving the locations (subscripts) for the ends of the linear slide. The smaller number is the index of the last 0, the larger is the index of the last value smaller than 1. |
Value
a numeric vector of length n
with values within the range
of 0 and 1 (inclusive).
The values are non-decreasing – meaning put more weight on more
recent observations.
Details
The arguments fractions
, observations
and locations
are all to control where the ends of the weights strictly between 0 and 1 are.
Only one of them is used.
locations
takes precedence.
fractions
is used if neither of the other two are given.
This is suitable to give as the weights
argument to
var.shrink.eqcor
and factor.model.stat
.
Revision
This help was last revised 2014 March 09.
See Also
var.shrink.eqcor
, factor.model.stat
.
Examples
# examples assume number of observations is 200
# all weights either 0 or 1
rollwin50 <- slideWeight(200, observations=c(50,50))
# 50 with full weight, 100 more with partial weight
swght50.150 <- slideWeight(200, observations=c(50, 150))
# approximately default weights of var.shrink.eqcor and factor.model.stat
lindec3 <- slideWeight(200, fractions=c(-1/2, 3/2))