Usage
ols(formula, data, weights, subset, na.action=na.delete, method="qr", model=FALSE, x=FALSE, y=FALSE, se.fit=FALSE, linear.predictors=TRUE, penalty=0, penalty.matrix, tol=1e-7, sigma, var.penalty=c('simple','sandwich'), ...)
Arguments
formula
an S formula object, e.g. Y ~ rcs(x1,5)*lsp(x2,c(10,20))
data
name of an S data frame containing all needed variables. Omit this to use a
data frame already in the S ``search list''.
weights
an optional vector of weights to be used in the fitting
process. If specified, weighted least squares is used with
weights weights
(that is, minimizing $sum(w*e^2)$);
otherwise ordinary least squares is used.
subset
an expression defining a subset of the observations to use in the fit. The default
is to use all observations. Specify for example age>50 & sex="male"
or
c(1:100,200:300)
respectively to use the observations satisfying a logical expression or those having
row numbers in the given vector.
na.action
specifies an S function to handle missing data. The default is the function na.delete
,
which causes observations with any variable missing to be deleted. The main difference
between na.delete
and the S-supplied function na.omit
is that
na.delete
makes a list
of the number of observations that are missing on each variable in the model.
The na.action
is usally specified by e.g. options(na.action="na.delete")
.
method
specifies a particular fitting method, or "model.frame"
instead to return the model frame
of the predictor and response variables satisfying any subset or missing value
checks.
model
default is FALSE
. Set to TRUE
to return the model frame
as element model
of the fit object.
x
default is FALSE
. Set to TRUE
to return the expanded design matrix as element x
(without intercept indicators) of the
returned fit object. Set both x=TRUE
if you are going to use
the residuals
function later to return anything other than ordinary residuals.
y
default is FALSE
. Set to TRUE
to return the vector of response values
as element y
of the fit.
se.fit
default is FALSE
. Set to TRUE
to compute the estimated standard errors of
the estimate of $X beta$ and store them in element se.fit
of the fit.
linear.predictors
set to FALSE
to cause predicted values not to be stored
tol
tolerance for information matrix singularity
sigma
If sigma
is given, it is taken as the actual root mean squared error parameter for the model. Otherwise sigma
is estimated from the data using the usual formulas (except for penalized models). It is often convenient to specify
sigma=1
for models with no error, when using fastbw
to find an
approximate model that predicts predicted values from the full model with
a given accuracy.
var.penalty
the type of variance-covariance matrix to be stored in the var
component of the fit when penalization is used. The default is the
inverse of the penalized information matrix. Specify
var.penalty="sandwich"
to use the sandwich estimator (see below
under var
), which limited simulation studies have shown yields
variances estimates that are too low.