本文介绍了使用插入式火车的二项式GLM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在某个数据集上拟合二项式GLM.使用glm(...,family = binomial)一切正常,但是我想使用插入符号train()函数来完成.不幸的是,我遇到了无法消除的意外错误.

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()) 

我得到的错误是:

推荐答案

caret不支持用于二项式结果的分组数据.您可以将数据扩展为二进制(伯努利)数据的因子变量.另外,如果执行此操作,则无需在对train的调用中使用family=binomial().

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.

最大

这篇关于使用插入式火车的二项式GLM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 07:34