brandmaier / semtree

Recursive Partitioning for Structural Equation Models
https://brandmaier.github.io/semtree/
GNU General Public License v3.0
13 stars 11 forks source link

bug in partialDependence #43

Closed brandmaier closed 2 years ago

brandmaier commented 2 years ago

The following minimal example produces an error in the new implementation of partialDependence, @cjvanlissa

library(semtree)
library(lavaan)
library(tictoc)

# sample some univariate data in x and two covariates y,z
n<-1000
data <- data.frame(x=rnorm(n),
                   y=ordered(rbinom(n = n,1,.25)),
                   z=ordered(sample(c(0,1),n,TRUE))
                   )

model <- "x~~x; x~0"
model <- lavaan::lavaan(model, data)

forest <- semforest(model, data,control = semforest.control(num.trees=20))

pd <- partialDependence(forest, reference.var = "y")