How would I find the the probability of getting an outcome of Y=0 given new.data (X1=4,X2=4,X3=4) for a tree model I created with method = 'poisson'? Exact code below:
tree.pois.cp<-rpart(Y ~ X1 + X2 + X3, data = data, method = 'poisson', control = rpart.control(cp = 1.1034e-02))
I used the below code for the same thing but using my negative binomial model:
pred.y.nb<-predict(nb, newdata = new.data, type = "response")
prob0.nb<-dnbinom(0, mu=pred.y.nb, size=nb$theta)
prob0.nb
#this is my answer for probability of Y=0 given my negative binom model
(Shout out to this question for helping me out: How to calculate the predicted probability of negative binomial regression model?)
I tried using the same code for my tree model tree.pois.cp:
pred.y.pois.cp<-predict(tree.pois.cp, newdata = new.data, type = "response")
But I get this error:
Error in match.arg(type) : 'arg' should be one of “vector”, “prob”, “class”, “matrix”
Thanks for your help!