[R] kknn and logistic regression: how to cross-validate binary prediction
Max Kuhn
mxkuhn at gmail.com
Tue Mar 16 12:04:16 CET 2010
Take a look at the caret package
http://cran.r-project.org/web/packages/caret/index.html
and the package vignettes, especially the one labeled as "model
builing".
Max
On Mar 15, 2010, at 6:11 PM, noclue_ <tim.liu at netzero.net> wrote:
>
> I am comparing kknn and logistic regression for binary outcome
> prediction -
>
> For kknn, I can do -
>
> kknn_<-kknn(out_come ~ age + gender , learn_, valid_)
> fit<-fitted(kknn_)
> table(valid_$out_come, fit)
>
> to get validation results in cross-tabulation.
>
> ---------
>
> For logistic, how can I do the equivalent cross-validation?
>
> logit_<-glm(out_come ~ age + gender, data=learn_, family=binomial)
> ...
> ...
> then how could I fit the logistic regression on validation data (ie.
> valid_)
> to get predicted outcome?
>
> Thanks!
> --
> View this message in context: http://n4.nabble.com/kknn-and-logistic-regression-how-to-cross-validate-binary-prediction-tp1594107p1594107.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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