1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
skip_on_cran()
skip_if_not_installed("mmrm")
skip_if_not(packageVersion("insight") > "0.18.8")
test_that("model_parameters", {
data(fev_data, package = "mmrm")
m1 <- mmrm::mmrm(
formula = FEV1 ~ RACE + SEX + ARMCD * AVISIT + us(AVISIT | USUBJID),
data = fev_data
)
out1 <- coef(summary(m1))
out2 <- model_parameters(m1)
expect_equal(
as.vector(out1[, "Estimate"]),
out2$Coefficient,
tolerance = 1e-4,
ignore_attr = TRUE
)
expect_identical(
rownames(out1),
out2$Parameter
)
expect_equal(
as.vector(out1[, "df"]),
out2$df_error,
tolerance = 1e-4,
ignore_attr = TRUE
)
expect_equal(
as.vector(out1[, "Pr(>|t|)"]),
out2$p,
tolerance = 1e-4,
ignore_attr = TRUE
)
expect_equal(
as.vector(out1[, "t value"]),
out2$t,
tolerance = 1e-4,
ignore_attr = TRUE
)
expect_equal(
as.vector(out1[, "Std. Error"]),
out2$SE,
tolerance = 1e-4,
ignore_attr = TRUE
)
expect_identical(attributes(out2)$ci_method, "Satterthwaite")
})
test_that("model_parameters", {
data(fev_data, package = "mmrm")
m1 <- mmrm::mmrm(
formula = FEV1 ~ RACE + SEX + ARMCD * AVISIT + us(AVISIT | USUBJID),
data = fev_data,
method = "Kenward-Roger"
)
out1 <- coef(summary(m1))
out2 <- model_parameters(m1)
expect_equal(
as.vector(out1[, "Estimate"]),
out2$Coefficient,
tolerance = 1e-4,
ignore_attr = TRUE
)
expect_identical(
rownames(out1),
out2$Parameter
)
expect_equal(
as.vector(out1[, "df"]),
out2$df_error,
tolerance = 1e-4,
ignore_attr = TRUE
)
expect_equal(
as.vector(out1[, "Pr(>|t|)"]),
out2$p,
tolerance = 1e-4,
ignore_attr = TRUE
)
expect_equal(
as.vector(out1[, "t value"]),
out2$t,
tolerance = 1e-4,
ignore_attr = TRUE
)
expect_equal(
as.vector(out1[, "Std. Error"]),
out2$SE,
tolerance = 1e-4,
ignore_attr = TRUE
)
expect_identical(attributes(out2)$ci_method, "Kenward")
})
|