[R] #library("CHAID") - Cross validation for chaid

Max Kuhn mxkuhn at gmail.com
Mon Jan 5 17:56:18 CET 2015


You can create your own:

   http://topepo.github.io/caret/custom_models.html

I put a prototype together. Source this file:

   https://github.com/topepo/caret/blob/master/models/files/chaid.R

then try this:

library("CHAID")

### fit tree to subsample
set.seed(290875)
USvoteS <- USvote[sample(1:nrow(USvote), 1000),]


## You probably don't want to use `train.formula` as
## it will convert the factors to dummy variables
mod <- train(x = USvoteS[,-1], y = USvoteS$vote3,
             method = modelInfo,
             trControl = trainControl(method = "cv"))

Max

On Mon, Jan 5, 2015 at 7:11 AM, Rodica Coderie via R-help
<r-help at r-project.org> wrote:
> Hello,
>
> Is there an option of cross validation for CHAID decision tree? An example of CHAID is below:
> library("CHAID")
> example("chaid", package = "CHAID")
>
> How can I use a 10 fold cross-validation for CHAID?
> I've read that caret package is to cross-validate on many times of models, but model CHAID is not in caret's built-in library.
>
> library(caret)
> model <- train(vote3 ~., data = USvoteS, method='CHAID', tuneLength=10,trControl=trainControl(method='cv', number=10, classProbs=TRUE, summaryFunction=twoClassSummary))
>
> Thanks,
> Rodica
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list