Skip to contents

A small lme4::getME() vocabulary, for downstream code written against merMod objects. Registered on lme4's generic, so call it as lme4::getME(fit, "X") or load lme4 first.

Usage

# S3 method for class 'frmtmb_fit'
getME(object, name, resp = NULL, ...)

Arguments

object

A frmtmb_fit.

name

One or more names from the vocabulary above. A vector returns a named list.

resp

Response name, for the design extractors on a multivariate fit.

...

Refused: an argument the method does not have is an error naming it, rather than silently changing nothing.

Value

The requested component, or a named list when name names several.

Details

Supported names:

"X"

Fixed-effect design matrix of the mu predictor.

"Z", "Zt"

The sparse random-effect design of the mu predictor and its transpose. Columns (rows of Zt) span the whole random-effect coefficient vector, so a block belonging to another distributional parameter contributes zero columns here.

"beta", "fixef"

The primary (mu-family) fixed-effect coefficients, named. Coefficients of auxiliary distributional parameters are a separate vector; use fixef() for all of them.

"b"

Conditional modes in coefficient space, aligned with the columns of Z. Reduced-rank (rr()) blocks are expanded through their loadings, so this is not the internal parameter vector.

"theta"

Covariance parameters on the internal (unconstrained) scale, as in confint(). These are not lme4's relative-covariance-factor entries.

"lower"

Lower bounds on theta. The internal parameterization is unbounded, so this is a vector of -Inf, not lme4's mixture of 0 and -Inf. Code that tests theta == lower to detect a singular fit will never fire; use diagnose() or VarCorr() instead.

"sigma"

Residual standard deviation (sigma.frmtmb_fit()).

"flist"

The grouping factors, one per distinct grouping variable. Smooth and Gaussian-process blocks are excluded: their levels are basis functions, not groups. There is no "assign" attribute.

"n_rtrms", "n_rfacs"

Number of random-effect terms and of distinct grouping factors.

Multivariate fits have one design per response, so "X", "Z" and "Zt" need resp; the other names answer without it.

Examples

if (requireNamespace("lme4", quietly = TRUE)) {
  set.seed(1)
  dd <- data.frame(x = rnorm(100), g = factor(rep(1:10, 10)))
  dd$y <- rnorm(100, 1 + 0.5 * dd$x + rnorm(10, 0, 0.8)[dd$g], 1)
  fit <- frm(bf(y ~ x + (1 | g)) + gaussian(), data = dd)

  # the designs, for downstream code written against merMod objects
  dim(lme4::getME(fit, "X"))
  dim(lme4::getME(fit, "Zt"))

  # a vector of names returns a named list
  str(lme4::getME(fit, c("n_rtrms", "n_rfacs", "sigma")))

  # the conditional modes in coefficient space, aligned with Z
  head(lme4::getME(fit, "b"))
  # note: "lower" is all -Inf here, because the internal covariance
  # parameterization is unbounded. Use diagnose() to spot a singular
  # fit, not theta == lower.
  lme4::getME(fit, "lower")
}
#> List of 3
#>  $ n_rtrms: int 1
#>  $ n_rfacs: int 1
#>  $ sigma  : num 0.966
#> theta_1 
#>    -Inf