stats::lm.fit()
and stats::lm.wfit()
This function is just an if statement.
If the design matrix x
is complex, zlm.wfit()
is called.
Otherwise stats::lm.fit()
or stats::lm.wfit()
is called.
These functions are unlikely to be needed by end users, as they are called by lm()
.
lm.fit(
x,
y,
offset = NULL,
method = "qr",
tol = 1e-07,
singular.ok = TRUE,
...
)lm.wfit(
x,
y,
w,
offset = NULL,
method = "qr",
tol = 1e-07,
singular.ok = TRUE,
...
)
a list
with components (for lm.fit
and lm.wfit
)
p
vector
n
vector or matrix
n
vector or matrix
n
vector of orthogonal single-df
effects. The first rank
of them correspond to non-aliased
coefficients, and are named accordingly.
n
vector --- only for the *wfit*
functions.
integer, giving the rank
degrees of freedom of residuals
the QR decomposition, see qr
.
Fits without any columns or non-zero weights do not have the
effects
and qr
components.
.lm.fit()
returns a subset of the above, the qr
part
unwrapped, plus a logical component pivoted
indicating if the
underlying QR algorithm did pivot.
design matrix of dimension n * p
.
vector of observations of length n
, or a matrix with
n
rows.
(numeric of length n
). This can be used to
specify an a priori known component to be included in the
linear predictor during fitting.
currently, only method = "qr"
is supported.
tolerance for the qr
decomposition. Default
is 1e-7.
logical. If FALSE
, a singular model is an
error.
currently disregarded.
vector of weights (length n
) to be used in the fitting
process for the wfit
functions. Weighted least squares is
used with weights w
, i.e., sum(w * e^2)
is minimized.
lm.wfit
: wrapper for weighted linear fitting function.
set.seed(4242)
n <- 6
p <- 2
slop <- complex(real = 4.23, imaginary = 2.323)
slop2 = complex(real = 2.1, imaginary = -3.9)
interc <- complex(real = 1.4, imaginary = 1.804)
e <- complex(real=rnorm(n)/6, imaginary=rnorm(n)/6)
desmat <- matrix(c(complex(real = rnorm(n * p), imaginary = rnorm(n * p)), rep(1, n)), n, p + 1)
y = desmat %*% c(slop, slop2, interc) + e
lm.fit(desmat, y)
Run the code above in your browser using DataLab