roll.reg: Computes Rolling Regression.

View source: R/roll.reg.R

roll.regR 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

numeric or a column matrix of a dependent variable

x

matrix of independent variables, different columns should correspond to different variables, if not specified only a constant will be used

window

numeric, a size of a window for rolling

c

optional, logical, a parameter indicating whether constant is included, if not specified c=TRUE is used, i.e., constant is included

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

y, forecasted time-series

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)

fDMA documentation built on July 26, 2023, 6:09 p.m.

Related to roll.reg in fDMA...