File: slm.fit.Rd

package info (click to toggle)
r-cran-sparsem 1.84-2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,648 kB
  • sloc: fortran: 3,998; ansic: 75; makefile: 2
file content (65 lines) | stat: -rw-r--r-- 2,235 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
\name{slm.fit}
\alias{slm.fit}
\alias{slm.fit}
\alias{slm.wfit}
\alias{slm.fit.csr}
\title{Internal slm fitting functions}
\description{
 Fitting functions for sparse linear model fitting.
}
\usage{
slm.fit(x,y,method, \dots)
slm.wfit(x,y,weights,\dots)
slm.fit.csr(x, y, \dots)
}
\arguments{
\item{x}{ design matrix.  }
  \item{y}{ vector of response observations.  }
  \item{method}{ only \code{csr} is supported currently }
  \item{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 \deqn{\sum w_i*e_i^2}{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.}
  \item{\dots}{additional arguments.}
}
\details{
   \code{slm.fit} and \code{slm.wfit} call \code{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 \code{matrix.csr} form.  This is often
   advantageous in large problems to reduce memory requirements.
}
\value{
A list of class \code{slm} consisting of:
  \item{coef}{estimated coefficients}
  \item{chol}{cholesky object from fitting}
  \item{residuals}{residuals}
  \item{fitted}{fitted values}
  \item{df.residual}{degrees of freedom}
  \item{terms}{terms}
  \item{call}{call}
  ...
}
\references{
Koenker, R and Ng, P. (2002).  SparseM:  A Sparse Matrix Package for \R,\cr
\url{http://www.econ.uiuc.edu/~roger/research/home.html}}
\author{ Roger Koenker }

\seealso{  \code{\link{slm}} }
\examples{
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")
}

\keyword{ regression }