I have a N-way frequency table generated from a regression model fit. This is a reproducible example of such table:
data("CO2")
lm.fit = lm(uptake ~ Type + Treatment, data = CO2)
lm.fit$coefficients
test = count(CO2, c('Type','Treatment'))
test$res = predict(lm.fit, newdata = test)
test$freq = NULL
I am trying to visualize test
as a decision tree with nodes as Type
and Treatment
and res
as leaves. I would interpret it as the path the regression model takes, leading to the final value for a particular segment.
I am not able to generate a tree with test
. I am also open to other novel ways of visualizing these results. My original problem has many categorical variables, so I am looking for a customizable visualization, something from party::ctree
or rattle::fancyRpartPlot
.