papaja (version 0.1.0.9842)

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

Description

These methods take glm and lm objects to create formatted character strings to report the results in accordance with APA manuscript guidelines.

Usage

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

apa_print.lm(x, est_name = NULL, standardized = FALSE, ci = 0.95, observed_predictors = TRUE, in_paren = FALSE, ...)

apa_print.summary.glm(x, ...)

apa_print.summary.lm(x, ...)

Arguments

x

glm or 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.

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 formatted string will be reported inside parentheses. See details.

...

Arguments passed on to printnum

x

Numeric. Can be either a single value, vector, or matrix.

standardized

Logical. Indicates if coefficients are standardized or unstandardized and leading zeros are omitted if appropriate. See details.

observed_predictors

Logical. Indicates whether predictor variables were observed. See details.

Value

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.

% , either in units of the analyzed scale or as standardized effect size.
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.

Details

The coefficients names are sanitized to facilitate their use as list names. Parentheses are omitted and other non-word characters are replaced by _ (see sanitize_terms).

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 then 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). Currently, this option is ignored for glm-objects.

If ci is a single value, confidence intervals are calculated using confint.

If x is an lm-objects and the MBESS package 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.

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

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

See Also

confint, ci.pvaf

Other apa_print: apa_print.BFBayesFactor, apa_print.aov, apa_print.emmGrid, apa_print.glht, apa_print.htest, apa_print.list, apa_print

Examples

Run this code
# 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 always better
ctl <- rep(ctl, 2)
lm_fit2 <- lm(scale(trt) ~ scale(ctl))

apa_print(lm_fit2, standardized = TRUE)


# Dobson (1990) Page 93: Randomized Controlled Trial :
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
d.AD <- data.frame(treatment, outcome, counts)
glm.D93 <- glm(counts ~ outcome + treatment, family = poisson())

apa_print(glm.D93)
# }

Run the code above in your browser using DataLab