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 n * p.

y

vector of observations of length n, or a matrix with n rows.

offset

(numeric of length n). This can be used to specify an a priori known component to be included in the linear predictor during fitting.

method

currently, only method = "qr" is supported.

tol

tolerance for the qr decomposition. Default is 1e-7.

singular.ok

logical. If FALSE, a singular model is an error.

...

currently disregarded.

w

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.

Value

a list with components (for lm.fit and lm.wfit)

coefficients

p vector

residuals

n vector or matrix

fitted.values

n vector or matrix

effects

n vector of orthogonal single-df effects. The first rank of them correspond to non-aliased coefficients, and are named accordingly.

weights

n vector — only for the *wfit* functions.

rank

integer, giving the rank

df.residual

degrees of freedom of residuals

qr

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.

Functions

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)

[Package complexlm version 1.1.2 Index]