Learn R Programming

papaja (version 0.1.0.9054)

apa_print.lm: Format statistics (APA 6th edition)

Description

Takes lm objects from various statistical methods to create formated chraracter strings to report the results in accordance with APA manuscript guidelines.

Usage

"apa_print"(x, est_name = NULL, standardized = FALSE, ci = 0.95, in_paren = FALSE, ...)
"apa_print"(x, est_name = NULL, standardized = FALSE, ci = 0.95, in_paren = FALSE, ...)

Arguments

x
lm object.
est_name
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.
standardized
Logical. Indicates if coefficients are standardized or unstandardized and leading zeros are omitted if appropriate. See details.
ci
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.
in_paren
Logical. Indicates if the formated string will be reported inside parentheses. See details.
...
Further arguments to pass to printnum to format the estimate.

Value

apa_print.lm returns a list containing the following components according to the input:

Details

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 formated 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.

Confidence intervals for $R^2$ are computed using ci.pvaf to obtain a confidence region that corresponds to the $\alpha$-level chosen for the confidence intervals of parameters (e.g., 95% CI or $\alpha = 0.05$ for parameters yields a 90% CI for $R^2$, see Steiger, 2004)

References

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

See Also

confint, ci.pvaf

Other apa_print: apa_print.Anova.mlm, apa_print.anova, apa_print.aov, apa_print.aovlist, apa_print.summary.aov, apa_print.summary.aovlist; apa_print.htest; apa_print

Examples

Run this code
# 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