roll_regres.fit | R Documentation |
Function with a few validations before calling C++ code.
roll_regres.fit(x, y, width, do_compute = character(), grp = NULL, do_downdates = TRUE, min_obs = NULL)
x |
design matrix of dimension |
y |
numeric vector of observations of length |
width |
integer with the width of the moving window. Only used if
|
do_compute |
character vector with elements |
grp |
integer vector to be used if you e.g., want to run the regression
over weekly blocks of data. See "Details" in |
do_downdates |
logical which is |
min_obs |
positive integer with minimum number of observation that are
required in a window. Useful if there are gaps in |
First, the dqrdc
routine from LINPACK is used to form the QR
decomposition for the first window of data using Householder transformations
without pivoting. Then, the LINPACK dchud
and dchdd
routines
are used to update and downdate the Cholesky decomposition (the R matrix in
the QR decomposition).
Notice that unlike lm
, there are no checks of the rank of the matrix.
Same as roll_regres
.
Golub, G. H., & Van Loan, C. F. (2013). Matrix computations (4rd ed.). JHU Press. See chapter 5 and section 6.5.
roll_regres
for method similar to lm
.
# simulate data set.seed(9623556) n <- 50 p <- 2 X <- cbind(1, matrix(rnorm(p * n), ncol = p)) y <- drop(X %*% c(1, -1, 1)) + rnorm(n) # compute coefs out <- roll_regres.fit(x = X, y = y, width = 45L) tail(out$coefs)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.