| mars {mda} | R Documentation |
Multivariate additive regression splines.
mars(x, y, w, wp, degree, nk, penalty, thresh, prune, trace.mars,
forward.step, prevfit, ...)
An object of class "mars", which is a list with the following
components:
call |
call used to mars. |
all.terms |
term numbers in full model. 1 is the constant
term. Remaining terms are in pairs (2 3, 4 5, and so
on). all.terms indicates nonsingular set of terms. |
selected.terms |
term numbers in selected model. |
penalty |
the input penalty value. |
degree |
the input degree value. |
thresh |
the input threshold value. |
gcv |
gcv of chosen model. |
factor |
matrix with ij-th element equal to 1 if term i has a factor of the form x_j > c, equal to -1 if term i has a factor of the form x_j <= c, and to 0 if xj is not in term i. |
cuts |
matrix with ij-th element equal to the cut point c for variable j in term i. |
residuals |
residuals from fit. |
fitted |
fitted values from fit. |
lenb |
length of full model. |
coefficients |
least squares coefficients for final model. |
x |
the input x matrix. |
This function was coded from scratch, and did not use any of Friedman's mars code. It gives quite similar results to Friedman's program in our tests, but not exactly the same results. We have not implemented Friedman's anova decomposition nor are categorical predictors handled properly yet. Our version does handle multiple response variables, however. As it is not well-tested, we would like to hear of any bugs.
Trevor Hastie and Robert Tibshirani
J. Friedman, ``Multivariate Additive Regression Splines''. Annals of Statistics, 1991.
predict.mars,
model.matrix.mars
data(trees)
fit1 <- mars(trees[,-3], trees[3])
showcuts <- function(obj)
{
tmp <- obj$cuts[obj$sel, ]
dimnames(tmp) <- list(NULL, names(trees)[-3])
tmp
}
showcuts(fit1)
## examine the fitted functions
par(mfrow=c(1,2), pty="s")
Xp <- matrix(sapply(trees[1:2], mean), nrow(trees), 2, byrow=TRUE)
for(i in 1:2) {
xr <- sapply(trees, range)
Xp1 <- Xp; Xp1[,i] <- seq(xr[1,i], xr[2,i], len=nrow(trees))
Xf <- predict(fit1, Xp1)
plot(Xp1[ ,i], Xf, xlab=names(trees)[i], ylab="", type="l")
}