slm {slm}R Documentation

Fitting Stationary Linear Models

Description

slm is used to fit linear models when the error process is assumed to be strictly stationary.

Usage

slm(myformula, data = NULL, model = TRUE, x = FALSE, y = FALSE,
  qr = TRUE, method_cov_st = "fitAR", cov_st = NULL, Cov_ST = NULL,
  model_selec = -1, model_max = 50, kernel_fonc = NULL,
  block_size = NULL, block_n = NULL, plot = FALSE)

Arguments

myformula

an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted.

data

an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which slm is called.

model, x, y, qr

logicals. If TRUE the corresponding components of the fit (the model frame, the model matrix, the response, the QR decomposition) are returned.

method_cov_st

the method chosen by the user to estimate the autocovariances of the error process. The user has the choice between the methods "fitAR", "spectralproj", "efromovich", "kernel", "select" or "hac". By default, the "fitAR" method is used.

cov_st

numeric vector. The estimated autocovariances of the error process. The user can give his own vector.

Cov_ST

matrix. It is an argument given by the user if he wants to use his own covariance matrix estimator.

model_selec

integer or -1. The order of the method. If model_selec = -1, the method works automatically.

model_max

integer. Maximal order of the method.

kernel_fonc

function. Use this argument if method_cov_st = kernel. Define the kernel to use in the method. The user can give his own kernel function.

block_size

integer. Size of the bootstrap blocks if method_cov_st = kernel. block_size must be greater than model_max.

block_n

integer. Blocks number to use for the bootstrap if method_cov_st = kernel.

plot

logical. By default, plot = FALSE.

Details

The slm function is based on the architecture of the lm function. Models for slm are specified symbolically. A typical model has the form response ~ terms where response is the (numeric) response vector and terms is a series of terms which specifies a linear predictor for response. See the documentation of lm for more details.

Value

slm returns an object of class "slm". The function summary is used to obtain and print a summary of the results. The generic accessor functions coefficients, effects, fitted.values and residuals extract various useful features of the value returned by slm. An object of class "slm" is a list containing at least the following components:

method_cov_st

print the method chosen.

cov_st

the estimated autocovariances of the error process. NA if "hac" is used.

Cov_ST

if given by the user, the estimated covariance matrix of the error process. NA if "hac" is used.

model_selec

the order of the method.

norm_matrix

the normalization matrix of the least squares estimator.

design_qr

the matrix (X^{t} X)^{-1}.

coefficients

a named vector of the estimated coefficients.

residuals

the residuals, that is response minus fitted values.

fitted.values

the fitted values.

rank

the numeric rank of the fitted linear model.

df.residual

the number of observations minus the number of variables.

call

the matched call.

terms

the terms object used.

xlevels

(only where relevant) a record of the levels of the factors used in fitting.

y

if requested, the response used.

x

if requested, the model matrix used.

model

if requested (the default), the model frame used.

References

E. Caron, J. Dedecker and B. Michel (2019). Linear regression with stationary errors: the R package slm. arXiv preprint arXiv:1906.06583. https://arxiv.org/abs/1906.06583.

See Also

summary for summaries.

The generic functions coef, effects, residuals, fitted, vcov.

predict for prediction, including confidence intervals for x' beta, where x' is a new observation of the design.

confint for confidence intervals of parameters.

Examples

data("shan")
slm(shan$PM_Xuhui ~ . , data = shan, method_cov_st = "fitAR", model_selec = -1)

data("co2")
y = as.vector(co2)
x = as.vector(time(co2)) - 1958
reg1 = slm(y ~ x + I(x^2) + I(x^3) + sin(2*pi*x) + cos(2*pi*x) + sin(4*pi*x) +
 cos(4*pi*x) + sin(6*pi*x) + cos(6*pi*x) + sin(8*pi*x) + cos(8*pi*x),
 method_cov_st = "fitAR", model_selec = -1, plot = TRUE)

reg2 = slm(y ~ x + I(x^2) + I(x^3) + sin(2*pi*x) + cos(2*pi*x) + sin(4*pi*x) +
 cos(4*pi*x) + sin(6*pi*x) + cos(6*pi*x) + sin(8*pi*x) + cos(8*pi*x),
 method_cov_st = "kernel", model_selec = -1, model_max = 50, kernel_fonc = triangle,
 block_size = 100, block_n = 100)

[Package slm version 1.2.0 Index]