buildgam {buildmer}R Documentation

Use buildmer to fit generalized additive models using gam from package mgcv


Use buildmer to fit generalized additive models using gam from package mgcv


  data = NULL,
  family = gaussian(),
  quickstart = 0,
  buildmerControl = buildmerControl()



See the general documentation under buildmer-package


See the general documentation under buildmer-package


See the general documentation under buildmer-package


A numeric with values from 0 to 5. If set to 1, will use bam to obtain starting values for gam's outer iteration, potentially resulting in a much faster fit for each model. If set to 2, will disregard ML/REML and always use bam's fREML for the quickstart fit. 3 also sets discrete=TRUE. Values between 3 and 4 fit the quickstart model to a subset of that value (e.g.\ quickstart=3.1 fits the quickstart model to 10% of the data, which is also the default if quickstart=3. Values between 4 and 5 do the same, but also set a very sloppy convergence tolerance of 0.2.


Control arguments for buildmer — see the general documentation under buildmerControl


To work around an issue in gam, you must make sure that your data do not contain a variable named 'intercept'.

lme4 random effects are supported: they will be automatically converted using re2mgcv.

If gam's optimizer argument is not set to use outer iteration, gam fits using PQL. In this scenario, only crit='deviance' is supported.

General families implemented in mgcv are supported, provided that they use normal formulas. Currently, this is only true of the family. Because this family can only be fitted using REML, buildgam automatically sets gam's select argument to TRUE and prevents removal of parametric terms.

The quickstart function is experimental. If you desire more control (e.g.\ discrete=FALSE but use.chol=TRUE), additional options can be provided as extra arguments and will be passed on to bam as they are applicable. Note that quickstart needs to be larger than 0 to trigger the quickstart path at all.

If scaled-t errors are used (family=scat), the quickstart path will also provide initial values for the two theta parameters (corresponding to the degrees of freedom and the scale parameter), but only if your installation of package mgcv is at least at version 1.8-32.

See Also



model <- buildgam(f1 ~ s(timepoint,by=following) + s(participant,by=following,bs='re') +

[Package buildmer version 2.5 Index]