模型无法收敛,并且使用glmer发出了多个警告

时间:2019-12-07 20:58:58

标签: r lme4 mixed-models

我是R新手,并尝试使用glmer来帮助完成我的论文。我使用的是Stat v16,但meglm不允许我使用伽马分布和链接标识,因此我来到R来执行此操作。不幸的是,我仍然无法使完整的模型收敛。

不确定这是否有帮助,但这就是我在Stata中试图做的事情:

meglm countOutcome Exposure##c.TimePeriod1 Exposure##c.TimePeriod2 Exposure##c.TimePeriod3 Exposure##c.TimePeriod4 covariate1 covariate2  covariate3, || SBA:, family(gaussian) link(identity) covariance(unstructured) offset(area) reml 

这是我尝试过的...

第一次尝试:

summary(glmer(countOutcome ~ 1 + Exposure.f*TimePeriod1 + Exposure.f*TimePeriod2 + Exposure.f*TimePeriod3 + Exposure.f*TimePeriod4 + covariate1 + covariate2 + covariate3 + (1 | SBA), data=data,family=Gamma(link=identity))) 
fit warnings:
Some predictor variables are on very different scales: consider rescaling
convergence code: 0
unable to evaluate scaled gradient
Model failed to converge: degenerate  Hessian with 4 negative eigenvalues
failure to converge in 10000 evaluations

