Unanble to produce the plot using ctree(partykit)

43 views Asked by At

I am trying to plot a simple conditional inference tree using the "partykit" package in R. But when I try to produce the plot of the ctree, it produces the following error -

Error in valid.viewport(x, y, width, height, just, gp, clip, mask, xscale, : invalid 'yscale' in viewport

I am attaching the code that I have used and also the plot that I am getting -

library(partykit)
data("airquality")


dumm_model = ctree(Ozone ~ ., data=airquality, na.action = na.pass,
                   control = ctree_control(teststat = "quadratic", testtype = "Bonferroni"))

plot(dumm_model)

Ctree plot produced with no terminal nodes

The dataset "airquality" obviously has some missing values, but I used the na.pass value in the na.action argument which is supposed to ignore the missing values in the dataset. Can someone help me with this problem of getting the plot of the tree?

1

There are 1 answers

1
G5W On

To get rid of the NA's use na.action = na.omit

dumm_model2 = ctree(Ozone ~ ., data=airquality, na.action = na.omit,
            control = ctree_control(teststat = "quadratic", 
            testtype = "Bonferroni"))
plot(dumm_model2)

Tree diagram