umxAPA: Creates nicely formatted journal-style summaries of models,...

Description Usage Arguments Value References See Also Examples

View source: R/fit_and_reporting.R

Description

umxAPA creates summaries from a range of inputs. Use it for reporting lm models, effects, and summarizing data.

  1. Given an lm, umxAPA will return a formatted effect, including 95% CI in square brackets, for one of the effects (specified by name in se). e.g.: umxAPA(lm(mpg~wt, data=mtcars), "wt") yields: β = -5.344 [-6.486, -4.203], p< 0.001

  2. This also works for t.test(), stats::glm(), cor.test(), and others as I come across them.

  3. get a CI from obj=beta and se=se : umxAPA(-0.30, .03) # \eqn{\beta} = -0.3 [-0.36, -0.24]

  4. Back out an SE from b and CI: umxAPA(-0.030, c(-0.073, 0.013)) # \eqn{\beta} = -0.03, se =0.02

  5. Given only a number as obj, will be treated as a p-value as returned in APA format.

  6. Given a dataframe, umxAPA will return a table of correlations, with the mean and SD of each variable as the last row. So, umxAPA(mtcars[,c("cyl", "wt", "mpg", )] yields a table of correlations, means and SDs thus:

    cyl wt mpg
    cyl 1 0.78 -0.85
    wt 0.78 1 -0.87
    mpg -0.85 -0.87 1
    mean_sd 6.19 (1.79) 3.22 (0.98) 20.09 (6.03)

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
umxAPA(
  obj = .Last.value,
  se = NULL,
  p = NULL,
  std = FALSE,
  digits = 2,
  use = "complete",
  min = 0.001,
  addComparison = NA,
  report = c("markdown", "html"),
  lower = TRUE,
  test = c("Chisq", "LRT", "Rao", "F", "Cp"),
  SEs = TRUE,
  means = TRUE
)

Arguments

obj

A model (e.g. lm(), lme(), glm(), t.test()), beta-value, or data.frame

se

If obj is a beta, se treated as standard-error (returning a CI). If obj is a model, used to select effect of interest (blank for all effects). Finally, set se to the CI c(lower, upper), to back out the SE.

p

If obj is a beta, use p-value to compute SE (returning a CI).

std

Whether to report std betas (re-runs model on standardized data).

digits

How many digits to round output.

use

If obj is a data.frame, how to handle NAs (default = "complete")

min

For a p-value, the smallest value to report numerically (default .001)

addComparison

For a p-value, whether to add "</=" default (NA) adds "<" if necessary

report

What to return (default = 'markdown'). Use 'html' to open a web table.

lower

Whether to not show the lower triangle of correlations for a data.frame (Default TRUE)

test

If obj is a glm, which test to use to generate p-values options = "Chisq", "LRT", "Rao", "F", "Cp"

SEs

Whether or not to show correlations with their SE (Default TRUE)

means

Whether or not to show means in a correlation table (Default TRUE)

Value

References

See Also

Other Reporting Functions: loadings.MxModel(), umxFactorScores(), umxGetParameters(), umxParameters(), umxReduce(), umx_aggregate(), umx_names(), umx_time(), umx

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# ========================================
# = Report lm (regression/anova) results =
# ========================================
umxAPA(lm(mpg ~ wt + disp, mtcars)) # All parameters
umxAPA(lm(mpg ~ wt + disp, mtcars), "disp") # Just disp effect
umxAPA(lm(mpg ~ wt + disp, mtcars), std = TRUE) # Standardize effects

# glm example
df = mtcars
df$mpg_thresh = 0
df$mpg_thresh[df$mpg>16] = 1
m1 = glm(mpg_thresh ~ wt + gear,data = df, family = binomial)
umxAPA(m1)

# A t-Test
m1 = t.test(1:10, y = c(7:20))
umxAPA(m1)

# ========================================================
# = Summarize a DATA FRAME: Correlations + Means and SDs =
# ========================================================
umxAPA(mtcars[,1:3])
umxAPA(mtcars[,1:3], digits = 3)
umxAPA(mtcars[,1:3], lower = FALSE)
## Not run: 
umxAPA(mtcars[,1:3], report = "html")

## End(Not run)

# ===============================================
# = CONFIDENCE INTERVAL text from effect and se =
# ===============================================
umxAPA(.4, .3) # parameter 2 interpreted as SE

# Input beta and CI, and back out the SE
umxAPA(-0.030, c(-0.073, 0.013), digits = 3)

# ====================
# = Format a p-value =
# ====================
umxAPA(.0182613)
umxAPA(.000182613)
umxAPA(.000182613,  addComparison=FALSE)

# ========================
# = Report a correlation =
# ========================
data(twinData)
tmp = subset(twinData, zygosity %in% c("MZFF", "MZMM"))
m1 = cor.test(~ wt1 + wt2, data = tmp)
umxAPA(m1)

# ===================
# = Report a t-test =
# ===================
m1 = t.test(extra ~ group, data = sleep)
umxAPA(m1)

tbates/umx documentation built on March 30, 2020, 7:56 a.m.