format model parameters in APA style
Source:R/tables.R, R/anova.R, R/betareg.R, and 11 more
apa_parameters.Rdformat model parameters in APA style
Usage
apa_parameters(
fit,
predictor_parameters = c("Coefficient", "SE", "Std_Coefficient", "t", "df_error", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
...
)
# S3 method for class 'glm'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "Exp_Coefficient", "t", "z",
"df_error", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
exponentiate = NULL,
...
)
# S3 method for class 'aov'
apa_parameters(
fit,
predictor_parameters = NULL,
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
...
)
# S3 method for class 'aovlist'
apa_parameters(
fit,
predictor_parameters = NULL,
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
...
)
# S3 method for class 'afex_aov'
apa_parameters(
fit,
predictor_parameters = NULL,
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
...
)
# S3 method for class 'betareg'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "Exp_Coefficient", "z", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
exponentiate = NULL,
component_headings = TRUE,
...
)
# S3 method for class 'clmm'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "Exp_Coefficient", "z", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
exponentiate = NULL,
thresholds = TRUE,
random = TRUE,
effect_headings = TRUE,
random_scale = c("sd", "variance"),
...
)
# S3 method for class 'gam'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "Exp_Coefficient", "t", "z",
"df_error", "edf", "F", "Chi2", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
exponentiate = NULL,
terms = c("all", "parametric", "smooth"),
...
)
# S3 method for class 'bam'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "Exp_Coefficient", "t", "z",
"df_error", "edf", "F", "Chi2", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
exponentiate = NULL,
terms = c("all", "parametric", "smooth"),
...
)
# S3 method for class 'geeglm'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "Exp_Coefficient", "z", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
exponentiate = NULL,
ci = 0.95,
correlation_rows = NULL,
...
)
# S3 method for class 'lavaan'
apa_parameters(
fit,
predictor_parameters = NULL,
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
standardize = TRUE,
variances = FALSE,
intercepts = FALSE,
thresholds = FALSE,
ci = 0.95,
groups = c("columns", "rows"),
...
)
# S3 method for class 'rma'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "CI", "Exp_Coefficient",
"z", "t", "df_error", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
studies = NULL,
weights = TRUE,
transform = TRUE,
...
)
# S3 method for class 'mlm'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "Std_Coefficient", "t",
"df_error", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
outcomes = c("rows", "columns"),
...
)
# S3 method for class 'multinom'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "Exp_Coefficient", "z", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
exponentiate = TRUE,
category_headings = TRUE,
...
)
# S3 method for class 'zeroinfl'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "Exp_Coefficient", "z", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
exponentiate = TRUE,
component_headings = TRUE,
...
)
# S3 method for class 'hurdle'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "Exp_Coefficient", "z", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
exponentiate = TRUE,
component_headings = TRUE,
...
)
# S3 method for class 'rq'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "t", "df_error", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
se = c("nid", "iid", "ker", "boot"),
ci = 0.95,
...
)
# S3 method for class 'rqs'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "t", "df_error", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
se = c("nid", "iid", "ker", "boot"),
ci = 0.95,
quantiles = c("columns", "rows"),
...
)
# S3 method for class 'rlm'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "t", "df_error", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
...
)
# S3 method for class 'lmrob'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "t", "df_error", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
...
)
# S3 method for class 'coxph'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "Exp_Coefficient", "z", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
exponentiate = TRUE,
...
)
# S3 method for class 'survreg'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "Exp_Coefficient", "z", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
exponentiate = NULL,
...
)
# S3 method for class 'lm'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "Std_Coefficient", "t",
"df_error", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
...
)
# S3 method for class 'polr'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "Exp_Coefficient", "z", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
exponentiate = NULL,
thresholds = TRUE,
...
)
# S3 method for class 'clm'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "Exp_Coefficient", "z", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
exponentiate = NULL,
thresholds = TRUE,
...
)
# S3 method for class 'merMod'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "Exp_Coefficient", "t", "z",
"df_error", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
exponentiate = NULL,
random = TRUE,
effect_headings = TRUE,
random_scale = c("sd", "variance"),
...
)
# S3 method for class 'glmmTMB'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "Exp_Coefficient", "t", "z",
"df_error", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
exponentiate = NULL,
random = TRUE,
effect_headings = TRUE,
random_scale = c("sd", "variance"),
...
)
# S3 method for class 'lme'
apa_parameters(
fit,
predictor_parameters = c("Parameter", "Coefficient", "SE", "t", "df_error", "p"),
starred = NA,
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
random = TRUE,
effect_headings = TRUE,
random_scale = c("sd", "variance"),
...
)
# S3 method for class 'list'
apa_parameters(
fit,
predictor_parameters = NULL,
starred = "deltaR2",
bolded = NA,
column_formats = NULL,
t_with_df = TRUE,
performance_parameters = c("R2", "deltaR2"),
performance_layout = c("rows", "columns"),
...
)Arguments
- fit
a fitted model:
lm,glm(includingMASS::glm.nb),aov,aovlist,afex_aov, ordinal (MASS::polr,ordinal::clm), mixed (lme4::lmer,lme4::glmer,glmmTMB::glmmTMB,nlme::lme), generalized additive (mgcv::gam,mgcv::bam), structural equation (lavaan), meta-analysis (metafor::rma), multinomial (nnet::multinom), zero-inflated and hurdle (pscl::zeroinfl,pscl::hurdle), beta (betareg::betareg), quantile (quantreg::rq), robust (MASS::rlm,robustbase::lmrob), survival (survival::coxph,survival::survreg), ordinal mixed (ordinal::clmm), generalized estimating equations (geepack::geeglm), or multivariate linear (lm(cbind(y1, y2) ~ x)) models, or a named list of models of the same kind (seeperformance_parameters)- predictor_parameters
columns to display, in order, named as in
parameters::model_parameters():"Parameter","Coefficient","SE","Std_Coefficient"(standardized coefficient, \(\beta\)),"CI","t","z","df_error","p", and, for models with a log or logit link,"Exp_Coefficient"and"Exp_CI". If named vector, column names will be vector names. Columns not present in the model output (e.g.,tfor a model tested with z) are silently dropped. For lists of models,NULL(default) uses the default for each model's class. Add"CI"to show confidence intervals as [LL, UL] (headed, e.g., "95% CI"), and, forglm,polr, andclmmodels,"Exp_CI"to show confidence intervals of exponentiated coefficients (headed, e.g., "95% CI for OR"). Confidence intervals are not shown by default.- starred
columns to which significance stars are added (e.g.,
"Coefficient"or"p").NULLorNAfor none.- bolded
columns whose values are bolded when p \(\le\) .05 (e.g.,
"Coefficient").NULLorNA(default) for none.- column_formats
column_formats()object to format columns. IfNULL(default), the column formats set withapa7_defaults().- t_with_df
if
TRUE(default), the t column header includes the degrees of freedom (e.g., t(29)), and the df column is dropped, when all rows have the same df. IfFALSE, t and df are separate columns.- ...
arguments passed to methods. For
lm,glm,polr, andclmmodels, further arguments are passed toparameters::model_parameters(). For example,vcov = "HC3"gives heteroskedasticity-consistent (robust) standard errors, and the test statistics, p-values, and confidence intervals are based on them.ci = .90sets the confidence level.- exponentiate
if
NULL(default), exponentiated coefficients are added when the model's link function is logit or log (i.e., odds ratios, risk ratios, or incidence rate ratios); for beta regression models, only for a logit link of the mean; for parametric survival models (survival::survreg), when the distribution models log time (time ratios). Cox models (survival::coxph) default toTRUE(hazard ratios). IfTRUE, exponentiated coefficients are always added. IfFALSE, they are never added.- component_headings
for models with two components, if
TRUE(default), each component is introduced by a heading row, with its coefficients indented below it. IfFALSE, there are no heading rows, and the second component's coefficients are labeled instead: "Precision: " for the precision model of beta regression models (betareg::betareg), and "Zero-inflation: " or "Zero hurdle: " for the zero model of zero-inflated and hurdle models (pscl::zeroinfl,pscl::hurdle).- thresholds
for ordinal models, if
TRUE(default), threshold (cutpoint) rows are displayed below the predictors. Forlavaanmodels, ifTRUE, a section for the thresholds of ordinal indicators is added (FALSEby default).- random
for mixed models, if
TRUE(default), random-effect standard deviations and correlations (and the residual standard deviation, for linear mixed models) are displayed below the fixed effects.- effect_headings
for mixed models, if
TRUE(default), the fixed and random effects are introduced by heading rows ("Fixed effects" and "Random effects"), with the effects indented below them. Headings are added only when random effects are displayed. The random-effects heading names the statistic of the SD (or variance) rows (e.g., "Random effects (SD)"), and each cluster (grouping factor) gets a subheading with its terms indented below it; correlation (or covariance) rows name their own statistic (e.g., "r (Constant, Days)"). Without headings, each random-effect label names its cluster and statistic (e.g., "Subject: SD (Days)").- random_scale
for mixed models,
"sd"(default) displays random effects as standard deviations (SD) and correlations (r), and"variance"displays them as variances (Var) and covariances (Cov).- terms
for generalized additive models (
mgcv::gam), which terms to show:"all"(default) for the parametric terms and the smooth terms under their own headings,"parametric", or"smooth"- ci
for quantile regression (
quantreg::rq),lavaan, and generalized estimating equation (geepack::geeglm) models, the confidence level of the intervals shown whenpredictor_parametersincludes"CI"(default .95). For other models, passciin...toparameters::model_parameters().- correlation_rows
for generalized estimating equations (
geepack::geeglm), whether the estimated parameters of the working correlation are shown below the coefficients. IfNULL(default), they are shown when there is a single parameter (\(\alpha\) of exchangeable and AR(1) structures), and not for unstructured correlations, which have one for each pair of occasions.- standardize
for
lavaanmodels, ifTRUE(default), fully standardized estimates (\(\beta\)) are displayed with their standard errors and p-values. IfFALSE, unstandardized estimates (B) are displayed.- variances, intercepts
for
lavaanmodels, ifTRUE, sections for (residual) variances or intercepts are added. Both areFALSEby default. (Thevarianceargument ofapa_loadings()is different: it adds rows for the variance explained by each factor.)- groups
for multiple-group
lavaanmodels,"columns"(default) shows the groups side by side, each under a column spanner, and"rows"stacks them, each under a heading row.- studies
for meta-analyses (
metafor::rma()), ifTRUE, the table has a row for each study (its effect size, confidence interval, and weight) followed by the pooled estimate. IfFALSE, the table has the model's coefficients (the pooled estimate, or the intercept and moderators of a meta-regression). IfNULL(default),TRUEfor models without moderators andFALSEfor meta-regressions.- weights
for the study rows of meta-analyses, if
TRUE(default), each study's percentage of the total weight is shown- transform
for meta-analyses, if
TRUE(default), effect sizes computed on a transformed scale are shown on their original scale: log risk ratios, odds ratios, incidence rate ratios, and ratios of means are exponentiated, and Fisher's z-transformed correlations are converted back to correlations. In meta-regressions, exponentiated coefficients are added in a separate column. IfFALSE, estimates stay on the scale on which they were analyzed.- outcomes
for multivariate linear models (
lm(cbind(y1, y2) ~ x)), where each outcome's coefficients go:"rows"(default), under a heading row for each outcome, or"columns", side by side under a column spanner for each outcome.- category_headings
for multinomial models, if
TRUE(default), the coefficients of each outcome category are introduced by a heading row that names the comparison (e.g., "Part time vs. Not working"), with the predictors indented below it. IfFALSE, each row is labeled with its category and predictor (e.g., "Part time: Children").- se
for quantile regression models, the method of computing standard errors, passed to
quantreg::summary.rq():"nid"(default) for Hendricks-Koenker sandwich estimates, which allow the errors to differ across cases,"iid"for estimates that assume independent and identically distributed errors,"ker"for Powell kernel estimates, or"boot"for bootstrap estimates. (quantreg's own default for fewer than 1,000 cases,"rank", gives confidence intervals without standard errors.)- quantiles
for quantile regression models with several quantiles (
quantreg::rq(tau = c(.25, .5, .75))),"columns"(default) to show each quantile's estimates side by side under a column spanner (e.g., "\(\tau\) = .25"), or"rows"to stack them under heading rows- performance_parameters
for lists of models, model comparison metrics passed to
apa_performance_comparison(). IfNULL, no metrics are added. By default, they depend on the kind of model and the layout (see Details): in rows (performance_layout = "rows"), each model's fit, its change, the test of the change (with its degrees of freedom in the label and its stars), and an information criterion; in columns,R2anddeltaR2(and, for mixed models,R2_conditionalanddeltaR2_conditional, withR2the marginal R^2^), except for models without a valid R^2^ or nested tests:R2,deltaR2, andAICfor GAMs,R1andAICfor quantile regressions,Sigma_robustforrlm, andQICfor generalized estimating equations.- performance_layout
for lists of models, where the model comparison metrics go:
"rows"(default) adds a row for each metric below the model's parameters (and random effects), labeled in the variable column (e.g., R^2^ and \(\Delta R^2\)) with its value in the first value column, as in many hierarchical regression tables, and metrics without a value (e.g., the change in R^2^ of the first model) are left out;"columns"(the default before apa7 0.3.0) adds a column for each metric, with its value on the model's heading row.
Details
For lists of models in rows (the default layout), each model's statistics follow its parameters, and the first model is tested against a model with only a constant (and the random effects of mixed models). The test row is starred, and the note defines it. The defaults by kind of model are:
| Models | Fit | Test of the change | Also |
lm; glm with an estimated dispersion | R^2^ and \(\Delta R^2\) | F | |
glm with a fixed dispersion (e.g., binomial, Poisson) | pseudo-R^2^ | likelihood ratio \(\chi^2\) | AIC |
polr, clm, multinom, betareg | pseudo-R^2^ | likelihood ratio \(\chi^2\) | AIC |
zeroinfl, hurdle | likelihood ratio \(\chi^2\) | AIC | |
Mixed models (lme4, glmmTMB, nlme, clmm) | marginal and conditional R^2^ | likelihood ratio \(\chi^2\) | AIC |
coxph, survreg | Nagelkerke's R^2^ and C | likelihood ratio \(\chi^2\) | AIC |
lmrob | robust R^2^ and its change | robust Wald \(\chi^2\) | |
rlm | robust residual scale | none | |
rq | R^1^ | none | AIC |
GEE (geeglm) | QIC | Wald \(\chi^2\) of the added terms | |
GAMs (mgcv) | R^2^ and \(\Delta R^2\) | none | AIC |
Lists of different kinds of models get R^2^ and \(\Delta R^2\). Give
performance_parameters to choose the statistics yourself.
For glm objects (including MASS::glm.nb), the test statistic is z for families with a fixed dispersion parameter (binomial, Poisson, negative binomial) and t for families with an estimated dispersion parameter (Gaussian, Gamma, inverse Gaussian, quasi families). Whichever statistic applies is displayed. The exponentiated coefficient column (Exp_Coefficient) is labeled OR for logit links, IRR for log links in count models (Poisson, quasi-Poisson, negative binomial), RR for log links in binomial models, and Exp(B) otherwise.
For aov models (including repeated-measures models with an Error() term) and afex models, apa_parameters() returns the ANOVA table from apa_anova(). predictor_parameters and t_with_df are ignored, and other arguments in ... (e.g., effect_size, type) are passed to apa_anova(). To display regression coefficients instead, refit the model with stats::lm().
For beta regression models (betareg::betareg), which model outcomes
between 0 and 1 (e.g., proportions), the mean model and the precision
model (\(\phi\)) are each introduced by a heading row ("Mean model"
and "Precision model"). Coefficients are tested with Wald z tests. With
a logit link for the mean (the default), mean coefficients are log odds of
the mean proportion, and their exponentiated values (shown by default) are
odds ratios, labeled OR. Precision coefficients are not exponentiated.
Higher precision means less variability around the mean. A constant
precision (a model without a | part, as in y ~ x) is shown as one
\(\phi\) row with its estimate and standard error, without a test.
apa_note() names the links and gives the number of cases.
For ordinal mixed models (cumulative link mixed models fit with
ordinal::clmm()), the predictors and thresholds are displayed as for
ordinal::clm() models: Wald z tests, cumulative odds ratios (OR) for
logit links, and thresholds (cutpoints) below the predictors, without
tests. The random effects are displayed as for lme4 models, under a
"Random effects" heading (see random, effect_headings, and
random_scale). Models fit with the older ordinal::clmm2() are not
supported.
For generalized additive models fit with mgcv::gam() or mgcv::bam(),
the table has the parametric terms (coefficients, standard errors, and
their t or z tests) and the smooth terms (effective degrees of freedom
and their approximate F or \(\chi^2\) tests), as reported
by summary(), under the headings "Parametric terms" and "Smooth terms".
Smooth terms are labeled by their type and variables (e.g., "s(Age)" or
"te(Longitude, Latitude)"), and smooths of a factor-by variable are labeled
by level (e.g., "s(Age): Group = Treatment"). Coefficients of log and logit
links are exponentiated by default, as for stats::glm() models.
apa_note() names the method used to estimate the smoothing parameters.
For generalized estimating equations fit with geepack::geeglm(),
coefficients are shown as for glm models, with exponentiated
coefficients for logit and log links, and tested with Wald z tests
(z^2^ is geepack's Wald statistic). Standard errors are geepack's
robust (sandwich) estimates, or its jackknife estimates if the model was
fit with them (std.err). The estimated parameters of the working
correlation are shown below the coefficients, with their standard errors
but no tests (correlation_rows; when they are not shown, a single
\(\alpha\) is given in the note). apa_note() names the link, the
working correlation, the kind of standard errors, and the numbers of
observations and clusters. Lists of models are compared with Wald tests
of the terms added to the previous model (from geepack's anova()) and
by QIC, because GEE models have no likelihood.
For structural equation models and confirmatory factor analyses fit with lavaan, estimates come from lavaan::standardizedSolution() (standardize = TRUE, default) or lavaan::parameterEstimates() (standardize = FALSE). Each kind of parameter is introduced by a heading row: "Factor loadings" (e.g., Visual \(\rightarrow\) x1), "Regressions" (e.g., Speed \(\leftarrow\) Visual), "Correlations" (or "Covariances", if unstandardized; e.g., Visual \(\leftrightarrow\) Textual), and "Defined parameters" (e.g., indirect effects defined with :=), followed, if requested, by variances, intercepts, and thresholds. The default columns are the estimate, its standard error, and its p-value; "z", "CI", and (with standardize = TRUE) "Coefficient" for unstandardized estimates can be added to predictor_parameters. Unstandardized parameters fixed to set the scale of a factor (e.g., marker loadings fixed at 1) are not tested. Variable names are shown as written in the model, with the first letter capitalized and underscores replaced by spaces.
For multiple-group models (e.g., group = "school"), the groups are shown side by side by default, with one row for each parameter and a column spanner for each group, so that the groups can be compared row by row. With groups = "rows", each group has a heading row, with the kinds of parameters indented below it. A defined parameter that uses the labels of one group is shown with that group. One that combines groups (e.g., the difference between two groups' paths) is shown in the first group's columns, or under an "Across groups" heading. apa_note() gives the size of each group and names the parameters constrained to be equal across groups (group.equal), and any exceptions (group.partial). Standardized estimates of equal parameters can still differ across groups, because standardization uses each group's variances.
For meta-analyses fit with metafor::rma() (random-effects or
equal-effects models, without or with moderators), the table of a model
without moderators has a row for each study, labeled by the study labels
(slab), with its effect size, confidence interval, and percentage of the
total weight, followed by the pooled estimate under a rule. The column of
effect sizes is named by the measure given to metafor::escalc() (e.g.,
g for standardized mean differences, r for correlations, and OR for
odds ratios). apa_note() names the measure and the model (including the
estimator of \(\tau^2\)), and gives the test of the pooled
estimate, its prediction interval, and the test of heterogeneity. The
table of a meta-regression has the intercept and moderators, as for other
regression models. apa_performance() gives the heterogeneity statistics.
Multilevel meta-analyses fit with metafor::rma.mv() (e.g., several effect
sizes nested in studies, with random = ~ 1 | study / effect) get the
same tables, with a row for each effect size. apa_note() names the
levels and their numbers of units, and gives each level's variance
component (\(\sigma^2\)) and the multilevel \(I^2\)
(Cheung, 2014). Random effects with an ~ inner | outer structure (e.g.,
correlated outcomes within studies) are not yet supported.
For multivariate linear models, fit with stats::lm() and several outcomes
(lm(cbind(y1, y2) ~ x), class mlm), each outcome's coefficients are
shown as for an lm model, under a heading row for each outcome (or side
by side, with outcomes = "columns"). The coefficients and their tests
are those of a separate regression of each outcome on the same
predictors, so they do not take the correlations among the outcomes into
account. For multivariate tests of each predictor, use apa_anova().
Lists of multivariate models are not supported yet.
For multinomial logistic regression models (nnet::multinom), each outcome
category except the reference category (the first level of the response)
has its own block of coefficients, introduced by a heading row such as
"Part time vs. Not working". Coefficients are log odds of the category
relative to the reference category, tested with Wald z tests, and their
exponentiated values (shown by default) are odds ratios relative to the
reference category (sometimes called relative risk ratios), labeled OR.
To compare the categories with a different reference, relevel the response
(e.g., with stats::relevel()) before fitting the model. apa_note() names
the reference category.
For zero-inflated and hurdle count models fit with pscl::zeroinfl() and
pscl::hurdle(), the count model and the zero model are each introduced by
a heading row ("Count model" and "Zero-inflation model" or "Zero hurdle
model"); with component_headings = FALSE, the zero model's coefficients
are labeled "Zero-inflation: " or "Zero hurdle: " instead. Coefficients are tested with Wald z tests. Only the count model's
coefficients are exponentiated (by default), giving incidence rate ratios
(IRR), because the zero model has a different link and meaning. In a
zero-inflated model, the zero model predicts excess zeros (zeros not
produced by the count model); in a hurdle model, it predicts whether the
count is greater than zero. apa_note() says which, names the count
distribution, and gives the negative binomial dispersion parameter
(\(\theta\)).
For quantile regression models (quantreg::rq), coefficients are the
change in a quantile of the outcome (e.g., the median, with tau = .5)
per unit of the predictor, tested with t tests of the coefficient
divided by its standard error (see se). apa_note() names the quantile
and the kind of standard errors. Models with several quantiles show the
estimates of each quantile side by side (see quantiles).
For robust regression models (MASS::rlm and robustbase::lmrob),
coefficients are tested with t tests, as in linear regression, but
cases with large residuals get less weight. Standardized coefficients are
not shown by default, because standardizing with the ordinary standard
deviations does not match a robust fit. apa_note() names the estimator
and its weight function (e.g., MM-estimation with bisquare weights), says
how the standard errors were computed, and gives N and the number of
cases whose weights are below .10, which have almost no influence on the
estimates. For rlm, the p-values are computed by the parameters
package, because MASS gives none.
For Cox proportional hazards models (survival::coxph), coefficients are
log hazard ratios, tested with Wald z tests, and their exponentiated
values (shown by default) are hazard ratios, labeled HR. A hazard ratio
above 1 means that the event happens sooner (at a higher rate) as the
predictor increases. The model has no intercept. apa_note() names the
model and gives the number of cases and of events.
For parametric survival models (survival::survreg), which are
accelerated failure time models for distributions of log time (e.g., the
default Weibull, exponential, log-normal, and log-logistic), coefficients
are changes in log survival time, tested with Wald z tests, and their
exponentiated values (shown by default) are time ratios, labeled TR. A
time ratio above 1 means that the event happens later as the predictor
increases, the opposite of a hazard ratio above 1. The constant and the
log of the scale parameter, Log(scale), are not exponentiated. The scale
is tested only for Weibull models, where a scale of 1 is the exponential
model. apa_note() names the distribution and gives the number of cases
and of events.
For ordinal regression models (MASS::polr and ordinal::clm), coefficients are tested with Wald z tests. (parameters reports t for polr, but the test is asymptotically normal, and clm reports z for the same model.) With a logit link, exponentiated coefficients are cumulative odds ratios, labeled OR. Threshold rows show only the estimate, its standard error, and its confidence interval, because their exponentiated values are not odds ratios, and testing whether a threshold equals 0 is not meaningful. Confidence intervals ("CI", "Exp_CI") are Wald z intervals, consistent with the z tests.
For mixed models fit with lme4 (lmer and glmer), fixed effects are displayed as for lm and glm models. For linear mixed models, t tests and confidence intervals use Kenward-Roger degrees of freedom by default (ci_method = "kenward", which requires the pbkrtest package); pass another ci_method (e.g., "satterthwaite", which requires lmerTest, or "wald") to change this. When the degrees of freedom differ across fixed effects, they are shown in a df column rather than in the t column header. Random-effect rows show only the estimated standard deviation (SD) or correlation (r), or with random_scale = "variance", the variance (Var) or covariance (Cov), grouped by cluster (grouping factor) under a subheading for each cluster, with nested clusters named, e.g., "Classroom in School". The fixed and random effects are introduced by heading rows (effect_headings = TRUE). The random-effects heading names the statistic of the SD or variance rows (e.g., "Random effects (SD)"), and correlation or covariance rows name their own (e.g., "r (Constant, Days)"). apa_note() defines the symbols.
For mixed models fit with glmmTMB::glmmTMB(), fixed effects are tested with z tests, and random effects are displayed as for lme4 models. Coefficients of log and logit links are exponentiated by default (e.g., IRR for Poisson and negative binomial models). When the model has a zero-inflation part (ziformula) or a dispersion part (dispformula), each part is introduced by a heading row ("Conditional model", "Zero-inflation model", or "Dispersion model"), and only the conditional model's coefficients are exponentiated. A dispersion parameter that is not modeled (i.e., without a dispformula) is not displayed.
For linear mixed models fit with nlme::lme(), fixed effects are tested with t tests whose degrees of freedom are computed by nlme from the grouping levels at which each effect varies, and random effects are displayed as for lme4 models. Parameters of residual correlation structures (correlation, e.g., nlme::corAR1()) and variance functions (weights, e.g., nlme::varIdent()) are displayed below the residual SD, and apa_note() names the structures.
References
Ferrari, S. L. P., & Cribari-Neto, F. (2004). Beta regression for modelling rates and proportions. Journal of Applied Statistics, 31(7), 799–815. doi:10.1080/0266476042000214501
Smithson, M., & Verkuilen, J. (2006). A better lemon squeezer? Maximum-likelihood regression with beta-distributed dependent variables. Psychological Methods, 11(1), 54–71. doi:10.1037/1082-989X.11.1.54
Halekoh, U., Højsgaard, S., & Yan, J. (2006). The R package geepack for generalized estimating equations. Journal of Statistical Software, 15(2). doi:10.18637/jss.v015.i02
Liang, K.-Y., & Zeger, S. L. (1986). Longitudinal data analysis using generalized linear models. Biometrika, 73(1), 13–22. doi:10.1093/biomet/73.1.13
Pan, W. (2001). Akaike's information criterion in generalized estimating equations. Biometrics, 57(1), 120–125. doi:10.1111/j.0006-341X.2001.00120.x
Cheung, M. W.-L. (2014). Modeling dependent effect sizes with three-level meta-analyses: A structural equation modeling approach. Psychological Methods, 19(2), 211–229. doi:10.1037/a0032968
DerSimonian, R., & Laird, N. (1986). Meta-analysis in clinical trials. Controlled Clinical Trials, 7(3), 177–188. doi:10.1016/0197-2456(86)90046-2
Knapp, G., & Hartung, J. (2003). Improved tests for a random effects meta-regression with a single covariate. Statistics in Medicine, 22(17), 2693–2710. doi:10.1002/sim.1482
Hendricks, W., & Koenker, R. (1992). Hierarchical spline models for conditional quantiles and the demand for electricity. Journal of the American Statistical Association, 87(417), 58–68. doi:10.1080/01621459.1992.10475175
Koenker, R., & Bassett, G. (1978). Regression quantiles. Econometrica, 46(1), 33–50. doi:10.2307/1913643
Koenker, R., & Machado, J. A. F. (1999). Goodness of fit and related inference processes for quantile regression. Journal of the American Statistical Association, 94(448), 1296–1310. doi:10.1080/01621459.1999.10473882
Huber, P. J. (1964). Robust estimation of a location parameter. The Annals of Mathematical Statistics, 35(1), 73–101. doi:10.1214/aoms/1177703732
Renaud, O., & Victoria-Feser, M.-P. (2010). A robust coefficient of determination for regression. Journal of Statistical Planning and Inference, 140(7), 1852–1862. doi:10.1016/j.jspi.2010.01.008
Yohai, V. J. (1987). High breakdown-point and high efficiency robust estimates for regression. The Annals of Statistics, 15(2), 642–656. doi:10.1214/aos/1176350366
Cox, D. R. (1972). Regression models and life-tables. Journal of the Royal Statistical Society: Series B (Methodological), 34(2), 187–202. doi:10.1111/j.2517-6161.1972.tb00899.x
Harrell, F. E., Califf, R. M., Pryor, D. B., Lee, K. L., & Rosati, R. A. (1982). Evaluating the yield of medical tests. JAMA, 247(18), 2543–2546. doi:10.1001/jama.1982.03320430047030
Wei, L. J. (1992). The accelerated failure time model: A useful alternative to the Cox regression model in survival analysis. Statistics in Medicine, 11(14–15), 1871–1879. doi:10.1002/sim.4780111409
Examples
lm(mpg ~ cyl + wt, data = mtcars) |>
apa_parameters() |>
apa_flextable()
Variable
B
SE
β
t(29)
p
Constant
39.69
1.71
.00
23.14
<.001
Cyl
−1.51
0.41
−.45
−3.64
.001
Wt
−3.19
0.76
−.52
−4.22
<.001
# Confidence intervals with robust (HC3) standard errors
# \donttest{
if (requireNamespace("sandwich", quietly = TRUE)) {
lm(mpg ~ cyl + wt, data = mtcars) |>
apa_parameters(
predictor_parameters = c("Parameter", "Coefficient", "SE", "CI", "t", "df_error", "p"),
vcov = "HC3"
) |>
apa_flextable()
}
Variable
B
SE
95% CI
t(29)
p
Constant
39.69
2.30
[34.97, 44.40]
17.22
<.001
Cyl
−1.51
0.39
[−2.30, −0.72]
−3.90
<.001
Wt
−3.19
0.78
[−4.78, −1.60]
−4.10
<.001
# }
# Hierarchical regression: a list of models, with R-squared and its
# change in rows below each model's parameters
models <- list(
`Model 1` = lm(mpg ~ cyl, data = mtcars),
`Model 2` = lm(mpg ~ cyl + wt, data = mtcars)
)
apa_parameters(models)
#> Model Variable *B* *SE* β *t* *df* *p*
#> 1 Model 1
#> 2 Constant 37.88 2.07 .00 18.27 30 <.001
#> 3 Cyl −2.88 0.32 −.85 −8.92 30 <.001
#> 4 *R*^2^ .73
#> 5 *F*(1, 30) 79.56^\\*\\*\\*^
#> 6 Model 2
#> 7 Constant 39.69 1.71 .00 23.14 29 <.001
#> 8 Cyl −1.51 0.41 −.45 −3.64 29 .001
#> 9 Wt −3.19 0.76 −.52 −4.22 29 <.001
#> 10 *R*^2^ .83
#> 11 Δ*R*^2^ .10
#> 12 *F*(1, 29) 17.77^\\*\\*\\*^
# The same statistics in columns
# \donttest{
apa_parameters(models, performance_layout = "columns")
#> Model Variable *B* *SE* β *t* *df* *p* *R*^2^ Δ*R*^2^
#> 1 Model 1 .73
#> 2 Constant 37.88 2.07 .00 18.27 30 <.001
#> 3 Cyl −2.88 0.32 −.85 −8.92 30 <.001
#> 4 Model 2 .83 .10^\\*\\*\\*^
#> 5 Constant 39.69 1.71 .00 23.14 29 <.001
#> 6 Cyl −1.51 0.41 −.45 −3.64 29 .001
#> 7 Wt −3.19 0.76 −.52 −4.22 29 <.001
# }
# Logistic regression, with odds ratios
glm(am ~ wt + hp, data = mtcars, family = binomial) |>
apa_parameters()
#> # A tibble: 3 × 6
#> Variable `*B*` `*SE*` `*OR*` `*z*` `*p*`
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Constant 18.87 7.44 1.56×10^8^ 2.53 .01
#> 2 Wt −8.08 3.07 3.09×10^−4^ −2.63 .008
#> 3 Hp 0.04 0.02 1.04 2.04 .04
# \donttest{
if (requireNamespace("betareg", quietly = TRUE)) {
data("ReadingSkills", package = "betareg")
d <- ReadingSkills
d$dyslexia <- factor(d$dyslexia, levels = c("no", "yes"))
# Reading accuracy, with the precision depending on dyslexia and IQ
betareg::betareg(accuracy ~ dyslexia * iq | dyslexia + iq, data = d) |>
apa_parameters()
}
#> # A tibble: 9 × 6
#> Variable `*B*` `*SE*` `*OR*` `*z*` `*p*`
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Mean model "" "" "" "" ""
#> 2 Constant " 1.86" "0.28" "6.46" " 6.61" "<.001"
#> 3 Dyslexia–Yes "−1.48" "0.29" "0.23" "−5.20" "<.001"
#> 4 Iq " 1.07" "0.26" "2.91" " 4.09" "<.001"
#> 5 Dyslexia–Yes × Iq "−1.16" "0.27" "0.31" "−4.38" "<.001"
#> 6 Precision model "" "" "" "" ""
#> 7 Constant " 1.56" "0.32" "" " 4.88" "<.001"
#> 8 Dyslexia–Yes " 3.49" "0.52" "" " 6.66" "<.001"
#> 9 Iq " 1.23" "0.27" "" " 4.60" "<.001"
# }
# \donttest{
if (requireNamespace("ordinal", quietly = TRUE)) {
# Bitterness ratings of wine, with judges as a random factor
data("wine", package = "ordinal")
ordinal::clmm(rating ~ temp + contact + (1 | judge), data = wine) |>
apa_parameters()
}
#> # A tibble: 10 × 6
#> Variable `*B*` `*SE*` `*OR*` `*z*` `*p*`
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Fixed effects "" "" "" "" ""
#> 2 Temp–Warm " 3.06" "0.60" "21.39" "5.14" "<.001"
#> 3 Contact–Yes " 1.83" "0.51" " 6.26" "3.58" "<.001"
#> 4 1|2 "−1.62" "0.68" "" "" ""
#> 5 2|3 " 1.51" "0.60" "" "" ""
#> 6 3|4 " 4.23" "0.81" "" "" ""
#> 7 4|5 " 6.09" "0.97" "" "" ""
#> 8 Random effects (*SD*) "" "" "" "" ""
#> 9 Judge "" "" "" "" ""
#> 10 Constant " 1.13" "" "" "" ""
# }
# \donttest{
if (requireNamespace("mgcv", quietly = TRUE)) {
mgcv::gam(mpg ~ am + s(hp, k = 5) + s(wt, k = 5), data = mtcars,
method = "REML") |>
apa_parameters()
}
#> # A tibble: 6 × 7
#> Variable `*B*` `*SE*` `*t*(25.43)` `*edf*` `*F*` `*p*`
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Parametric terms "" "" "" "" "" ""
#> 2 Constant "19.86" "0.69" "28.67" "" "" "<.001"
#> 3 Am " 0.57" "1.43" " 0.40" "" "" " .70 "
#> 4 Smooth terms "" "" "" "" "" ""
#> 5 s(Hp) "" "" "" "2.36" "5.46" " .006"
#> 6 s(Wt) "" "" "" "2.21" "5.83" " .005"
# }
# Generalized estimating equations
# \donttest{
if (requireNamespace("geepack", quietly = TRUE)) {
data(ohio, package = "geepack")
fit_gee <- geepack::geeglm(
resp ~ age + smoke,
id = id,
data = ohio,
family = binomial,
corstr = "exchangeable"
)
apa_parameters(fit_gee)
}
#> # A tibble: 4 × 6
#> Variable `*B*` `*SE*` `*OR*` `*z*` `*p*`
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Constant −1.88 0.11 "0.15" "−16.51" "<.001"
#> 2 Age −0.11 0.04 "0.89" " −2.59" " .01 "
#> 3 Smoke 0.27 0.18 "1.30" " 1.49" " .14 "
#> 4 Working correlation (*α*) 0.35 0.06 "" "" ""
# }
# \donttest{
if (requireNamespace("lavaan", quietly = TRUE)) {
model <- "visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9
speed ~ visual + textual"
lavaan::sem(model, data = lavaan::HolzingerSwineford1939) |>
apa_parameters()
# Multiple groups, side by side
lavaan::cfa(
"visual =~ x1 + x2 + x3",
data = lavaan::HolzingerSwineford1939,
group = "school",
group.equal = "loadings"
) |>
apa_parameters()
}
#> # A tibble: 4 × 7
#> Parameter `Pasteur_β` `Pasteur_*SE*` `Pasteur_*p*` `Grant-White_β`
#> <chr> <chr> <chr> <chr> <chr>
#> 1 Factor loa… "" "" "" ""
#> 2 Visual → … ".61" "0.07" "<.001" ".60"
#> 3 Visual → … ".48" "0.07" "<.001" ".52"
#> 4 Visual → … ".72" "0.08" "<.001" ".77"
#> # ℹ 2 more variables: `Grant-White_*SE*` <chr>, `Grant-White_*p*` <chr>
# }
# \donttest{
if (requireNamespace("metafor", quietly = TRUE) &&
requireNamespace("metadat", quietly = TRUE)) {
d_bcg <- metafor::escalc(
measure = "RR",
ai = tpos, bi = tneg, ci = cpos, di = cneg,
data = metadat::dat.bcg,
slab = paste(author, year)
)
fit_meta <- metafor::rma(yi, vi, data = d_bcg)
apa_parameters(fit_meta)
apa_performance(fit_meta)
# Meta-regression
metafor::rma(yi, vi, mods = ~ ablat, data = d_bcg) |>
apa_parameters()
}
#> # A tibble: 2 × 7
#> Variable `*B*` `*SE*` `95% CI` `*RR*` `*z*` `*p*`
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Constant 0.25 0.25 [−0.24, 0.74] 1.29 1.01 .31
#> 2 Ablat −0.03 0.01 [−0.04, −0.01] 0.97 −4.04 <.001
# }
# Multivariate regression: the coefficients of each outcome
fit_mlm <- lm(cbind(mpg, qsec) ~ wt + hp, data = mtcars)
apa_parameters(fit_mlm)
#> # A tibble: 8 × 6
#> Variable `*B*` `*SE*` `β` `*t*(29)` `*p*`
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Mpg "" "" "" "" ""
#> 2 Constant "37.23" "1.60" " .00" "23.28" "<.001"
#> 3 Wt "−3.88" "0.63" " −.63" "−6.13" "<.001"
#> 4 Hp "−0.03" "0.01" " −.36" "−3.52" " .002"
#> 5 Qsec "" "" "" "" ""
#> 6 Constant "18.83" "0.67" " .00" "28.02" "<.001"
#> 7 Wt " 0.94" "0.27" " .52" " 3.54" " .001"
#> 8 Hp "−0.03" "0.00" "−1.05" "−7.20" "<.001"
apa_parameters(fit_mlm, outcomes = "columns")
#> # A tibble: 3 × 11
#> Variable `Mpg_*B*` `Mpg_*SE*` `Mpg_β` `Mpg_*t*(29)` `Mpg_*p*` `Qsec_*B*`
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Constant 37.23 1.60 .00 23.28 <.001 18.83
#> 2 Wt −3.88 0.63 −.63 −6.13 <.001 0.94
#> 3 Hp −0.03 0.01 −.36 −3.52 .002 −0.03
#> # ℹ 4 more variables: `Qsec_*SE*` <chr>, `Qsec_β` <chr>,
#> # `Qsec_*t*(29)` <chr>, `Qsec_*p*` <chr>
# \donttest{
if (requireNamespace("nnet", quietly = TRUE) &&
requireNamespace("carData", quietly = TRUE)) {
d <- carData::Womenlf
d$partic <- relevel(d$partic, ref = "not.work")
nnet::multinom(partic ~ hincome + children, data = d, trace = FALSE) |>
apa_parameters()
}
#> # A tibble: 8 × 6
#> Variable `*B*` `*SE*` `*OR*` `*z*` `*p*`
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 fulltime vs. not.work "" "" "" "" ""
#> 2 Constant " 1.98" "0.48" "7.26" " 4.10" "<.001"
#> 3 Hincome "−0.10" "0.03" "0.91" "−3.46" "<.001"
#> 4 Children–Present "−2.56" "0.36" "0.08" "−7.06" "<.001"
#> 5 parttime vs. not.work "" "" "" "" ""
#> 6 Constant "−1.43" "0.59" "0.24" "−2.42" " .02 "
#> 7 Hincome " 0.01" "0.02" "1.01" " 0.29" " .77 "
#> 8 Children–Present " 0.02" "0.47" "1.02" " 0.05" " .96 "
# }
# \donttest{
if (requireNamespace("pscl", quietly = TRUE)) {
data("bioChemists", package = "pscl")
pscl::zeroinfl(art ~ fem + kid5 + ment | ment,
data = bioChemists, dist = "negbin") |>
apa_parameters()
}
#> # A tibble: 8 × 6
#> Variable `*B*` `*SE*` `*IRR*` `*z*` `*p*`
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Count model "" "" "" "" ""
#> 2 Constant " 0.49" "0.07" "1.64" " 6.92" "<.001"
#> 3 Fem–Women "−0.23" "0.07" "0.80" "−3.18" " .002"
#> 4 Kid 5 "−0.13" "0.05" "0.88" "−2.73" " .006"
#> 5 Ment " 0.02" "0.00" "1.02" " 7.04" "<.001"
#> 6 Zero-inflation model "" "" "" "" ""
#> 7 Constant "−0.79" "0.35" "" "−2.27" " .02 "
#> 8 Ment "−0.62" "0.25" "" "−2.49" " .01 "
# }
# \donttest{
if (requireNamespace("quantreg", quietly = TRUE) &&
requireNamespace("psych", quietly = TRUE)) {
d <- psych::sat.act
d$female <- as.integer(d$gender == 2)
# ACT scores at the 25th, 50th, and 75th percentiles
quantreg::rq(ACT ~ education + female, tau = c(.25, .5, .75), data = d) |>
suppressWarnings() |>
apa_parameters()
}
#> # A tibble: 3 × 13
#> Variable `*τ* = .25_*B*` `*τ* = .25_*SE*` `*τ* = .25_*t*(697)`
#> <chr> <chr> <chr> <chr>
#> 1 Constant 23.67 0.91 26.12
#> 2 Education 0.67 0.24 2.83
#> 3 Female −0.67 0.69 −0.97
#> # ℹ 9 more variables: `*τ* = .25_*p*` <chr>, `*τ* = .50_*B*` <chr>,
#> # `*τ* = .50_*SE*` <chr>, `*τ* = .50_*t*(697)` <chr>,
#> # `*τ* = .50_*p*` <chr>, `*τ* = .75_*B*` <chr>,
#> # `*τ* = .75_*SE*` <chr>, `*τ* = .75_*t*(697)` <chr>,
#> # `*τ* = .75_*p*` <chr>
# }
# \donttest{
if (requireNamespace("robustbase", quietly = TRUE) &&
requireNamespace("carData", quietly = TRUE)) {
# Reported weight by measured weight; one measured weight is a data
# entry error (weight and height swapped)
d <- carData::Davis
robustbase::lmrob(repwt ~ weight * sex, data = d) |>
apa_parameters()
}
#> # A tibble: 4 × 5
#> Variable `*B*` `*SE*` `*t*(179)` `*p*`
#> <chr> <chr> <chr> <chr> <chr>
#> 1 Constant 2.39 1.50 1.59 .11
#> 2 Weight 0.95 0.03 35.66 <.001
#> 3 Sex–M 3.03 2.13 1.43 .16
#> 4 Weight × Sex–M −0.02 0.03 −0.59 .56
# }
# \donttest{
if (requireNamespace("survival", quietly = TRUE) &&
requireNamespace("carData", quietly = TRUE)) {
# Time to rearrest after release from prison
survival::coxph(
survival::Surv(week, arrest) ~ fin + age + prio,
data = carData::Rossi
) |>
apa_parameters()
}
#> # A tibble: 3 × 6
#> Variable `*B*` `*SE*` `*HR*` `*z*` `*p*`
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Fin–Yes −0.35 0.19 0.71 −1.82 .07
#> 2 Age −0.07 0.02 0.94 −3.22 .001
#> 3 Prio 0.10 0.03 1.10 3.56 <.001
# }
# \donttest{
if (requireNamespace("MASS", quietly = TRUE) &&
requireNamespace("carData", quietly = TRUE)) {
MASS::polr(poverty ~ gender + age, data = carData::WVS, Hess = TRUE) |>
apa_parameters()
}
#> # A tibble: 4 × 6
#> Variable `*B*` `*SE*` `*OR*` `*z*` `*p*`
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Gender–Male 0.15 0.05 "1.17" "2.96" " .003"
#> 2 Age 0.01 0.00 "1.01" "8.59" "<.001"
#> 3 Too Little | About Right 0.68 0.08 "" "" ""
#> 4 About Right | Too Much 2.41 0.09 "" "" ""
# }
# \donttest{
if (requireNamespace("lme4", quietly = TRUE) &&
requireNamespace("pbkrtest", quietly = TRUE)) {
lme4::lmer(Reaction ~ Days + (Days | Subject), data = lme4::sleepstudy) |>
apa_parameters()
}
#> # A tibble: 9 × 5
#> Variable `*B*` `*SE*` `*t*(17)` `*p*`
#> <chr> <chr> <chr> <chr> <chr>
#> 1 Fixed effects "" "" "" ""
#> 2 Constant "251.41" "6.82" "36.84" "<.001"
#> 3 Days " 10.47" "1.55" " 6.77" "<.001"
#> 4 Random effects (*SD*) "" "" "" ""
#> 5 Subject "" "" "" ""
#> 6 Constant " 24.74" "" "" ""
#> 7 Days " 5.92" "" "" ""
#> 8 *r* (Constant, Days) " .07" "" "" ""
#> 9 Residual " 25.59" "" "" ""
# }
# \donttest{
if (requireNamespace("glmmTMB", quietly = TRUE)) {
data(Salamanders, package = "glmmTMB")
glmmTMB::glmmTMB(
count ~ mined + (1 | site),
ziformula = ~ mined,
family = poisson,
data = Salamanders
) |>
apa_parameters()
}
#> # A tibble: 11 × 6
#> Variable `*B*` `*SE*` `*IRR*` `*z*` `*p*`
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Conditional model "" "" "" "" ""
#> 2 Fixed effects "" "" "" "" ""
#> 3 Constant " 0.09" "0.23" "1.09" " 0.38" " .71 "
#> 4 Mined–No " 1.14" "0.25" "3.13" " 4.64" "<.001"
#> 5 Random effects (*SD*) "" "" "" "" ""
#> 6 Site "" "" "" "" ""
#> 7 Constant " 0.28" "" "" "" ""
#> 8 Zero-inflation model "" "" "" "" ""
#> 9 Fixed effects "" "" "" "" ""
#> 10 Constant " 1.14" "0.24" "" " 4.85" "<.001"
#> 11 Mined–No "−1.74" "0.26" "" "−6.63" "<.001"
# }
# \donttest{
if (requireNamespace("nlme", quietly = TRUE)) {
nlme::lme(
distance ~ age + Sex,
random = ~ 1 | Subject,
correlation = nlme::corAR1(),
data = nlme::Orthodont
) |>
apa_parameters()
}
#> # A tibble: 9 × 6
#> Variable `*B*` `*SE*` `*t*` `*df*` `*p*`
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Fixed effects "" "" "" "" ""
#> 2 Constant "17.72" "0.85" "20.85" "80" "<.001"
#> 3 Age " 0.66" "0.06" "10.40" "80" "<.001"
#> 4 Sex–Female "−2.33" "0.76" "−3.06" "25" " .005"
#> 5 Random effects (*SD*) "" "" "" "" ""
#> 6 Subject "" "" "" "" ""
#> 7 Constant " 1.79" "" "" "" ""
#> 8 Residual " 1.45" "" "" "" ""
#> 9 Residual autocorrelation (*φ*) " .06" "" "" "" ""
# }