Learn R Programming

gets (version 0.22)

regressorsMean: Create the regressors of the mean equation

Description

The function generates the regressors of the mean equation in an arx model. The returned value is a matrix with the regressors and, by default, the regressand in column one. By default, observations (rows) with missing values are removed in the beginning and the end with na.trim, and the returned matrix is a zoo object.

Usage

regressorsMean(y, mc = FALSE, ar = NULL, ewma = NULL, mxreg = NULL,
  return.regressand = TRUE, return.as.zoo = TRUE, na.trim=TRUE)

Arguments

y

numeric vector, time-series or zoo object.

mc

logical. TRUE includes an intercept, whereas FALSE (default) does not.

ar

either NULL (default) or an integer vector, say, c(2,4) or 1:4 with the AR-terms. The AR-lags to include in the mean specification. If NULL, then no lags are included.

ewma

either NULL (default) or a list with arguments sent to the eqwma function. In the latter case a lagged moving average of y is included as a regressor.

mxreg

either NULL (default) or a numeric vector or matrix, say, a zoo object, of conditioning variables. Note that, if both y and mxreg are zoo objects, then their samples are matched.

return.regressand

logical. TRUE, the default, includes the regressand as column one in the returned matrix.

return.as.zoo

TRUE, the default, returns the matrix as a zoo object.

na.trim

TRUE, the default, removes observations with NA-values in the beginning and the end with na.trim.

Value

A matrix, by default of class zoo, with the regressand as column one (the default).

See Also

arx, isat, zoo and na.trim.

Examples

Run this code
# NOT RUN {
##generate some data:
y <- rnorm(10) #regressand
x <- matrix(rnorm(10*5), 10, 5) #regressors

##create regressors (examples):
regressorsMean(y, mxreg=x)
regressorsMean(y, mxreg=x, return.regressand=FALSE)
regressorsMean(y, mc=TRUE, ar=1:3, mxreg=x)
regressorsMean(log(y^2), mc=TRUE, ar=c(2,4))

##let y and x be time-series:
y <- ts(y, frequency=4, end=c(2018,4))
x <- ts(x, frequency=4, end=c(2018,4))
regressorsMean(y, mxreg=x)
regressorsMean(y, mc=TRUE, ar=1:3, mxreg=x)
regressorsMean(log(y^2), mc=TRUE, ar=c(2,4))

##missing values (NA):
y[1] <- NA
x[10,3] <- NA
regressorsMean(y, mxreg=x)
regressorsMean(y, mxreg=x, na.trim=FALSE)
# }

Run the code above in your browser using DataLab