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

context("test.apa.regression.lmerModLmerTest")
library(apaformat)
library(lmerTest)

x = testdata.apa.regression.lmerModLmerTest
model = lmer(Response ~ Treatment + (1|FocusGroup), data = x)

tab = apa.regression(model)
exp = matrix(byrow = T, nrow = 2,
             c("0.248", "$t$(38) = 1.423", "(r = 0.225)", "(p > .05)",
               "1.211", "$t$(38) = 4.908", "(r = 0.623)", "(p < .001)"))
rownames(exp) = c("(Intercept)", "Treatment2")
colnames(exp) = c("Fixed Effects", "t-test", "r", "p-value")
expect_identical(tab, exp)

tab = apa.regression.lmerModLmerTest(model)
exp = matrix(byrow = T, nrow = 2,
             c("0.248", "$t$(38) = 1.423", "(r = 0.225)", "(p > .05)",
               "1.211", "$t$(38) = 4.908", "(r = 0.623)", "(p < .001)"))
rownames(exp) = c("(Intercept)", "Treatment2")
colnames(exp) = c("Fixed Effects", "t-test", "r", "p-value")
expect_identical(tab, exp)

ci = confint(model, parm = "beta_")
tab = apa.regression.lmerModLmerTest(model, ci)
exp = matrix(byrow = T, nrow = 2,
             c("0.248", "[-0.09, 0.59]", "$t$(38) = 1.423", "(r = 0.225)", "(p > .05)",
               "1.211", "[0.73, 1.69]",  "$t$(38) = 4.908", "(r = 0.623)", "(p < .001)"))
rownames(exp) = c("(Intercept)", "Treatment2")
colnames(exp) = c("Fixed Effects", "CI 95%", "t-test", "r", "p-value")
expect_identical(tab, exp)
markanewman/apaformat documentation built on May 10, 2019, 1:19 a.m.