roll.reg {fDMA} | R Documentation |
Computes Rolling Regression.
Description
This function computes Rolling Regression. For the first window
-1 observations Recursive Regression is computed. Since window
-th observation the rolling is performed.
Usage
roll.reg(y,x=NULL,window,c=NULL)
Arguments
y |
|
x |
|
window |
|
c |
optional, |
Details
It might happen during computations that lm
(which is used inside roll.reg
) will produce NA
or NaN
. In such a case regression coefficients for a given period are taken as 0
and p-values for t-test for statistical significance of regression coefficients are taken as 1
.
It is not possible to set c=FALSE
if x=NULL
. In such a case the function will automatically reset c=TRUE
inside the code.
Value
class reg
object, list
of
$y.hat |
fitted (forecasted) values |
$AIC |
Akaike Information Criterion (from the current window size) |
$AICc |
Akaike Information Criterion with a correction for finite sample sizes (from the current window size) |
$BIC |
Bayesian Information Criterion (from the current window size) |
$MSE |
Mean Squared Error (from the current window size) |
$coeff. |
regression coefficients |
$p.val |
p-values for t-test for statistical significance of regression coefficients |
$window |
window size |
$y |
|
See Also
grid.roll.reg
, print.reg
, summary.reg
, plot.reg
.
Examples
wti <- crudeoil[-1,1]
drivers <- (lag(crudeoil[,-1],k=1))[-1,]
ld.wti <- (diff(log(wti)))[-1,]
ld.drivers <- (diff(log(drivers)))[-1,]
roll1 <- roll.reg(y=ld.wti,x=ld.drivers,window=100)
roll2 <- roll.reg(y=ld.wti,window=100)