Skip to content

Commit

Permalink
remove the offending coxph test
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed Apr 5, 2023
1 parent 0f25a27 commit 14af423
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 26 deletions.
24 changes: 0 additions & 24 deletions tests/testthat/test-coxph.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,3 @@ test_that("model_parameters", {
tolerance = 1e-4
)
})


test_that("model_parameters", {
suppressPackageStartupMessages(library(survival, quietly = TRUE))

# Create the simplest test data set
test1 <- list(
time = c(4, 3, 1, 1, 2, 2, 3),
status = c(1, 1, 1, 0, 1, 1, 0),
x = c(0, 2, 1, 1, 1, 0, 0),
sex = c(0, 0, 0, 0, 1, 1, 1)
)
# Fit a stratified model
m2 <- coxph(Surv(time, status) ~ x + strata(sex), test1)
expect_equal(model_parameters(m2)$Coefficient, 0.8023179, tolerance = 1e-4)
expect_equal(model_parameters(m2)$z, 0.9756088, tolerance = 1e-4)
expect_equal(model_parameters(m2)$p, 0.3292583, tolerance = 1e-4)

unloadNamespace("quantreg")
unloadNamespace("rms")
unloadNamespace("multcomp")
unloadNamespace("TH.data")
unloadNamespace("survival")
})
16 changes: 14 additions & 2 deletions tests/testthat/test-model_parameters.efa_cfa.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
test_that("principal_components", {
skip_if_not_installed("psych")

set.seed(333)
x <- principal_components(mtcars[, 1:7], n = "all", threshold = 0.2)
expect_identical(c(ncol(x), nrow(x)), c(8L, 7L))
Expand All @@ -26,6 +27,7 @@ test_that("principal_components", {
test_that("efa-cfa", {
skip_if_not_installed("psych")
skip_if_not_installed("lavaan")

efa <- psych::fa(attitude, nfactors = 3)
params <- parameters::model_parameters(efa)
expect_identical(c(nrow(params), ncol(params)), c(7L, 6L))
Expand All @@ -51,15 +53,25 @@ test_that("efa-cfa", {

test_that("FactoMineR", {
skip_if_not_installed("FactoMineR")
x <- suppressWarnings(model_parameters(FactoMineR::PCA(mtcars, ncp = 3, graph = FALSE), threshold = 0.2, sort = TRUE))

x <- suppressWarnings(model_parameters(
FactoMineR::PCA(mtcars, ncp = 3, graph = FALSE),
threshold = 0.2,
sort = TRUE
))
expect_identical(c(ncol(x), nrow(x)), c(5L, 11L))

x <- suppressWarnings(model_parameters(FactoMineR::FAMD(iris, ncp = 3, graph = FALSE), threshold = 0.2, sort = TRUE))
x <- suppressWarnings(model_parameters(
FactoMineR::FAMD(iris, ncp = 3, graph = FALSE),
threshold = 0.2,
sort = TRUE
))
expect_identical(c(ncol(x), nrow(x)), c(5L, 5L))
})

test_that("BayesFM", {
skip_if_not_installed("BayesFM")

set.seed(333)
befa <- BayesFM::befa(mtcars, iter = 1000, verbose = FALSE)
params <- suppressWarnings(parameters::model_parameters(befa, sort = TRUE))
Expand Down

0 comments on commit 14af423

Please sign in to comment.