lm.fit {complexlm} | R Documentation |
Complex Variable Compatible Wrappers for stats::lm.fit()
and stats::lm.wfit()
Description
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()
.
Usage
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,
...
)
Arguments
x |
design matrix of dimension |
y |
vector of observations of length |
offset |
(numeric of length |
method |
currently, only |
tol |
tolerance for the |
singular.ok |
logical. If |
... |
currently disregarded. |
w |
vector of weights (length |
Value
a list
with components (for lm.fit
and lm.wfit
)
coefficients |
|
residuals |
|
fitted.values |
|
effects |
|
weights |
|
rank |
integer, giving the rank |
df.residual |
degrees of freedom of residuals |
qr |
the QR decomposition, see |
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.
Functions
-
lm.wfit
: wrapper for weighted linear fitting function.
Examples
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)