I have 3 factors x1, x2, x3, and one outcome y (True, False).
x1 has 3 levels, x2 has 40 levels, x3 has 2 levels.
I would like to find which parameter (x1, x2, or x3) and associated levels influence the most the outcome y. Is this possible with rpart?
I tried:
fit <- rpart(y ~ x1, model="class")
Error in if (model) { : argument is not interpretable as logical
> fit <- rpart(y ~ x1)
> fit
n= 181365
node), split, n, loss, yval, (yprob)
* denotes terminal node
1) root 181365 16370 FALSE (0.90974003 0.09025997) *
I am not sure which model to take: "anova", "poisson", "class" or "exp"?
The example in the manual (Kyphosis) uses only numeric input, but I have factors.
Here is a reproduction of the problem in a small data set:
> a = data.frame(c("A", "A", "B"), c(FALSE, FALSE, TRUE))
> a
c..A....A....B.. c.FALSE..FALSE..TRUE.
1 A FALSE
2 A FALSE
3 B TRUE
> colnames(a)=c("x1", "y")
> a
x1 y
1 A FALSE
2 A FALSE
3 B TRUE
> rpart(y ~ x1, data=a, model="class")
Error in if (model) { : argument is not interpretable as logical
> a$y = factor(a$y)
> rpart(y ~ x1, data=a, model="class")
Error in if (model) { : argument is not interpretable as logical
> a$y = as.factor(a$y)
> rpart(y ~ x1, data=a, model="class")
Error in if (model) { : argument is not interpretable as logical