# Application of GMonBoost to automobile data
# written by Florian Leitenstorfer, last update: April 29, 2007
# This file code for reproduction of automobile example, see:
# Tutz and Leitenstorfer (2007): Generalized Smooth Monotonic Regression in Additive Modelling,
# Journal of Computational and Graphical Statistics 16, 165-188.
# The data are given in the R package rpart (use newer version of this package, it
# is not included in older versions)
library(rpart)
#selection of the variables Mileage, weight and Disp.
car.data <- as.matrix(car.test.frame[,c(4,6,7)])
#transforming the variables into metrical terms
#gas consumption in lt./100km
car.data[,1] <- (1/(car.data[,1]*1.609))*3.78*100
#weight in kg
car.data[,2] <- car.data[,2]*0.453592
#displacement (lt.)
car.data[,3] <- car.data[,3]/61.0237441
#Comment: it is not plausible that the displacement is given in liters, as mentioned in the documentation of the package
# we believe that it is given in cubic inches, and transform it to litres.
#Fit of the model, with both components under monotonicity constraint, logistic basis functions (20 basis functions for each smooth component)
#stopping of boosting by aicc; the same ridge parameter is used as in the paper
car.GMonBoost <- GMonBoost(y=car.data[,1],X=car.data[,2:3],spline="logbas",mvec=c(T,T),family="gaussian",criterion="aicc",lambda=20,M=200,early=F)
#Plot of the smooth components
par(mfrow=c(1,2))
plot.GMonBoost(car.GMonBoost,xlab=c("weight","displacement"))