| 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 " |
data |
an optional data frame, list or environment (or object coercible by |
model, x, y, qr |
logicals. If |
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 |
model_max |
integer. Maximal order of the method. |
kernel_fonc |
function. Use this argument if |
block_size |
integer. Size of the bootstrap blocks if |
block_n |
integer. Blocks number to use for the bootstrap if |
plot |
logical. By default, |
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 |
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 |
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)