# NOT RUN {
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