if (FALSE) {
# Assume that d is a data.frame with point observations
# of a numerical response variable y and predictor variables
# a, b, and c.
# Fit a generalized additive model to y,a,b,c.
# We want to model b and c as nonlinear terms:
require(gam)
fit <- gam(y ~ a + s(b) + s(c), data = d)
multi.local.function(in.grids = c("a", "b", "c"),
out.varnames = "pred",
fun = grid.predict, fit = fit )
# Note that the 'grid.predict' uses by default the
# predict method of 'fit'.
# Model predictions are written to a file named pred.asc
}
if (FALSE) {
# A fake example of a logistic additive model:
require(gam)
fit <- gam(cl ~ a + s(b) + s(c), data = d, family = binomial)
multi.local.function(in.grids = c("a", "b", "c"),
out.varnames = "pred",
fun = grid.predict, fit = fit,
control.predict = list(type = "response") )
# 'control.predict' is passed on to 'grid.predict', which
# dumps its contents into the arguments for 'fit''s
# 'predict' method.
# Model predictions are written to a file named pred.asc
}
Run the code above in your browser using DataLab