Skip to content

Commit

Permalink
added a test for dummy splits
Browse files Browse the repository at this point in the history
  • Loading branch information
brandmaier committed Dec 6, 2023
1 parent c2c6140 commit cb9289f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/testthat/test-dummy-split.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
library(lavaan)


set.seed(458)
n <- 500
var_unordered <- factor(sample(c("lightning","rain","sunshine","snow"),n,TRUE))
var_grp <- factor((var_unordered %in% c("rain","sunshine")))
x <- rnorm(n)+ifelse(var_grp,20,0)

# data frame has only a dummy predictor
df <- data.frame(x=x, var_grp)

fit <- lavaan("x~~x",df)

tree <- semtree(fit, df, control = semtree.control(method="score"))

testthat::expect_equal(tree$rule$name, "var_grp")
testthat::expect_equal(tree$rule$value, "FALSE")

0 comments on commit cb9289f

Please sign in to comment.