GLMM S4类模型对象的k倍交叉验证 [英] k-fold cross validation for GLMM S4 class model object

查看:134
本文介绍了GLMM S4类模型对象的k倍交叉验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用R中的glmer函数适合GLMM对象,并且想要执行k倍交叉验证.对于简单的GLM,我使用了DAAG pkg中的CVbinary函数,如下所示.

I have a GLMM object fit using the glmer function in R and want to perform k-fold cross validation. For simple GLMs I have used the CVbinary function from the DAAG pkg as seen below.

> SimpleGLM <- glm(Res ~ Var1 + Var2, data = Data, family=binomial)
> CVbinary(SimpleGLM,  nfolds=10, print.details=TRUE)

Fold:  3 2 4 1 7 10 6 9 5 8
Internal estimate of accuracy = 0.828
Cross-validation estimate of accuracy = 0.827

但是,当将IndID的随机术语添加到模型中时,符合glmer的模型的S4类将导致错误(如下).

However, when a random term for IndID is added to the model an error (below) results from the S4 class of a model fit with glmer.

GLMMod <- glmer(Res ~ Var1 + Var2 + (1|IndID), data = Data, family=binomial)
> CVbinary(GLMMod ,  nfolds=10, print.details=TRUE)

Error in obj$data : $ operator not defined for this S4 class

我一直在网上寻找并无法找到与CVbinary类似的功能,该功能可用于S4对象,但想在此处进行仔细检查,然后再手动进行编码.

I have been looking online and have been unable to find a function similar to CVbinary that works with S4 objects, but wanted to double check here before I code it manually.

简而言之,(假设我正确地解释了R错误),是否有一个函数可以对S4对象执行k倍交叉验证?

In short, (assuming I am correctly interpreting the R error) is there a function that performs k-fold cross validation on S4 objects?

推荐答案

建议您检查该问题背后的统计假设.当专家采用这种方法评估各个因素的p值时,他们强调需要进行自举,并要特别注意随机因素规范所隐含的研究设计.请参阅草稿" GLMM常见问题解答. (向@BenBolker提供信贷以维护该资源的所有权和所有权.该资源在去年有了很大的扩展,现在甚至还包含一些粗略的图形.它即将成为一本书的章节.)DAAG的作者还出版了DAAGxtras,该书具有您可以在pkg:lme4

You would be well-advised to examine the statistical assumptions underlying the question. When the experts approach this for assessment of p-values for individual factors, they emphasize the need to do bootstrapping with proper attention to the study design implied by the random factor specification. See the "draft" GLMM FAQ. (Credit to @BenBolker for authorship and maintenance of that resource. It has expanded greatly in the last year and now even has some kewl graphics. It's on its way to becoming a book chapter.) The author of DAAG has also published DAAGxtras which has a compareModels function which you could set up after using the newly introduced predict methods in pkg:lme4

还有"r-mixed-models-in"档案的资源:

There's also the resource of the mixed-models-in-R Archive: http://markmail.org/search/?q=+list%3Aorg.r-project.r-sig-mixed-models+cross-validation

这篇关于GLMM S4类模型对象的k倍交叉验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