Problem with glmmTMB function in R: 在摘要中出现NaN。

huangapple go评论79阅读模式
英文:

Problem with glmmTMB function in R: gives NaN in summary

问题

I have a large motor insurance dataset with which I want to make a mixed model regression to model the expected claim frequency using glmmTMB, with the purpose of determining an initial base premium.

My script looks like this:

glmmTMB(response ~ Var1 + Var2 + Var3 + ... +
   offset(log(exposure_level) + (1|policy_id), 
       data = data, 
       family = nbinom1(link = "log")) 

No matter what I do I get warnings regarding NaN and convergence and the p-value, std, z value, AIC, BIC, logLik and deviance in the summary are all NaN.

I get the following warnings:

Warning messages:
1: In .checkRankX(TMBStruc, control$rank_check) :
fixed effects in conditional model are rank deficient
2: In (function (start, objective, gradient = NULL, hessian = NULL, :
NA/NaN function evaluation
3: In (function (start, objective, gradient = NULL, hessian = NULL, :
NA/NaN function evaluation
4: In fitTMB(TMBStruc) :
Model convergence problem; non-positive-definite Hessian matrix. See vignette('troubleshooting')
5: In fitTMB(TMBStruc) :
Model convergence problem; false convergence (8). See vignette('troubleshooting')

I have tried grouping the data more and leaving out variables, but it does not seem that I can fix the issues. No matter what I try the warnings and NaN still shows.

Has anyone experienced the same and know how to solve the problem?

英文:

I have a large motor insurance dataset with which I want to make a mixed model regression to model the expected claim frequency using glmmTMB, with the purpose of determining an initial base premium.

My script looks like this:

glmmTMB(response ~ Var1 + Var2 + Var3 + ... +
   offset(log(exposure_level) + (1|policy_id), 
       data = data, 
       family = nbinom1(link = "log")) 

No matter what I do I get warnings regarding NaN and convergence and the p-value, std, z value, AIC, BIC, logLik and deviance in the summary are all NaN.

I get the following warnings:

> Warning messages: <br>
> 1: In .checkRankX(TMBStruc, control$rank_check) :
fixed effects in conditional model are rank deficient<br>
> 2: In (function (start, objective, gradient = NULL, hessian = NULL, :
NA/NaN function evaluation<br>
> 3: In (function (start, objective, gradient = NULL, hessian = NULL, :
NA/NaN function evaluation<br>
> 4: In fitTMB(TMBStruc) :
Model convergence problem; non-positive-definite Hessian matrix. See vignette('troubleshooting')<br>
> 5: In fitTMB(TMBStruc) :
Model convergence problem; false convergence (8). See vignette('troubleshooting')

I have tried grouping the data more and leaving out variables, but it does not seem that I can fix the issues. No matter what I try the warnings and NaN still shows.

Has anyone experienced the same and know how to solve the problem?

答案1

得分: 1

The key is

> 在.checkRankX(TMBStruc, control$rank_check)中:条件模型中的固定效应秩亏

如果您在模型拟合中添加参数control = glmmTMBControl(rank_check = "adjust"),它应该会自动处理这个问题。

这意味着您的预测变量集中存在多重共线性列(有很多原因会导致这种情况:与某些组合缺失的交互作用、完全描述一组分类选项的虚拟变量、常量列...)

例如:

library(glmmTMB)
data("sleepstudy", package = "lme4")
ss <- transform(sleepstudy, Days2 = Days)
m <- glmmTMB(Reaction ~ Days + Days2 + (1|Subject),
   data = ss,
   control = glmmTMBControl(rank_check = "adjust"))

这会产生消息(不再是警告)

> 从秩亏的条件模型中删除列:Days2

英文:

The key is

> In .checkRankX(TMBStruc, control$rank_check) : fixed effects in conditional model are rank deficient

If you add the argument control = glmmTMBControl(rank_check = &quot;adjust&quot;) to your model fit, it should take care of this automatically.

This means that you have multicollinear columns in your set of predictor variables (there are lots of reasons this happens: interactions with some combinations missing, dummy variables that completely describe a set of categorical options, constant columns ...)

For example:

library(glmmTMB)
data(&quot;sleepstudy&quot;, package = &quot;lme4&quot;)
ss &lt;- transform(sleepstudy, Days2 = Days)
m &lt;- glmmTMB(Reaction ~ Days + Days2 + (1|Subject),
   data = ss,
   control = glmmTMBControl(rank_check = &quot;adjust&quot;))

which gives the message (not a warning any more)

> dropping columns from rank-deficient conditional model: Days2

huangapple
  • 本文由 发表于 2023年5月17日 20:36:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76272172.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定