Learn R Programming

trouBBlme4SolveR (version 0.1.4)

fstruction: Formula removal of singular random effects

Description

Removes those random effects from a model formula making the model to be singular.

Usage

fstruction(model, tol = 1e-4)

Value

A list with a string component dstring which is the formula as character updated (to be used by update) after removing the singular random effects and, when no all the random effects are removed two other string components:

  • betchar: a character vector with the random effect terms removed from the formula.

  • inchar: a character vector having the same length as betchar with the corresponding groups (aggregate levels) for which the random effects are removed.

Arguments

model

The model of interest, output of either lmer or glmer, that is, an object of class merMod and subclass either lmerMod or glmerMod.

tol

A numeric value (default is 1e-4), tolerance under which to determine if the random effects make the model to be singular.

Author

Iago Giné-Vázquez, iago.gin-vaz@protonmail.com

See Also

Examples

Run this code
if(requireNamespace("nlme")){
	library(lme4)
	data(Orthodont, package = "nlme")
	Orthodont$nsex <- as.numeric(Orthodont$Sex == "Male")
	Orthodont$nsexage <- with(Orthodont, nsex*age)
	## The next model is singular
	fmo <- lmer(distance ~ age + (age|Subject) + (0+nsex|Subject) +
		    (0 + nsexage|Subject), data = Orthodont)
	summary(fmo)

	## Let's see the formula updated (as a string)
	fstruction(fmo)
}

Run the code above in your browser using DataLab