Binomial GLM using caret train

﹥>﹥吖頭↗ 提交于 2019-12-10 21:26:42

问题


I would like to fit a Binomial GLM on a certain dataset. Using glm(...,family=binomial) everything works fine however I would like to do it with the caret train() function. Unfortunately I get an unexpected error which I cannot get rid of.

library("marginalmodelplots")
library("caret")

MissUSA <- MissAmerica08[,c(2,4,6,7,8,10)]
formula<-cbind(Top10, 9-Top10)~.
glmfit <- glm(formula=formula,data=MissUSA,family=binomial())

trainfit<-train(form=formula,data=MissUSA,trControl=trainControl(method = "none"),   method="glm",  family=binomial()) 

The error I get is: "Error : nrow(x) == length(y) is not TRUE"


回答1:


caret doesn't support grouped data for a binomial outcome. You can expand the data into a factor variable that is binary (Bernoulli) data. Also, if you do that, you do not need to use family=binomial() in the call to train.

Max



来源:https://stackoverflow.com/questions/25803960/binomial-glm-using-caret-train

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!