glmmVA: Fitting Generalized Linear Mixed-Effects Models with...

View source: R/glmmVA.R

glmmVAR Documentation

Fitting Generalized Linear Mixed-Effects Models with Variational Approximation

Description

Wraps the "gllvm" function to fit a (univariate) generalized linear mixed-effects model (GLMM) in a more familiar syntax. Both fixed and random effects are specified in lme4-style via the formula argument.

Usage

glmmVA(
  formula,
  data,
  family,
  control = list(reltol = 1e-10, optimizer = "optim", max.iter = 6000, maxit = 6000,
    optim.method = "BFGS"),
  control.va = list(Ar.struc = "unstructured", diag.iter = 0, Lambda.start = 0.3),
  control.start = list(starting.val = "zero", n.init = 1, n.init.max = 10, start.fit =
    NULL, scalmax = 10, MaternKappa = 1.5, rangeP = NULL, zetacutoff = NULL,
    start.optimizer = "nlminb", start.optim.method = "BFGS"),
  ...
)

Arguments

formula

a formula object describing both the fixed- and random-effects part of the model. A response should be present on the left-hand side of the operator, and otherwise passed as a named 'y' argument to the function. Random effects are written in lme4-style. Some structured random effects are supported, see "gllvm" for more information.

data

an optional data frame containing the variables named in formula.

family

a family as supported by the "gllvm" function.

control

A list with the following arguments controlling the optimization:

reltol:

convergence criteria for log-likelihood, defaults to 1e-10.

optimizer:

the log-likelihood can be optimized using "optim" (default) or "nlminb".

max.iter:

maximum number of iterations for optimizer = "nlminb", defaults to 6000.

maxit:

maximum number of iterations for optimizer, defaults to 6000.

optim.method:

optimization method to be used if optimizer is "optim". Defaults to "BFGS", but to "L-BFGS-B" for Tweedie family due the limited-memory use.

control.va

A list with the following arguments controlling the variational approximation method:

Ar.struc:

covariance structure of VA distributions, "unstructured" or "diagonal". Defaults to "unstructured". "Unstructured" meaning block diagonal for ordinary random effects, a kronecker product for propto structures with correlaton parameters, and fully unstructured for structured random effects (such as "corExp").

diag.iter:

non-negative integer which can sometimes be used to speed up the updating of variational (covariance) parameters, whichh can sometimes improve the fit. Either 0 or 1. Defaults to 0.

Lambda.start:

starting value for variances in VA distributions. Defaults to 0.3.

control.start

A list with the following arguments controlling the starting values:

starting.val:

defaults to "zero". See "gllvm" for details.

n.init:

number of initial runs. Uses multiple runs and picks up the one giving highest log-likelihood value. Defaults to 1.

n.init.max:

maximum number of refits try try for n.init without improvement, defaults to 10.

start.fit:

object that inherits of class 'gllvm' which can be given as starting parameters.

MaternKappa:

Starting value for smoothness parameter of Matern covariance function. Defaults to 3/2.

scalmax:

Sets starting value for the scale parameter for the coordinates. Defaults to 10, when the starting value for scale parameter scales the distances of coordinates between 0-10.

rangeP:

Sets starting value for the range parameter for the correlation structure.

zetacutoff:

A vector of length 2. Sets starting value for the cutoff parameters of the ordered beta model.

start.optimizer:

optimizer for starting value generation, see "optimizer" for more information.

start.optim.method:

optimizer method for starting value generation, see "optim.method" for more information.

...

other arguments passed onto the "gllvm" function.

Value

An object of class "glmmVA" that inherits from the "gllvm" class.

Author(s)

Bert van der Veen

See Also

gllvm

Examples

data(eSpider)
data <- cbind(data.frame(y = c(eSpider$abund[eSpider$nonNA,]),
           species = factor(rep(1:ncol(eSpider$abund), each = length(eSpider$nonNA))),
           site = factor(rep(1:length(eSpider$nonNA), ncol(eSpider$abund)))),
           do.call(rbind, replicate(ncol(eSpider$abund), scale(eSpider$X[eSpider$nonNA,]), 
           simplify = FALSE)))
# Example 1: crossed random slope effects                          
model <- glmmVA(y~species + ConWate + ConHumu + (0+ConHumu|species) + (0+ConWate|species),
                family = "poisson", data = data)

# Example 2: correlated random slopes
model1 <- glmmVA(y~species + ConWate + ConHumu + (0+ConWate+ConHumu|species),
                 family = "poisson", data = data)


gllvm documentation built on May 10, 2026, 5:06 p.m.