buildgam {buildmer} R Documentation

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

### Description

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

### Usage

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


### Arguments

 formula See the general documentation under buildmer-package data See the general documentation under buildmer-package family See the general documentation under buildmer-package quickstart 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. buildmerControl Control arguments for buildmer — see the general documentation under buildmerControl

### Details

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 cox.ph 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.

buildmer-package

### Examples



library(buildmer)
model <- buildgam(f1 ~ s(timepoint,by=following) + s(participant,by=following,bs='re') +
s(participant,timepoint,by=following,bs='fs'),data=vowels)



[Package buildmer version 2.5 Index]