Created
June 3, 2020 13:07
-
-
Save vincentarelbundock/40f53604ec843972b489c877cb1f0203 to your computer and use it in GitHub Desktop.
test-pool.r.squared.R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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