
Multivariate adaptive 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 used to mars
.
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.
term numbers in selected model.
the input penalty value.
the input degree value.
the input threshold value.
gcv of chosen model.
matrix with
matrix with
residuals from fit.
fitted values from fit.
length of full model.
least squares coefficients for final model.
a matrix of basis functions obtained from the input x matrix.
a matrix containing the independent variables.
a vector containing the response variable, or in the case of multiple responses, a matrix whose columns are the response values for each variable.
an optional vector of observation weights (currently ignored).
an optional vector of response weights.
an optional integer specifying maximum interaction degree (default is 1).
an optional integer specifying the maximum number of model terms.
an optional value specifying the cost per degree of freedom charge (default is 2).
an optional value specifying forward stepwise stopping threshold (default is 0.001).
an optional logical value specifying whether the model
should be pruned in a backward stepwise fashion (default is
TRUE
).
an optional logical value specifying whether info
should be printed along the way (default is FALSE
).
an optional logical value specifying whether
forward stepwise process should be carried out (default is
TRUE
).
optional data structure from previous fit. To see the
effect of changing the penalty parameter, one can use prevfit with
forward.step = FALSE
.
further arguments to be passed to or from methods.
Trevor Hastie and Robert Tibshirani
J. Friedman, ``Multivariate Adaptive Regression Splines'' (with discussion) (1991). Annals of Statistics, 19/1, 1--141.
predict.mars
,
model.matrix.mars
.
Package earth also provides multivariate adaptive regression
spline models based on the Hastie/Tibshirani mars code in package
mda, adding some extra features. It can be used in the
method
argument of fda
or mda
.
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")
}
Run the code above in your browser using DataLab