apa_print.merMod: Typeset Statistical Results from Hierarchical GLM

View source: R/apa_print_merMod.R

apa_print.merModR Documentation

Typeset Statistical Results from Hierarchical GLM

Description

These methods take objects from various R functions that calculate hierarchical (generalized) linear models to create formatted character strings to report the results in accordance with APA manuscript guidelines.

Usage

## S3 method for class 'merMod'
apa_print(
  x,
  effects = "fixed",
  conf.int = 0.95,
  in_paren = FALSE,
  est_name = NULL,
  ...
)

## S3 method for class 'mixed'
apa_print(x, ...)

Arguments

x

A fitted hierarchical (generalized) linear model, either from lme4::lmer(), lmerTest::lmer(), afex::mixed(), or lme4::glmer().

effects

Character. Determines which information is returned. Currently, only fixed-effects terms ("fixed") are supported.

conf.int

Numeric specifying the required confidence level or a named list specifying additional arguments that are passed to lme4::confint.merMod(), see details.

in_paren

Logical. Whether the formatted string is to be reported in parentheses. If TRUE, parentheses in the formatted string (e.g., those enclosing degrees of freedom) are replaced with brackets.

est_name

An optional character. The label to be used for fixed-effects coefficients.

...

Further arguments that may be passed to apa_num to format estimates (i.e., columns estimate and conf.int).

Details

Confidence intervals are calculated by calling lme4::confint.merMod(). By default, Wald confidence intervals are calculated, but this may change in the future.

Value

apa_print()-methods return a named list of class apa_results containing the following elements:

estimate

One or more character strings giving point estimates, confidence intervals, and confidence level. A single string is returned in a vector; multiple strings are returned as a named list. If no estimate is available the element is NULL.

statistic

One or more character strings giving the test statistic, parameters (e.g., degrees of freedom), and p-value. A single string is returned in a vector; multiple strings are returned as a named list. If no estimate is available the element is NULL.

full_result

One or more character strings comprised 'estimate' and 'statistic'. A single string is returned in a vector; multiple strings are returned as a named list.

table

A data.frame of class apa_results_table that contains all elements of estimate and statistics. This table can be passed to apa_table() for reporting.

Column names in apa_results_table are standardized following the broom glossary (e.g., term, estimate conf.int, statistic, df, df.residual, p.value). Additionally, each column is labelled (e.g., $\hat{\eta}^2_G$ or $t$) using the tinylabels package and these labels are used as column names when an apa_results_table is passed to apa_table().

See Also

Other apa_print: apa_print(), apa_print.BFBayesFactor(), apa_print.aov(), apa_print.emmGrid(), apa_print.glht(), apa_print.htest(), apa_print.list(), apa_print.lm(), apa_print.lme()

Examples


  # Fit a linear mixed model using the lme4 package
  # or the lmerTest package (if dfs and p values are desired)
  library(lmerTest)
  fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
  # Format statistics for fixed-effects terms (the default)
  apa_print(fm1)



papaja documentation built on Oct. 30, 2024, 9:09 a.m.