【问题标题】:Incorrect number of theta components (!1)theta 分量的数量不正确 (!1)
【发布时间】:2019-07-17 17:25:31
【问题描述】:

我正在尝试做一个广义线性混合模型,毕竟返回一条消息,我的 theta 数不正确。

我正在尝试运行广义线性混合模型,我的变量是:

   fr fc          ed np      nnd ID_site RN_total_effort
4  15 34 0.006209597 13 748.4804      13            1344
9  13 81 0.004367510  3 306.6037      22             680
10 10 80 0.006039674  3 106.2123      25             680
11 15 50 0.011958544 13 792.4102      31             680
12 12 36 0.008262562 13 867.6111      35             680
13 16 75 0.006942968  4 686.7576      36             680

fr 是我的答案,(fcednpnnd)是我的解释变量。我正在使用 GLMER,ID_site 是我的随机因素。我也有不同努力的研究RN_total_effort,所以我用偏移来思考我的模型。这是我的代码。

m1_mist<-glmer(fr~fc+nnd+ed+np+(1|ID_site), offset(mist$RN_total_effort), family= poisson, data=mist)

运行后给出以下信息:

Error in glmer(fr ~ fc + nnd + ed + np + (1 | ID_site), offset(mist$RN_total_effort),  : 
  'control' is not a list; use glmerControl()

我用这个:

m1_mist<-glmer(fr~fc+nnd+ed+np+(1|ID_site), offset(mist$RN_total_effort), family= poisson, data=mist, control=glmerControl(optimizer="nloptwrap", optCtrl=list(maxfun=100000)))

然后返回:

Error in getStart(start, lower = rho$lower, pred = rho$pp, "theta") : 
  incorrect number of theta components (!=1)
Além disso: Warning message:
Some predictor variables are on very different scales: consider rescaling 

我重新调整了变量(ednnd)并再次运行:

m1_mist<-glmer(fr~fc+nndr+edr+np+(1|ID_site), offset(mist$RN_total_effort), family= poisson, data=mist, control=glmerControl(optimizer="nloptwrap", optCtrl=list(maxfun=100000)))

现在出现这条消息:

Error in getStart(start, lower = rho$lower, pred = rho$pp, "theta") : 
  incorrect number of theta components (!=1)

什么是错误?

【问题讨论】:

    标签: r lme4 mixed-models


    【解决方案1】:

    出现错误消息是因为偏移变量是作为位置参数提供的,而不是作为命名参数提供的。在示例中,无论是在control= 还是start= 参数的位置。 为避免此类错误,只需明确使用名称,同时提供参数,即

    glmer(..., offset = mist$RN_total_effort).

    或者,您可以将偏移量包含在公式中

    fr ~ fc+nndr+edr+np+(1|ID_site) + offset(RN_total_effort).

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-18
      相关资源
      最近更新 更多