Takes lm
objects from various statistical methods to create formatted chraracter
strings to report the results in accordance with APA manuscript guidelines.
# S3 method for lm
apa_print(x, est_name = NULL, standardized = FALSE,
ci = 0.95, observed_predictors = TRUE, in_paren = FALSE, ...)# S3 method for summary.lm
apa_print(x, ...)
lm
object.
Character. If NULL
(default) the name given in x
(or a formally correct
adaptation, such as "\(b^*\)" instead of "b" for standardized regression coefficients) is used,
otherwise the supplied name is used. See details.
Logical. Indicates if coefficients are standardized or unstandardized and leading zeros are omitted if appropriate. See details.
Numeric. Either a single value (range [0, 1]) giving the confidence level or a two-column
matrix
with confidence region bounds as column names (e.g. "2.5 %" and "97.5 %") and
coefficient names as row names (in the same order as they appear in summary(x)$coefficients
.
See details.
Logical. Indicates whether predictor variables were observed. See details.
Logical. Indicates if the formatted string will be reported inside parentheses. See details.
Further arguments to pass to printnum
to format the estimate.
apa_print.lm
returns a list containing the following components according to the input:
statistic
A named list of character strings giving the test statistic, parameters, and p value for each term.
estimate
A named list of character strings giving the descriptive estimates and confidence intervals for each term.
full_result
A named list of character strings comprised of estimate
and statistic
for each term.
table
A data.frame containing the complete regression table, which can be passed to apa_table
.
The coefficients names are sanitized to facilitate their use as list names (see Value section). Parentheses
are omitted and other non-word characters are replaced by _
.
If in_paren
is TRUE
parentheses in the formatted string, such as those surrounding degrees
of freedom, are replaced with brackets.
est_name
is placed in the output string and is thus passed to pandoc or LaTeX through kntir.
Thus, to the extent it is supported by the final document type, you can pass LaTeX-markup to format the final
text (e.g., \\beta
yields \(\beta\)).
If standardized
is TRUE
"scale()" is removed from coefficients names (see examples).
If ci
is a single value, confidence intervals are calculated using confint
.
If MBESS is available, confidence intervals for \(R^2\) are computed using ci.R2
to
obtain a confidence region that corresponds to the \(\alpha\)-level chosen for the confidence intervals of
regression coefficients (e.g., 95% CI or \(\alpha = 0.05\) for regression coefficients yields a 90% CI for
\(R^2\), see Steiger, 2004). If observed_predictors = FALSE
, it is assumed that predictors are fixed
variables, i.e., "the values of the [predictors] were selected a priori as part of the research design"
(p. 15, Kelly, 2007); put differently, it is assumed that predictors are not random.
Steiger (2004). Beyond the F Test: Effect Size Confidence Intervals and Tests of Close Fit in the Analysis of Variance and Contrast Analysis. Psychological Methods, 9(2), 164-182. doi:10.1037/1082-989X.9.2.164
Kelley, K. (2007). Confidence intervals for standardized effect sizes: Theory, application, and implementation. Journal of Statistical Software, 20(8), 1-24. doi:10.18637/jss.v020.i08
Other apa_print: apa_print.aov
,
apa_print.glht
,
apa_print.htest
,
apa_print.list
, apa_print
# NOT RUN {
# Data from Dobson (1990), p. 9.
ctl <- c(4.17, 5.58, 5.18, 6.11, 4.50, 4.61, 5.17, 4.53, 5.33, 5.14)
trt <- c(4.81, 4.17, 4.41, 3.59, 5.87, 3.83, 6.03, 4.89, 4.32, 4.69)
group <- gl(2, 10, 20, labels = c("Ctl", "Trt"))
weight <- c(ctl, trt)
lm_fit <- lm(weight ~ group)
apa_print(lm_fit)
trt <- rep(trt, 2) # More data is allways better
ctl <- rep(ctl, 2)
lm_fit2 <- lm(scale(trt) ~ scale(ctl))
apa_print(lm_fit2, standardized = TRUE)
# }
Run the code above in your browser using DataLab