This help topic is for R version 0.60. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/base/html/lsfit.html
lsfit {base}R Documentation

Find the Least Squares Fit

Description

The least squares estimate of \beta in the model

\bold{Y} = \bold{X \beta} + \bold{\epsilon}

is found. If weights are specified then a weighted least squares is performed with the weight given to the jth case specified by the jth entry in wt.

If any observation has a missing value in any field, that observation is removed before the analysis is carried out. This can be quite inefficient if there is a lot of missing data.

The implementation is via a modification of the LINPACK subroutines which allow for multiple left-hand sides.

Usage

lsfit(x, y, wt, intercept=TRUE, tolerance=1e-07, yname=NULL)

Arguments

x

a matrix whose rows correspond to cases and whose columns correspond to variables.

y

the responses, possibly matrix valued if you want to fit multiple left hand sides.

wt

an optional vector of weights for performing weighted least squares.

intercept

whether or not an intercept term should be used.

tolerance

the tolerance to be used in the matrix decomposition.

yname

an unused parameter for compatibility.

Value

A list with the following named components:

coef

the least squares estimates of the coefficients in the model (stated below).

residuals

residuals from the fit.

intercept

indicates whether an intercept was fitted.

qr

the QR decomposition of the design matrix.

See Also

lm which usually is preferable; ls.print, ls.diag, rreg.

Examples

##-- Using the same data as the lm(.) example:
lsD9 <- lsfit(x = as.numeric(gl(2,10,20)), y = weight)
ls.print(lsD9)

[Package base version 0.60 ]