Learn Python and AI for free! One week only. No credit card needed.
Ends in:
umxAPA
creates APA-style reports from a range of statistical models, or to summarize data.
Given an stats::lm()
model, umxAPA
will return a formatted effect, including 95% CI.
e.g.: umxAPA(lm(mpg~wt, data=mtcars), "wt")
yields:
umxAPA
also supports t.test()
, stats::glm()
, cor.test()
, and others as I need them.
Get a CI from obj=beta
and se=se : umxAPA(-0.30, .03)
returns
Back out an SE from umxAPA(-0.030, c(-0.073, 0.013))
returns
Given only a number as obj, will be treated as a p-value, and returned in APA format.
Given a dataframe, umxAPA
will return a table of correlations with means and SDs in the last row. e.g.:
umxAPA(mtcars[,c("cyl", "wt", "mpg", )]
yields:
cyl | wt | mpg | |
cyl | 1 | 0.78 | -0.85 |
wt | 0.78 | 1 | -0.87 |
mpg | -0.85 | -0.87 | 1 |
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
)
A model (e.g. lm()
, lme()
, glm()
, t.test()
), beta-value, or data.frame
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.
If obj is a beta, use p-value to compute SE (returning a CI).
Whether to report std betas (re-runs model on standardized data).
How many digits to round output.
If obj is a data.frame, how to handle NAs (default = "complete")
For a p-value, the smallest value to report numerically (default .001)
For a p-value, whether to add "</=" default (NA) adds "<" if necessary
What to return (default = 'markdown'). Use 'html' to open a web table.
Whether to not show the lower triangle of correlations for a data.frame (Default TRUE)
If obj is a glm, which test to use to generate p-values options = "Chisq", "LRT", "Rao", "F", "Cp"
Whether or not to show correlations with their SE (Default TRUE)
Whether or not to show means in a correlation table (Default TRUE)
string
Other Reporting Functions:
umxFactorScores()
,
umxGetParameters()
,
umxParameters()
,
umx_aggregate()
,
umx_time()
,
umx
# NOT RUN {
# ========================================
# = Report lm (regression/anova) results =
# ========================================
umxAPA(lm(mpg ~ wt + disp, mtcars)) # Report all parameters
umxAPA(lm(mpg ~ wt + disp, mtcars), "wt") # Just effect of weight
umxAPA(lm(mpg ~ wt + disp, mtcars), std = TRUE) # Standardize model!
###############
# 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 #
###############
umxAPA(t.test(x = 1:10, y = c(7:20)))
umxAPA(t.test(extra ~ group, data = sleep))
# ======================================================
# = Summarize 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")
# }
# NOT RUN {
# ==========================================
# = CONFIDENCE INTERVAL 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) # 0.02
umxAPA(.00018261) # < 0.001
umxAPA(.00018261, addComparison = FALSE) # 0.001
# ========================
# = Report a correlation =
# ========================
data(twinData)
tmp = subset(twinData, zygosity %in% c("MZFF", "MZMM"))
m1 = cor.test(~ wt1 + wt2, data = tmp)
umxAPA(m1)
# }
Run the code above in your browser using DataLab