computeS {spconf} | R Documentation |
Compute Smoothing Matrix
Description
Calculates the smoothing (or "hat") matrix from a design matrix.
Usage
computeS(x, inds = 1:nrow(x))
Arguments
x |
Matrix of spline values, assumed to have full rank. A data frame is coerced into a matrix. |
inds |
Column indices of smoothing matrix to return (corresponding to rows in |
Details
Given a matrix X
of spline values, this computes S=X(X'X)^(-1)X'
. When x
has many rows, this can be quite large. The inds
argument can be used to return a subset of columns from S
.
Value
An N
-by-n
matrix, where n
is the length of inds
and N
is the number of rows in x
.
See Also
Examples
# Simple design matrix case
X <- cbind(1, rep(c(0, 1), each=4))
S <- computeS(X)
# More complex example
xloc <- runif(n=100, min=0, max=10)
X <- splines::ns(x=xloc, df=4, intercept=TRUE)
S <- computeS(X)
S2 <- computeS(X, inds=1:4)
[Package spconf version 1.0.1 Index]