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

context("apa.regression.glm")
library(apaformat)

x = testdata.apa.regression.glm
model = glm(Response ~ Attribute, data = x, family = binomial())

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

tab = apa.regression.glm(model)
exp = matrix(byrow = T, nrow = 2,
             c("0.45",  "$z$ = -1.708", "(p > .05)",
               "4.096", "$z$ = 2.976",  "(p < .01)"))
rownames(exp) = c("(Intercept)", "Attribute")
colnames(exp) = c("Odds Ratio", "z score", "p-value")
expect_identical(tab, exp)

ci = confint(model)
tab = apa.regression.glm(model, ci)
exp = matrix(byrow = T, nrow = 2,
             c("0.45",  "[0.16, 1.05]", "$z$ = -1.708", "(p > .05)",
               "4.096", "[1.81, 12.14]", "$z$ = 2.976",  "(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.