# NOT RUN {
data(wage1)
## Cross-validated model selection for spline degree and bandwidths Note
## - we override the default nmulti here to get a quick illustration
## (we don't advice doing this, in fact advise using more restarts in
## serious applications)
model <- crs(lwage~married+
female+
nonwhite+
educ+
exper+
tenure,
basis="additive",
complexity="degree",
data=wage1,
segments=c(1,1,1),
nmulti=1)
summary(model)
## Residual plots
plot(model)
## Partial mean plots (control for non axis predictors)
plot(model,mean=TRUE)
## Partial first derivative plots (control for non axis predictors)
plot(model,deriv=1)
## Partial second derivative plots (control for non axis predictors)
plot(model,deriv=2)
## Compare with local linear kernel regression
require(np)
model <- npreg(lwage~married+
female+
nonwhite+
educ+
exper+
tenure,
regtype="ll",
bwmethod="cv.aic",
data=wage1)
summary(model)
## Partial mean plots (control for non axis predictors)
plot(model,common.scale=FALSE)
## Partial first derivative plots (control for non axis predictors)
plot(model,gradients=TRUE,common.scale=FALSE)
detach("package:np")
# }
Run the code above in your browser using DataLab