Learn R Programming

spaMM (version 4.0.0)

as_LMLT: Conversion to input for procedures from lmerTest package

Description

The lmerTest::contest function and ::anova method implement a number of tests for linear mixed models, e.g. using effective degrees of freeedom based on (a generalization of) Satterthwaite's method. These tests can be performed using spaMM fits through the conversion of the fit object, by the as_LMLT function. Only the tests using lmerTest's default method ddf="Satterthwaite" are formally supported, as the converted object do not have therequired format for the other methods. Only LMMs are handled by lmerTest, and residual-dispersion models are not yet handled by the conversion.

Usage

as_LMLT(fitobject, nuisance=NULL, verbose=TRUE, transf=TRUE, ...)

Value

The value is returned invisibly. It is an S4 object of class "LMLT" with slots matching those required in objects of S4 class "lmerModLmerTest" when used by package lmerTest with ddf="Satterthwaite" (many additional slots of a formal "lmerModLmerTest" object are missing). The additional nuisance slot contains the nuisance list.

Arguments

fitobject

Object of class HLfit resulting from the fit of a linear mixed model (LMM).

nuisance

A list of fitted values of parameters that affect the distribution of the test of fixed effects, in the format of the fixed argument of the fitme function. If NULL (default), then the list is constructed from the fitted values of the random-effect parameters and of phi (residual dispersion parameter). The nuisance argument is better ingored unless the extractor he construct the default value fails in some way.

verbose

boolean: controls printing of the message that shows the unlisted value of the nuisance list.

transf

boolean: whether to evaluate numerical derivatives on a transformed parameter scale, or not (may affect numerical precision).

...

Other arguments that may be needed by some method (currently ignored).

References

Alexandra Kuznetsova, Per B. Brockhoff and Rune H. B. Christensen (2017) lmerTest Package: Tests in Linear Mixed Effects Models. Journal of Statistical Software, 82(13), 1–26. doi:10.18637/jss.v082.i13

Examples

Run this code
## Reproducing an example from the doc of lmerTest::contest.lmerModLmerTest,
#    using a spaMM fit as input.
if (FALSE) {
  data("sleepstudy", package="lme4")
  
  ## The fit:
  spfit <- fitme(Reaction ~ Days + I(Days^2) + (1|Subject) + (0+Days|Subject),
             sleepstudy, method="REML")
  
  ## Conversion:           
  spfit_lmlt <-  as_LMLT(spfit) 

  ## Functions from package lmerTest can then be called on this object:
  lmerTest::contest(spfit_lmlt, L=diag(3)[2:3, ])   # Test of 'Days + I(Days^2)'.
  #
  anova(spfit_lmlt, type="1")         # : using lmerTest:::anova.lmerModLmerTest()

}

Run the code above in your browser using DataLab