本文介绍了R:从 GLMNet 获取 AIC/BIC/可能性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我想知道是否可以从 GLMNet 获取 AIC 和 BIC.我发现 glmnet.cr 似乎能够做到,但我的反应是时间,而不是顺序.我可以根据可能性自己计算它,但 glmnet 也不会返回.

I'm wondering if I can get AIC and BIC from GLMNet. I've found glmnet.cr that seems to be able to do it but my response is time, not ordinal. I could calculate it myself from likelihood but glmnet doesn't return that either.

切线:我真的可以返回 l1norm 吗?我觉得应该是

Tangential: can I actually return the l1norm? I feel like it should just be

fit$norm

但似乎不是.(我知道它说不要把数字拉出来,但我实际上没有使用 R)

but it doesn't seem to be. (I know it says don't pull the numbers out but I'm actually not using the R)

预先感谢您的帮助.

推荐答案

我在如何计算 glmnet 模型的 AIC 和 BIC 方面苦苦挣扎.然而,经过相当多的搜索,我在谷歌结果的第三页找到了答案.它可以在这里找到.我把它贴在这里供未来的读者使用,因为我相信我不会是唯一的.

I was struggling a lot with a way how to calculate AIC and BIC for glmnet models. However, after quite a lot of searching, I found on the third page of google results the answer. It can be found here. I am posting it here for future readers as I believe I cannot be the only one.

最后,我通过以下方式实现了 AIC 和 BIC:

In the end, I implemented the AIC and BIC in the following way:

fit <- glmnet(x, y, family = "multinomial")

tLL <- fit$nulldev - deviance(fit)
k <- fit$df
n <- fit$nobs
AICc <- -tLL+2*k+2*k*(k+1)/(n-k-1)
AICc

BIC<-log(n)*k - tLL
BIC

这篇关于R:从 GLMNet 获取 AIC/BIC/可能性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 23:40