Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vincentarelbundock/40f53604ec843972b489c877cb1f0203 to your computer and use it in GitHub Desktop.
Save vincentarelbundock/40f53604ec843972b489c877cb1f0203 to your computer and use it in GitHub Desktop.
test-pool.r.squared.R
library(testthat)
library(mice)
context("pool.r.squared")
data(nhanes)
imp <- mice::mice(nhanes, maxit = 2, m = 2, seed = 1, print = FALSE)
fit_mira <- with(data = imp, exp = lm(chl ~ age + bmi))
test_that("r.squared", {
result <- as.vector(pool.r.squared(fit_mira, adjusted = FALSE)[1, ])
truth <- c(0.509058126347586, 0.000336803067828044, 0.890425978574948, NaN)
expect_equal(result, truth)
})
test_that("r.squared.adjusted", {
result <- as.vector(pool.r.squared(fit_mira, adjusted = TRUE)[1, ])
truth <- c(0.461526485190816, 0.0069275130447448, 0.883865543155355, NaN)
expect_equal(result, truth)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment