summary.gam
Alternatively, simple random effects can be fitted with gam
, which makes comparison straightforward.
Package gamm4
is an alternative, which allows AIC type model selection for generalized models. predict.gam
to evaluate the function for whatever argument values you need.
If derivatives are required then the simplest approach is to use finite differencing (which also allows
SEs etc to be calculated). tprs
and the example therein. multinom
function, but have another object called multinom
loaded.) gam.method
no longer exists. The smoothness selection method (GCV, REML etc) is now controlled by the
method
argument to gam
while the optimizer is selected using the optimizer
argument.
See gam
and http://www.maths.bris.ac.uk/~sw15190/igam/index.html for details. gamm
or gamm4
, the reported AIC is different for the gam
object and
the lme
or lmer
object. Why is this? There are several reasons for this. The most important is that the
models being used are actually different in the two representations. When treating the GAM as a mixed model, you are
implicitly assuming that if you gathered a replicate dataset, the smooths in your model would look completely
different to the smooths from the original model, except for having the same degree of smoothness. Technically you would expect
the smooths to be drawn afresh from their distribution under the random effects model. When viewing the gam from the
usual penalized regression perspective, you would expect smooths to look broadly similar under replication of the data.
i.e. you are really using Bayesian model for the smooths, rather than a random effects model (it's just that the frequentist random
effects and Bayesian computations happen to coincide for computing the estimates). As a result of the different assumptions
about the data generating process, AIC model comparisons can give rather different answers depending on the model adopted.
Which you use should depend on which model you really think is appropriate. In addition the computations of the AICs are
different. The mixed model AIC uses the marginal liklihood and the corresponding number of model parameters. The gam model
uses the penalized likelihood and the effective degrees of freedom. "tp"
) with a large sample size, and experiment with different optimizers to find one that is
slow for your problem. For prediction error/MSE, then leaving the smoothing basis dimensions at their
arbitrary defaults, when these are inappropriate for the problem setting, is a good way of reducing performance.
Similarly, using p-splines in place of derivative penalty based splines will often shave a little more
from the performance here. Unlike REML/ML, prediction error based smoothness selection criteria such as Mallows Cp and GCV
often produce a small proportion of severe overfits, so careful choise of smoothness selection method can help further.
In particular GCV etc. usually result in worse confidence interval and p-value performance than ML or REML. If all this
fails, try using a really odd simulation setup for which mgcv is clearly not suited: for example poor performance is almost
guaranteed for small noisy datasets with large numbers of predictors. Wood S.N. (2006) Generalized Additive Models: An Introduction with R. Chapman and Hall/CRC Press.