mixed_anova: ANOVA table from linear mixed effects analysis.

View source: R/mixed_anova.R

mixed_anovaR Documentation

ANOVA table from linear mixed effects analysis.

Description

One of four related functions for mixed effects analyses (based on lmer and as_lmerModLmerTest) to get a linear model for downstream steps, or an ANOVA table.

  1. mixed_model

  2. mixed_anova

  3. mixed_model_slopes

  4. mixed_anova_slopes.

Usage

mixed_anova(
  data,
  Y_value,
  Fixed_Factor,
  Random_Factor,
  Df_method = "Kenward-Roger",
  SS_method = "II",
  ...
)

Arguments

data

a data table object, e.g. data.frame or tibble.

Y_value

name of column containing quantitative (dependent) variable, provided within "quotes".

Fixed_Factor

name(s) of categorical fixed factors (independent variables) provided as a vector if more than one or within "quotes".

Random_Factor

name(s) of random factors to allow random intercepts; to be provided as a vector when more than one or within "quotes".

Df_method

method for calculating degrees of freedom. Default is Kenward-Roger, can be changed to "Satterthwaite".

SS_method

type of sum of square, default is type II, can be changed to "I", "III", "1" or "2", or others.

...

any additional arguments to pass on to lmer if required.

Details

These functions require a data table, one dependent variable (Y_value), one or more independent variables (Fixed_Factor), and at least one random factor (Random_Factor). These should match names of variables in the long-format data table exactly.

Outputs of mixed_model and mixed_model_slopes can be used for post-hoc comparisons with posthoc_Pairwise, posthoc_Levelwise, posthoc_vsRef, posthoc_Trends_Pairwise, posthoc_Trends_Levelwise and posthoc_Trends_vsRefor with emmeans.

More than one fixed factors can be provided as a vector (e.g. c("A", "B")). A full model with interaction term is fitted. This means when Y_value = Y, Fixed_factor = c("A", "B"), Random_factor = "R" are entered as arguments, these are passed on as Y ~ A*B + (1|R) (which is equivalent to Y ~ A + B + A:B + (1|R)).

In mixed_model_slopes and mixed_anova_slopes, the following kind of formula is used: Y ~ A*B + (S|R) (which is equivalent to Y ~ A + B + A:B + (S|R)). In this experimental implementation, random slopes and intercepts are fitted ((Slopes_Factor|Random_Factor)). Only one term each is allowed for Slopes_Factor and Random_Factor.

Value

ANOVA table of class "anova" and "data.frame".

Examples

#Usage with one fixed (Student) and random factor (Experiment)
mixed_anova(data = data_doubling_time, 
Y_value = "Doubling_time", 
Fixed_Factor = "Student", 
Random_Factor = "Experiment")

#two fixed factors provided as a vector
mixed_anova(data = data_cholesterol, 
Y_value = "Cholesterol", 
Fixed_Factor = c("Treatment", "Hospital"), 
Random_Factor = "Subject")


grafify documentation built on Oct. 7, 2023, 5:06 p.m.

Related to mixed_anova in grafify...