mcml_glmer {glmmrBase}R Documentation

lme4 style generlized linear mixed model

Description

A wrapper for Model stochastic maximum likelihood model fitting replicating lme4's syntax

Usage

mcml_glmer(
  formula,
  data,
  family,
  start = NULL,
  offset = NULL,
  verbose = 1L,
  iter.warmup = 100,
  iter.sampling = 50,
  weights = NULL,
  ...
)

Arguments

formula

A two-sided linear formula object including both the fixed and random effects specifications, see Details.

data

A data frame containing the variables named in 'formula'.

family

A family object expressing the distribution and link function of the model, see family.

start

Optional. A vector of starting values for the fixed effects.

offset

Optional. A vector of offset values.

verbose

Integer, controls the level of detail printed to the console, either 0 (no output), 1 (main output), or 2 (detailed output)

iter.warmup

The number of warmup iterations for the MCMC sampling step of each iteration.

iter.sampling

The number of sampling iterations for the MCMC sampling step of each iteration.

weights

Optional. A vector of observation level weights to apply to the model fit.

...

additional arguments passed to 'Model$MCML()'

Details

This function aims to replicate the syntax of lme4's 'lmer' command. The specified formula can be the standard lme4 syntax, or alternatively a glmmrBase style formula can also be used to allow for the wider range of covariance function specifications. For example both 'y~x+(1|cl/t)' and 'y~x+(1|gr(cl))+(1|gr(cl)*ar1(t))' would be valid formulae.

Value

A 'mcml' model fit object.

Examples

#create a data frame describing a cross-sectional parallel cluster
#randomised trial
df <- nelder(~(cl(10)*t(5)) > ind(10))
df$int <- 0
df[df$cl > 5, 'int'] <- 1
# simulate data using the Model class
df$y <- Model$new(
  formula = ~ factor(t) + int - 1 + (1|gr(cl)) + (1|gr(cl,t)),
  data = df,
  family = stats::binomial()
)$sim_data()
## Not run: 
fit <- mcml_glmer(y ~ factor(t) + int - 1 + (1|cl/t), data = df, family = binomial())

## End(Not run)

[Package glmmrBase version 0.9.2 Index]