tests/testthat/test.apa.regression.glmerMod.r

context("apa.regression.glmerMod")
library(lme4)
library(apaformat)

x = testdata.apa.regression.glmerMod
model = glmer(Response ~ Attribute + (1|FocusGroup), data = x, family = binomial())

tab = apa.regression(model)
exp = matrix(byrow = T, nrow = 2,
             c("0.016", "$z$ = -0.635", "(p > .05)",
               "1.543", "$z$ = 2.947",  "(p < .01)"))
rownames(exp) = c("(Intercept)", "Attribute")
colnames(exp) = c("Odds Ratio", "z score", "p-value")
expect_identical(tab, exp)

tab = apa.regression.glmerMod(model)
exp = matrix(byrow = T, nrow = 2,
             c("0.016", "$z$ = -0.635", "(p > .05)",
               "1.543", "$z$ = 2.947",  "(p < .01)"))
rownames(exp) = c("(Intercept)", "Attribute")
colnames(exp) = c("Odds Ratio", "z score", "p-value")
expect_identical(tab, exp)

ci = confint(model, parm = "beta_", method="Wald")
tab = apa.regression.glmerMod(model, ci)
exp = matrix(byrow = T, nrow = 2,
             c("0.016", "[0, 5277.64]", "$z$ = -0.635", "(p > .05)",
               "1.543", "[1.16, 2.06]", "$z$ = 2.947",  "(p < .01)"))
rownames(exp) = c("(Intercept)", "Attribute")
colnames(exp) = c("Odds Ratio", "CI 95%", "z score", "p-value")
expect_identical(tab, exp)
markanewman/apaformat documentation built on May 10, 2019, 1:19 a.m.