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

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

x = testdata.apa.regression.lm
model = lm(Response ~ Treatment, data = x)

tab = apa.regression(model)
exp = matrix(byrow = T, nrow = 2,
  c("-0.002", "$t$(38) = -0.009", "(r = 0.001)", "(p > .05)",
    "2.113",  "$t$(38) = 7.573",  "(r = 0.776)", "(p < .001)"))
rownames(exp) = c("(Intercept)", "Treatment2")
colnames(exp) = c("Estimate", "t-test", "r", "p-value")
expect_identical(tab, exp)

tab = apa.regression.lm(model)
exp = matrix(byrow = T, nrow = 2,
  c("-0.002", "$t$(38) = -0.009", "(r = 0.001)", "(p > .05)",
    "2.113",  "$t$(38) = 7.573", "(r = 0.776)", "(p < .001)"))
rownames(exp) = c("(Intercept)", "Treatment2")
colnames(exp) = c("Estimate", "t-test", "r", "p-value")
expect_identical(tab, exp)

ci = confint(model)
tab = apa.regression.lm(model, ci)
exp = matrix(byrow = T, nrow = 2,
  c("-0.002", "[-0.4, 0.4]", "$t$(38) = -0.009", "(r = 0.001)", "(p > .05)",
    "2.113",  "[1.55, 2.68]", "$t$(38) = 7.573", "(r = 0.776)", "(p < .001)"))
rownames(exp) = c("(Intercept)", "Treatment2")
colnames(exp) = c("Estimate", "CI 95%", "t-test", "r", "p-value")
expect_identical(tab, exp)
markanewman/apaformat documentation built on May 10, 2019, 1:19 a.m.