Computes running sample variance of a time-series x in a fixed length window.
RunningVar(x, W, circular = FALSE)
| x | A numeric vector. |
|---|---|
| W | A numeric scalar; length of |
| circular | Logical; whether running sample variance is computed assuming
circular nature of |
A numeric vector.
The length of output vector equals the length of x vector.
Parameter circular determines whether x time-series is assumed to have a circular nature.
Assume \(l_x\) is the length of time-series x, W is a fixed length of x time-series window.
If circular equals TRUE then
first element of the output time-series corresponds to sample variance of x[1:W],
last element of the output time-series corresponds to sample variance of c(x[l_x], x[1:(W - 1)]).
If circular equals FALSE then
first element of the output time-series corresponds to sample variance of x[1:W],
the \(l_x - W + 1\)-th element of the output time-series corresponds to sample variance of x[(l_x - W + 1):l_x],
last W-1 elements of the output time-series are filled with NA.
See runstats.demo(func.name = "RunningVar") for a detailed presentation.
#> [1] 0.3438391 0.5557440 1.1028621 3.2661092 3.2470397 2.1266755 0.3405289 #> [8] 0.2836473 NA NARunningVar(x, W = 3, circular = TRUE)#> [1] 0.34383915 0.55574395 1.10286211 3.26610922 3.24703967 2.12667546 #> [7] 0.34052892 0.28364729 0.02847671 0.03175456