slm.fit: Internal slm fitting functions

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Fitting functions for sparse linear model fitting.

Usage

1
2
3
slm.fit(x,y,method, ...)
slm.wfit(x,y,weights,...)
slm.fit.csr(x, y, ...)

Arguments

x

design matrix.

y

vector of response observations.

method

only csr is supported currently

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

The length of weights must be the same as the number of observations. The weights must be nonnegative and it is strongly recommended that they be strictly positive, since zero weights are ambiguous.

...

additional arguments.

Details

slm.fit and slm.wfit call slm.fit.csr to do Cholesky decomposition and then backsolve to obtain the least squares estimated coefficients. These functions can be called directly if the user is willing to specify the design matrix in matrix.csr form. This is often advantageous in large problems to reduce memory requirements.

Value

A list of class slm consisting of:

coef

estimated coefficients

chol

cholesky object from fitting

residuals

residuals

fitted

fitted values

df.residual

degrees of freedom

terms

terms

call

call

...

Author(s)

Roger Koenker

References

Koenker, R and Ng, P. (2002). SparseM: A Sparse Matrix Package for R,
http://www.econ.uiuc.edu/~roger/research/home.html

See Also

slm

Examples

1
2
3
4
5
6
7
8
9
data(lsq)
X <- model.matrix(lsq) #extract the design matrix
y <- model.response(lsq) # extract the rhs
class(X) # -> "matrix.csr"
class(y) # -> NULL
slm.fit(X,y)->slm.fit.o # this is much more efficient in memory usage than slm()
slm(y~as.matrix(X)-1) -> slm.o # this requires X to be transformed into dense mode
cat("Difference between `slm.fit' and `slm' estimated coefficients =",
	sum(abs(slm.fit.o$coef-slm.o$coef)),"\n")

Example output

Attaching package: 'SparseM'

The following object is masked from 'package:base':

    backsolve

[1] "matrix.csr"
attr(,"package")
[1] "SparseM"
[1] "matrix"
Difference between `slm.fit' and `slm' estimated coefficients = 0 

SparseM documentation built on Feb. 18, 2021, 5:06 p.m.