SCM

Forum: help

Monitor Forum | Start New Thread Start New Thread
RE: Bug when using `MIA` option in `ctree()` [ Reply ]
By: Ben Schneider on 2025-01-29 13:52
[forum:50058]
Thank you for the quick responses and update Achim and Torsten! I installed the updated version of 'partykit' from R-Forge and the bug I reported is resolved in that reproducible example. Much appreciated,

Ben

RE: Bug when using `MIA` option in `ctree()` [ Reply ]
By: Torsten Hothorn on 2025-01-29 10:28
[forum:50057]
The problem was that MIA was not turned-off in nodes w/o missing values. Fixed now and hopefully soon on CRAN. Thanks!

RE: Bug when using `MIA` option in `ctree()` [ Reply ]
By: Torsten Hothorn on 2025-01-29 07:16
[forum:50056]
Confirmed, will have a look. Thanks to both of you! Torsten

RE: Bug when using `MIA` option in `ctree()` [ Reply ]
By: Achim Zeileis on 2025-01-29 01:55
[forum:50054]
Benjamin, thanks for the report. I can confirm the problem and stumbled upon another error when using MIA = TRUE. As this is Torsten's code I hope that he will have a look at this.

I boiled down your reproducible example as much as I could:

## data
d <- data.frame(
y = factor(rep(0:1, c(14, 16))),
x = factor(c(1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, NA)),
z = c(1, 2, 3, 4, 1, 2, 4, 1, 2, 4, 1, 2, 3, 4, 1, 2, 3, 4, NA, 1, 2, 4, 1, 2, 3, 1, 2, 3, 4, 1)
)
d <- d[rep.int(1:30, c(22, 9, 4, 15, 12, 2, 7, 6, 1, 4, 25, 6, 2, 7, 42, 16, 3, 31, 1, 7, 3, 7, 1, 1, 3, 22, 3, 4, 18, 1)), ]

## package
library("partykit")

And then this is the error you had found:

ctree(y ~ x + z, data = d, alpha = 0.1, minbucket = 60, maxdepth = 7, MIA = TRUE)
## Error in partynode(id, split = split_node(x), kids = lapply(kids_node(x), :
## 'kids' must be an integer vector or a list of 'partynode' objects

And this is a new one:

ctree(y ~ x + z, data = d, alpha = 0.1, minbucket = 60, MIA = TRUE)
## Error in .LinStatExpCov1d(X = X, Y = Y, weights = weights, subset = subset, :
## node stack overflow

Both of these only appear to occur in the MIA case.

Bug when using `MIA` option in `ctree()` [ Reply ]
By: Ben Schneider on 2025-01-28 22:38
[forum:50053]

partykit-mia-bug-reproducible-example.R (1) downloads
Hello,

I'm writing to share a bug that occurs when using the `ctree()` function in `partykit` with the MIA option. For the attached dataset, I can run `ctree()` without issue if I specify `MIA=FALSE`. But when I specify `MIA=TRUE`, I get the following opaque error message:

> Error in partynode(id, split = split_node(x), kids = lapply(kids_node(x), : 'kids' must be an integer vector or a list of 'partynode' objects

I have attached an R script with a minimal reproducible example. The script creates a small dataset with a binary outcome variable and two predictors, one a factor variable and another a numeric predictor. It runs the call with `MIA = TRUE` first, producing the error message, and then shows the successful results from the same call with `MIA = FALSE`.

Since I don't have experience with `partykit` internals, it's not at all clear to me why the issue arises here.

Please let me know if I can provide any additional information that might be able to help resolve this bug.

Thanks,

Ben

--

BenjaminSchneider@westat.com

Thanks to:
Vienna University of Economics and Business Powered By FusionForge