Using finalfit conventions, produces mixed effects linear regression models for a set of explanatory variables against a continuous dependent.

lmmixed(.data, dependent, explanatory, random_effect, ...)

Arguments

.data

Dataframe.

dependent

Character vector of length 1, name of depdendent variable (must be continuous vector).

explanatory

Character vector of any length: name(s) of explanatory variables.

random_effect

Character vector of length 1, either, (1) name of random intercept variable, e.g. "var1", (automatically convered to "(1 | var1)"); or, (2) the full lme4 specification, e.g. "(var1 | var2)". Note parenthesis MUST be included in (2)2 but NOT included in (1).

...

Other arguments to pass to lme4::lmer.

Value

A list of multivariable lme4::lmer fitted model outputs. Output is of class lmerMod.

Details

Uses lme4::lmer with finalfit modelling conventions. Output can be passed to fit2df. This is only currently set-up to take a single random effect as a random intercept. Can be updated in future to allow multiple random intercepts, random gradients and interactions on random effects if there is a need.

See also

Examples

library(finalfit) library(dplyr) explanatory = c("age.factor", "sex.factor", "obstruct.factor", "perfor.factor") random_effect = "hospital" dependent = "nodes" colon_s %>% lmmixed(dependent, explanatory, random_effect) %>% fit2df(estimate_suffix=" (multilevel")
#> P-value for lmer is estimate assuming t-distribution is normal. Bootstrap for final publication.
#> explanatory Coefficient (multilevel #> 1 age.factor40-59 years -0.79 (-1.65-0.07, p=0.035) #> 2 age.factor60+ years -0.98 (-1.81--0.14, p=0.011) #> 3 sex.factorMale -0.19 (-0.62-0.24, p=0.195) #> 4 obstruct.factorYes -0.37 (-0.92-0.17, p=0.091) #> 5 perfor.factorYes 0.23 (-1.01-1.48, p=0.357)