[R] MARS help?

Spencer Graves spencer.graves at pdf.com
Wed Oct 18 05:43:41 CEST 2006


      I'm trying to use mars{mda} to model functions that look fairly 
close to a sequence of straight line segments.  Unfortunately, 'mars' 
seems to totally miss the obvious places for the knots in the apparent 
first order spline model, and I wonder if someone can suggest a better 
way to do this.  The following example consists of a slight downward 
trend followed by a jump up after t1=4, following by a more marked 
downward trend after t1=5: 

Dat0 <- cbind(t1=1:10,
   x=c(1, 0, 0, 90, 99, 95, 90, 87, 80, 77))
library(mda)
fit0 <- mars(Dat0[, 1, drop=FALSE], Dat0[, 2],
             penalty=.001)
plot(Dat0, type="l")
lines(Dat0[, 1], fit0$fitted.values,
      lty=2, col="red")

      Are there 'mars' options I'm missing or other software I should be 
using? 

      I've got thousands of traces crudely like this of different 
lengths, and I want an automated way of summarizing similar traces in 
terms of a fixed number of knots and associated slopes for each linear 
spline segment max(0, t1-t.knot). 

      Thanks,
      Spencer Graves



More information about the R-help mailing list