ols {fastmatrix} | R Documentation |
Fit linear regression model
Description
Returns an object of class "ols"
that represents a linear model fit.
Usage
ols(formula, data, subset, na.action, method = "qr", tol = 1e-7, maxiter = 100,
x = FALSE, y = FALSE, contrasts = NULL, ...)
Arguments
formula |
an object of class |
data |
an optional data frame, list or environment (or object coercible
by |
subset |
an optional vector specifying a subset of observations to be used in the fitting process. |
na.action |
a function which indicates what should happen when the data
contain |
method |
the least squares fitting method to be used; the options are |
tol |
tolerance for the conjugate gradients ( |
maxiter |
The maximum number of iterations for the conjugate gradients ( |
x , y |
logicals. If |
contrasts |
an optional list. See the |
... |
additional arguments (currently disregarded). |
Value
ols
returns an object of class
"ols"
.
The function summary
is used to obtain and print a summary of the
results. The generic accessor functions coefficients
, fitted.values
and residuals
extract various useful features of the value returned by ols
.
An object of class "ols"
is a list containing at least the
following components:
coefficients |
a named vector of coefficients |
residuals |
the residuals, that is response minus fitted values. |
fitted.values |
the fitted mean values. |
RSS |
the residual sum of squares. |
cov.unscaled |
a |
call |
the matched call. |
terms |
the |
contrasts |
(only where relevant) the contrasts used. |
y |
if requested, the response used. |
x |
if requested, the model matrix used. |
model |
if requested (the default), the model frame used. |
See Also
Examples
# tiny example of regression
y <- c(1, 3, 3, 2, 2, 1)
x <- matrix(c(1, 1,
2, 1,
3, 1,
1,-1,
2,-1,
3,-1), ncol = 2, byrow = TRUE)
f0 <- ols(y ~ x) # intercept is included by default
f0 # printing results (QR method was used)
f1 <- ols(y ~ x, method = "svd") # using SVD method instead
f1