- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 R 中的 lme4
的 glmer
函数分析数据(包括在下面)。我正在构建的模型包含一个泊松分布响应变量 (obs
)、一个随机因子 (area
)、一个连续偏移量 (duration
), 五个连续固定效应 (can_perc
, can_n
, time
, temp
, cloud_cover
) 和一个二项式固定效应因子 (burnt
)。在拟合模型之前,我检查了共线性并删除了所有共线性变量。
初始模型为:
q1 = glmer(obs ~ can_perc + can_n + time * temp +
cloud_cover + factor(burnt) + (1|area) + offset(dat$duration),
data=dat, family=poisson, na.action = na.fail)
(注意:我需要将 na.action
指定为“na.fail”,因为我稍后想 dredge()
模型,这是必需的.)
运行模型会给出以下警告:
"Hessian is numerically singular: parameters are not uniquely determined"
在模型的类似变体中,我也收到了警告:
"In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model is nearly unidentifiable: large eigenvalue ratio - Rescale variables?"
根据我对此处建议的有限理解https://rdrr.io/cran/lme4/man/troubleshooting.html在其他地方,这两个警告都反射(reflect)了一个类似的问题,即 Hessian(逆曲率矩阵)具有较大的特征值,表明(在数值公差范围内)表面在某个方向上是完全平坦的。根据警告和链接中的建议,我使用 scale()
重新调整了所有连续预测变量。我还缩放了偏移量变量(我尝试了缩放和不缩放这个变量)。具有缩放预测变量的模型在这里:
q2 = glmer(obs ~ s.can_perc + s.can_n + s.time * s.temp +
s.cloud_cover + factor(burnt) + (1|area) +
offset(dat$s.duration),
data=dat, family=poisson, na.action = na.fail)
但是我还没有逃脱特征值!缩放模型给出了两个警告:
"unable to evaluate scaled gradient"
"Model failed to converge: degenerate Hessian with 1 negative eigenvalues"
我在网上搜索了很多,除了检查模型没有被错误指定之外,找不到其他案例/解决方案来处理预测变量缩放后的特征值问题。
基于这些页面/文档: https://cran.r-project.org/web/packages/lme4/lme4.pdf
https://rdrr.io/cran/lme4/man/isSingular.html
https://stats.stackexchange.com/questions/242109/model-failed-to-converge-warning-in-lmer
和其他人,
我有:
检查了模型规范和数据是否有错误(我没有看到任何错误 - 我是否遗漏了什么?)
使用 is_singular(x, tol = 1e-05)
检查奇点(此函数调用不知何故从 isSingular()
演变为当前形式?):所有模型都给出 FALSE。
使用 converge_ok(q2, tolerance = 0.001)
检查收敛性度量:所有模型都给出 FALSE,除非我大幅增加容差;然而,它们在收敛措施上确实存在很大差异。
尝试了如下不同的优化器/模型估计方法:
glmerControl(optimizer = "bobyqa") 和 glmerControl(optimizer ="Nelder_Mead")
glmerControl(optimizer ='optimx', optCtrl=list(method='nlminb'))
all_fit()
函数。 代码如下:
# singularity and convergence for first two models:
is_singular(s1, tol = 1e-05) # FALSE (a good thing?)
converge_ok(s1, tol = 1e-05) # FALSE (a bad thing?) 0.0259109730912352
is_singular(s2, tol = 1e-05) # FALSE (a good thing?)
converge_ok(s2, tol = 1e-05) # FALSE (a bad thing?) 0.0023434329028163
# I looked at singularity and converge measures for the others below, but omitted for brevity.
# Alternate optimisations for q1:
q1.bobyqa = glmer(obs ~ can_perc + can_n + time * temp + cloud_cover + factor(burnt) + (1|area) + offset(dat$duration), data=dat, family=poisson, na.action = na.fail, glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e5)))
# Warning 1: unable to evaluate scaled gradient
# Warning 2: Model failed to converge: degenerate Hessian with 1 negative eigenvalues
q1.neldermead = glmer(obs ~ can_perc + can_n + time * temp + cloud_cover + factor(burnt) + (1|area) + offset(dat$duration), data=dat, family=poisson, na.action = na.fail, glmerControl(optimizer ="Nelder_Mead", optCtrl = list(maxfun = 2e5)))
# Warning: unable to evaluate scaled gradient Hessian is numerically singular: parameters are not uniquely determined
q1.nlminb = glmer(obs ~ can_perc + can_n + time * temp + cloud_cover + factor(burnt) + (1|area) + offset(dat$duration), data=dat, family=poisson, na.action = na.fail, glmerControl(optimizer ='optimx', optCtrl=list(method='nlminb')))
# Warning: Parameters or bounds appear to have different scalings. This can cause poor performance in optimization.
# It is important for derivative free methods like BOBYQA, UOBYQA, NEWUOA.convergence code 9999 from optimxError in pwrssUpdate(pp, resp, tol = tolPwrss, GQmat = GQmat, compDev = compDev, : (maxstephalfit) PIRLS step-halvings failed to reduce deviance in pwrssUpdate
all_fit(q1)
# Alternate optimisations for q2:
q2.bobyqa = glmer(obs ~ s.can_perc + s.can_n + s.time * s.temp + s.cloud_cover + factor(burnt) + (1|area) + offset(dat$s.duration), data=dat, family=poisson, na.action = na.fail, glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e5)))
# Warning 1: unable to evaluate scaled gradient
# Warning 2: Model failed to converge: degenerate Hessian with 1 negative eigenvalues
q2.neldermead = glmer(obs ~ s.can_perc + s.can_n + s.time * s.temp + s.cloud_cover + factor(burnt) + (1|area) + offset(dat$s.duration), data=dat, family=poisson, na.action = na.fail, glmerControl(optimizer ="Nelder_Mead", optCtrl = list(maxfun = 2e5)))
# Warning: unable to evaluate scaled gradient Hessian is numerically singular: parameters are not uniquely determined
q2.nlminb = glmer(obs ~ s.can_perc + s.can_n + s.time * s.temp + s.cloud_cover + factor(burnt) + (1|area) + offset(dat$s.duration), data=dat, family=poisson, na.action = na.fail, control = glmerControl(optimizer ='optimx', optCtrl=list(method='nlminb')))
# Warning: Model is nearly unidentifiable: large eigenvalue ratio - Rescale variables?
all_fit(q2)
is_singular(s1, tol = 1e-05) # FALSE (a good thing?)
[1] FALSE
converge_ok(s1, tol = 1e-05) # FALSE (a bad thing?) 0.0259109730912352
0.0259109730912352
FALSE
is_singular(s2, tol = 1e-05) # FALSE (a good thing?)
[1] FALSE
alternate optimisations for original model:
q1.bobyqa = glmer(obs ~ can_perc + can_n + time * temp + cloud_cover + factor(burnt) + (1|area) + offset(dat$duration), data=dat, family=poisson, na.action = na.fail, glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e5)))
unable to evaluate scaled gradientModel failed to converge: degenerate Hessian with 1 negative eigenvalues
alternate optimisations for original model:
q1.bobyqa = glmer(obs ~ can_perc + can_n + time * temp + cloud_cover + factor(burnt) + (1|area) + offset(dat$duration), data=dat, family=poisson, na.action = na.fail, glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e5)))
unable to evaluate scaled gradientModel failed to converge: degenerate Hessian with 1 negative eigenvalues
q1.neldermead = glmer(obs ~ can_perc + can_n + time * temp + cloud_cover + factor(burnt) + (1|area) + offset(dat$duration), data=dat, family=poisson, na.action = na.fail, glmerControl(optimizer ="Nelder_Mead", optCtrl = list(maxfun = 2e5)))
unable to evaluate scaled gradient Hessian is numerically singular: parameters are not uniquely determined
all_fit(q1)
bobyqa. : unable to evaluate scaled gradientModel failed to converge: degenerate Hessian with 1 negative eigenvalues[OK]
Nelder_Mead. : unable to evaluate scaled gradient Hessian is numerically singular: parameters are not uniquely determined[OK]
optimx.nlminb : Parameters or bounds appear to have different scalings.
This can cause poor performance in optimization.
It is important for derivative free methods like BOBYQA, UOBYQA, NEWUOA.convergence code 9999 from optimxParameters or bounds appear to have different scalings.
This can cause poor performance in optimization.
It is important for derivative free methods like BOBYQA, UOBYQA, NEWUOA.convergence code 9999 from optimx[ERROR]
optimx.L-BFGS-B : Parameters or bounds appear to have different scalings.
This can cause poor performance in optimization.
It is important for derivative free methods like BOBYQA, UOBYQA, NEWUOA.convergence code 9999 from optimxParameters or bounds appear to have different scalings.
This can cause poor performance in optimization.
It is important for derivative free methods like BOBYQA, UOBYQA, NEWUOA.convergence code 9999 from optimx[ERROR]
nloptwrap.NLOPT_LN_NELDERMEAD : [ERROR]
nloptwrap.NLOPT_LN_BOBYQA : [ERROR]
nmkbw. : [ERROR]
$`bobyqa.`
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
Family: poisson ( log )
Formula: obs ~ can_perc + can_n + time * temp + cloud_cover + factor(burnt) + (1 | area) + offset(dat$duration)
Data: dat
AIC BIC logLik deviance df.resid
311.0473 330.3356 -146.5237 293.0473 54
Random effects:
Groups Name Std.Dev.
area (Intercept) 1.992
Number of obs: 63, groups: area, 8
Fixed Effects:
(Intercept) can_perc can_n time temp
-67.4998 -1.3180 0.0239 4.8025 1.7793
cloud_cover factor(burnt)unburnt time:temp
-0.3813 18.5676 -0.1748
convergence code 0; 2 optimizer warnings; 0 lme4 warnings
$Nelder_Mead.
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
Family: poisson ( log )
Formula: obs ~ can_perc + can_n + time * temp + cloud_cover + factor(burnt) + (1 | area) + offset(dat$duration)
Data: dat
AIC BIC logLik deviance df.resid
311.0473 330.3356 -146.5237 293.0473 54
Random effects:
Groups Name Std.Dev.
area (Intercept) 1.992
Number of obs: 63, groups: area, 8
Fixed Effects:
(Intercept)
can_perc can_n time temp
-67.48057 -1.31791 0.02389 4.80463 1.78012
cloud_cover factor(burnt)unburnt time:temp
-0.38118 18.52637 -0.17483
convergence code 0; 2 optimizer warnings; 0 lme4 warnings
$optimx.nlminb
<std::runtime_error in pwrssUpdate(pp, resp, tol = tolPwrss, GQmat = GQmat, compDev = compDev, grpFac = fac, maxit = maxit, verbose = verbose): (maxstephalfit) PIRLS step-halvings failed to reduce deviance in pwrssUpdate>
$`optimx.L-BFGS-B`
<std::runtime_error in pwrssUpdate(pp, resp, tol = tolPwrss, GQmat = GQmat, compDev = compDev, grpFac = fac, maxit = maxit, verbose = verbose): (maxstephalfit) PIRLS step-halvings failed to reduce deviance in pwrssUpdate>
$nloptwrap.NLOPT_LN_NELDERMEAD
<simpleError in pwrssUpdate(pp, resp, tol = tolPwrss, GQmat = GQmat, compDev = compDev, grpFac = fac, maxit = maxit, verbose = verbose): Downdated VtV is not positive definite>
$nloptwrap.NLOPT_LN_BOBYQA
<simpleError in pwrssUpdate(pp, resp, tol = tolPwrss, GQmat = GQmat, compDev = compDev, grpFac = fac, maxit = maxit, verbose = verbose): Downdated VtV is not positive definite>
$nmkbw.
<std::runtime_error in pwrssUpdate(pp, resp, tol = tolPwrss, GQmat = GQmat, compDev = compDev, grpFac = fac, maxit = maxit, verbose = verbose): (maxstephalfit) PIRLS step-halvings failed to reduce deviance in pwrssUpdate>
alternate optimisations for q2:
q2.bobyqa = glmer(obs ~ s.can_perc + s.can_n + s.time * s.temp + s.cloud_cover + factor(burnt) + (1|area) + offset(dat$s.duration), data=dat, family=poisson, na.action = na.fail, glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e5)))
Model is nearly unidentifiable: large eigenvalue ratio - Rescale variables?
q2.neldermead = glmer(obs ~ s.can_perc + s.can_n + s.time * s.temp + s.cloud_cover + factor(burnt) + (1|area) + offset(dat$s.duration), data=dat, family=poisson, na.action = na.fail, glmerControl(optimizer ="Nelder_Mead", optCtrl = list(maxfun = 2e5)))
unable to evaluate scaled gradientModel failed to converge: degenerate Hessian with 1 negative eigenvalues
all_fit(q2)
bobyqa. : Model is nearly unidentifiable: large eigenvalue ratio
- Rescale variables?[OK]
Nelder_Mead. : unable to evaluate scaled gradientModel failed to converge: degenerate Hessian with 1 negative eigenvalues[OK]
optimx.nlminb : Model is nearly unidentifiable: large eigenvalue ratio
- Rescale variables?[OK]
optimx.L-BFGS-B : unable to evaluate scaled gradientModel failed to converge: degenerate Hessian with 1 negative eigenvalues[OK]
nloptwrap.NLOPT_LN_NELDERMEAD : [ERROR]
nloptwrap.NLOPT_LN_BOBYQA : [ERROR]
nmkbw. : [ERROR]
$`bobyqa.`
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
Family: poisson ( log )
Formula: n_shreiberi ~ s.can_perc + s.can_n + s.time * s.temp + s.cloud_cover +
factor(burnt) + (1 | area) + offset(dat$s.duration)
Data: dat
AIC BIC logLik deviance df.resid
316.8412 336.1294 -149.4206 298.8412 54
Random effects:
Groups Name Std.Dev.
area (Intercept) 2.523
Number of obs: 63, groups: area, 8
Fixed Effects:
(Intercept) s.can_perc s.can_n s.time s.temp
-18.19816 -0.22152 0.45839 0.05239 -0.24983
s.cloud_cover factor(burnt)unburnt s.time:s.temp
-0.19691 17.92390 -0.13948
convergence code 0; 1 optimizer warnings; 0 lme4 warnings
$Nelder_Mead.
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
Family: poisson ( log )
Formula: n_shreiberi ~ s.can_perc + s.can_n + s.time * s.temp + s.cloud_cover +
factor(burnt) + (1 | area) + offset(dat$s.duration)
Data: dat
AIC BIC logLik deviance df.resid
316.8408 336.1290 -149.4204 298.8408 54
Random effects:
Groups Name Std.Dev.
area (Intercept) 2.524
Number of obs: 63, groups: area, 8
Fixed Effects:
(Intercept) s.can_perc s.can_n s.time s.temp
-19.29632 -0.22153 0.45840 0.05241 -0.24990
s.cloud_cover factor(burnt)unburnt s.time:s.temp
-0.19692 19.02091 -0.13949
convergence code 0; 2 optimizer warnings; 0 lme4 warnings
$optimx.nlminb
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
Family: poisson ( log )
Formula: n_shreiberi ~ s.can_perc + s.can_n + s.time * s.temp + s.cloud_cover +
factor(burnt) + (1 | area) + offset(dat$s.duration)
Data: dat
AIC BIC logLik deviance df.resid
316.8412 336.1294 -149.4206 298.8412 54
Random effects:
Groups Name Std.Dev.
area (Intercept) 2.523
Number of obs: 63, groups: area, 8
Fixed Effects:
(Intercept) s.can_perc s.can_n s.time s.temp
-18.23626 -0.22152 0.45839 0.05239 -0.24983
s.cloud_cover factor(burnt)unburnt s.time:s.temp
-0.19691 17.96199 -0.13948
convergence code 0; 1 optimizer warnings; 0 lme4 warnings
$`optimx.L-BFGS-B`
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
Family: poisson ( log )
Formula: n_shreiberi ~ s.can_perc + s.can_n + s.time * s.temp + s.cloud_cover +
factor(burnt) + (1 | area) + offset(dat$s.duration)
Data: dat
AIC BIC logLik deviance df.resid
316.8412 336.1294 -149.4206 298.8412 54
Random effects:
Groups Name Std.Dev.
area (Intercept) 2.524
Number of obs: 63, groups: area, 8
Fixed Effects:
(Intercept) s.can_perc s.can_n s.time s.temp
-18.23581 -0.22155 0.45841 0.05242 -0.24997
s.cloud_cover factor(burnt)unburnt s.time:s.temp
-0.19694 17.96246 -0.13943
convergence code 0; 2 optimizer warnings; 0 lme4 warnings
$nloptwrap.NLOPT_LN_NELDERMEAD
<simpleError in pwrssUpdate(pp, resp, tol = tolPwrss, GQmat = GQmat, compDev = compDev, grpFac = fac, maxit = maxit, verbose = verbose): Downdated VtV is not positive definite>
$nloptwrap.NLOPT_LN_BOBYQA
<simpleError in pwrssUpdate(pp, resp, tol = tolPwrss, GQmat = GQmat, compDev = compDev, grpFac = fac, maxit = maxit, verbose = verbose): Downdated VtV is not positive definite>
$nmkbw.
<simpleError in pwrssUpdate(pp, resp, tol = tolPwrss, GQmat = GQmat, compDev = compDev, grpFac = fac, maxit = maxit, verbose = verbose): Downdated VtV is not positive definite>
数据集可在此链接获得: https://www.dropbox.com/s/ud50uatztjq4bh9/20181217%20Surveys%20simplified%20data%20for%20stackX.xlsx?dl=0
在我看来,这些替代优化方法都没有成功;事实上,其中一些似乎引发了其他警告/错误,这会让我陷入另一个困境。
任何人都可以建议我如何在拟合这些模型方面取得进展吗?我的目的不是让这些成为最终模型,而是挖掘它们,然后从不同的替代子集模型中选择最优/顶级模型。
最佳答案
tl;dr 这看起来像是完全分离的情况;在你的“烧伤”状态下,你根本没有积极的结果。您不一定需要担心这一点 - AIC 比较应该仍然相当稳健 - 但您可能想在继续之前了解发生了什么。 GLMM FAQ 的相关部分讨论了这个问题(和补救措施) (在 CrossValidated 上有各种相关问题/答案)。
我怎么知道?以下是系数:
(Intercept) s.can_perc s.can_n s.time s.temp
-19.29632 -0.22153 0.45840 0.05241 -0.24990
s.cloud_cover factor(burnt)unburnt s.time:s.temp
-0.19692 19.02091 -0.13949
任何时候(二项式或泊松式)GLM 中的系数(绝对值)大于 8-10,您都必须担心(除非您正在查看以非常大的方式测量的数值协变量的系数单位,例如,如果您以十亿吨为单位查看后院的碳量)。这意味着预测变量的一个单位变化会导致对数赔率(例如)10 个单位的变化(对于二项式/logit 链接模型),例如从概率 0.006 (plogis(-5)
) 到 0.994 (plogis(5)
)。在您的情况下,截距为 -19.29,因此当所有预测变量的值都为零时,处于燃烧状态,您得到的概率为 4.2e-9。另一个巨大的系数用于 unburnt
(19.02),因此在未燃烧(未燃烧?)条件下所有预测变量的值为零时,您将得到 plogis(-19.29+19.02)
= 0.43。
关于r - lme4 glmer 中的缩放预测变量不会解决特征值警告;替代优化也没有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53834754/
我想做的是让 JTextPane 在 JPanel 中占用尽可能多的空间。对于我使用的 UpdateInfoPanel: public class UpdateInfoPanel extends JP
我在 JPanel 中有一个 JTextArea,我想将其与 JScrollPane 一起使用。我正在使用 GridBagLayout。当我运行它时,框架似乎为 JScrollPane 腾出了空间,但
我想在 xcode 中实现以下功能。 我有一个 View Controller 。在这个 UIViewController 中,我有一个 UITabBar。它们下面是一个 UIView。将 UITab
有谁知道Firebird 2.5有没有类似于SQL中“STUFF”函数的功能? 我有一个包含父用户记录的表,另一个表包含与父相关的子用户记录。我希望能够提取用户拥有的“ROLES”的逗号分隔字符串,而
我想使用 JSON 作为 mirth channel 的输入和输出,例如详细信息保存在数据库中或创建 HL7 消息。 简而言之,输入为 JSON 解析它并输出为任何格式。 最佳答案 var objec
通常我会使用 R 并执行 merge.by,但这个文件似乎太大了,部门中的任何一台计算机都无法处理它! (任何从事遗传学工作的人的附加信息)本质上,插补似乎删除了 snp ID 的 rs 数字,我只剩
我有一个以前可能被问过的问题,但我很难找到正确的描述。我希望有人能帮助我。 在下面的代码中,我设置了varprice,我想添加javascript变量accu_id以通过rails在我的数据库中查找记
我有一个简单的 SVG 文件,在 Firefox 中可以正常查看 - 它的一些包装文本使用 foreignObject 包含一些 HTML - 文本包装在 div 中:
所以我正在为学校编写一个 Ruby 程序,如果某个值是 1 或 3,则将 bool 值更改为 true,如果是 0 或 2,则更改为 false。由于我有 Java 背景,所以我认为这段代码应该有效:
我做了什么: 我在这些账户之间创建了 VPC 对等连接 互联网网关也连接到每个 VPC 还配置了路由表(以允许来自双方的流量) 情况1: 当这两个 VPC 在同一个账户中时,我成功测试了从另一个 La
我有一个名为 contacts 的表: user_id contact_id 10294 10295 10294 10293 10293 10294 102
我正在使用 Magento 中的新模板。为避免重复代码,我想为每个产品预览使用相同的子模板。 特别是我做了这样一个展示: $products = Mage::getModel('catalog/pro
“for”是否总是检查协议(protocol)中定义的每个函数中第一个参数的类型? 编辑(改写): 当协议(protocol)方法只有一个参数时,根据该单个参数的类型(直接或任意)找到实现。当协议(p
我想从我的 PHP 代码中调用 JavaScript 函数。我通过使用以下方法实现了这一点: echo ' drawChart($id); '; 这工作正常,但我想从我的 PHP 代码中获取数据,我使
这个问题已经有答案了: Event binding on dynamically created elements? (23 个回答) 已关闭 5 年前。 我有一个动态表单,我想在其中附加一些其他 h
我正在尝试找到一种解决方案,以在 componentDidMount 中的映射项上使用 setState。 我正在使用 GraphQL连同 Gatsby返回许多 data 项目,但要求在特定的 pat
我在 ScrollView 中有一个 View 。只要用户按住该 View ,我想每 80 毫秒调用一次方法。这是我已经实现的: final Runnable vibrate = new Runnab
我用 jni 开发了一个 android 应用程序。我在 GetStringUTFChars 的 dvmDecodeIndirectRef 中得到了一个 dvmabort。我只中止了一次。 为什么会这
当我到达我的 Activity 时,我调用 FragmentPagerAdapter 来处理我的不同选项卡。在我的一个选项卡中,我想显示一个 RecyclerView,但他从未出现过,有了断点,我看到
当我按下 Activity 中的按钮时,会弹出一个 DialogFragment。在对话框 fragment 中,有一个看起来像普通 ListView 的 RecyclerView。 我想要的行为是当
我是一名优秀的程序员,十分优秀!