Warning messages:
1: Some predictor variables are on very different scales: consider rescaling 
2: In (function (fn, par, lower = rep.int(-Inf, n), upper = rep.int(Inf,  :
  failure to converge in 10000 evaluations
3: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  unable to evaluate scaled gradient
4: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge: degenerate  Hessian with 4 negative eigenvalues
5: In vcov.merMod(object, use.hessian = use.hessian) :
  variance-covariance matrix computed from finite-difference Hessian is
not positive definite or contains NA values: falling back to var-cov estimated from RX
6: In vcov.merMod(object, correlation = correlation, sigm = sig) :
  variance-covariance matrix computed from finite-difference Hessian is
not positive definite or contains NA values: falling back to var-cov estimated from RX

我通过以均值为中心对协变量进行了缩放,但仍然收到警告。

fit warnings:
Some predictor variables are on very different scales: consider rescaling
convergence code: 0
unable to evaluate scaled gradient
Model failed to converge: degenerate  Hessian with 4 negative eigenvalues
failure to converge in 10000 evaluations

Warning messages:
1: Some predictor variables are on very different scales: consider rescaling 
2: In (function (fn, par, lower = rep.int(-Inf, n), upper = rep.int(Inf,  :
  failure to converge in 10000 evaluations
3: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  unable to evaluate scaled gradient
4: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge: degenerate  Hessian with 4 negative eigenvalues
5: In vcov.merMod(object, use.hessian = use.hessian) :
  variance-covariance matrix computed from finite-difference Hessian is
not positive definite or contains NA values: falling back to var-cov estimated from RX
6: In vcov.merMod(object, correlation = correlation, sigm = sig) :
  variance-covariance matrix computed from finite-difference Hessian is
not positive definite or contains NA values: falling back to var-cov estimated from RX

然后,我按每1000个人重新调整了协变量的比例,但仍然收到警告。

convergence code: 0
unable to evaluate scaled gradient
Model failed to converge: degenerate  Hessian with 3 negative eigenvalues

Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  unable to evaluate scaled gradient
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge: degenerate  Hessian with 3 negative eigenvalues
3: In vcov.merMod(object, use.hessian = use.hessian) :
  variance-covariance matrix computed from finite-difference Hessian is
not positive definite or contains NA values: falling back to var-cov estimated from RX
4: In vcov.merMod(object, correlation = correlation, sigm = sig) :
  variance-covariance matrix computed from finite-difference Hessian is
not positive definite or contains NA values: falling back to var-cov estimated from RX

在Stack Exchange上浏览了几篇非常有用的文章之后,我尝试了另外三种方法但无济于事...非常欢迎提出建议。

尝试使用bobyqa作为优化程序:

summary(glmer(countOutcome ~ 1 + Exposure.f*TimePeriod1 + Exposure.f*TimePeriod2 + Exposure.f*TimePeriod3 + Exposure.f*TimePeriod4 + covariate1 + covariate2 + covariate3 + (1 | SBA),
              data=data, REML= TRUE, 
              family=Gamma(link=identity)), control=glmerControl(
                optimizer="bobyqa",optCtrl=list(maxfun=2e5)))


convergence code: 0
unable to evaluate scaled gradient
Model failed to converge: degenerate  Hessian with 3 negative eigenvalues

Warning messages:
1: extra argument(s) ‘REML’ disregarded 
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  unable to evaluate scaled gradient
3: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge: degenerate  Hessian with 3 negative eigenvalues
4: In summary.merMod(glmer(sba_nyc_fe_c ~ 1 + Gcode.f * T + Gcode.f *  :
  additional arguments ignored
5: In vcov.merMod(object, use.hessian = use.hessian) :
  variance-covariance matrix computed from finite-difference Hessian is
not positive definite or contains NA values: falling back to var-cov estimated from RX
6: In vcov.merMod(object, correlation = correlation, sigm = sig) :
  variance-covariance matrix computed from finite-difference Hessian is
not positive definite or contains NA values: falling back to var-cov estimated from RX

下一步尝试使用优化器L-BFGS-B:

summary(glmer(countOutcome ~ 1 + Exposure.f*TimePeriod1 + Exposure.f*TimePeriod2 + Exposure.f*TimePeriod3 + Exposure.f*TimePeriod4 + covariate1 + covariate2 + covariate3 + (1 | SBA),
              data=data, REML= TRUE, 
              family=Gamma(link=identity)), control=glmerControl(
                control = lmerControl(optimizer ='L-BFGS-B')))

convergence code: 0
unable to evaluate scaled gradient
Model failed to converge: degenerate  Hessian with 3 negative eigenvalues

Warning messages:
1: extra argument(s) ‘REML’ disregarded 
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  unable to evaluate scaled gradient
3: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge: degenerate  Hessian with 3 negative eigenvalues
4: In summary.merMod(glmer(sba_nyc_fe_c ~ 1 + Gcode.f * T + Gcode.f *  :
  additional arguments ignored
5: In vcov.merMod(object, use.hessian = use.hessian) :
  variance-covariance matrix computed from finite-difference Hessian is
not positive definite or contains NA values: falling back to var-cov estimated from RX
6: In vcov.merMod(object, correlation = correlation, sigm = sig) :
  variance-covariance matrix computed from finite-difference Hessian is
not positive definite or contains NA values: falling back var-cov estimated from RX

下一步尝试使用优化器nlminb:

summary(glmer(countOutcome ~ 1 + Exposure.f*TimePeriod1 + Exposure.f*TimePeriod2 + Exposure.f*TimePeriod3 + Exposure.f*TimePeriod4 + covariate1 + covariate2 + covariate3 + (1 | SBA),
              data=data, REML= TRUE, 
              family=Gamma(link=identity)), control=glmerControl(
               optimizer ='optimx', optCtrl=list(method='nlminb')))

convergence code: 0
unable to evaluate scaled gradient
Model failed to converge: degenerate  Hessian with 3 negative eigenvalues

Warning messages:
1: extra argument(s) ‘REML’ disregarded 
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  unable to evaluate scaled gradient
3: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge: degenerate  Hessian with 3 negative eigenvalues
4: In summary.merMod(glmer(sba_nyc_fe_c ~ 1 + Gcode.f * T + Gcode.f *  :
  additional arguments ignored
5: In vcov.merMod(object, use.hessian = use.hessian) :
  variance-covariance matrix computed from finite-difference Hessian is
not positive definite or contains NA values: falling back to var-cov estimated from RX
6: In vcov.merMod(object, correlation = correlation, sigm = sig) :
  variance-covariance matrix computed from finite-difference Hessian is
not positive definite or contains NA values: falling back to var-cov estimated from RX

我缺少什么吗?为什么这个模型不能收敛?谢谢

0 个答案:

没有答案