Hi, chaid_table.R has been really helpful, but when creating node_table, only filtering complete cases may result in 0 frequencies for the outcome levels (if each case has at least one missing value across the independent variables). Those 0 frequencies will later cause the chisq.test to raise an error because x must be positive.
I've removed both filter(complete.cases(.)) %>% and it works just fine to me.
Also noticed that you did tidyr::pivot_wider in row 76 but not in row 87.
Hi, chaid_table.R has been really helpful, but when creating node_table, only filtering complete cases may result in 0 frequencies for the outcome levels (if each case has at least one missing value across the independent variables). Those 0 frequencies will later cause the chisq.test to raise an error because x must be positive.
I've removed both
filter(complete.cases(.)) %>%and it works just fine to me.Also noticed that you did
tidyr::pivot_widerin row 76 but not in row 87.