You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用ZIBR包拟合零膨胀β-二项式模型时遇报错求助

ZIBR包拟合零膨胀β-二项式模型报错:missing value where TRUE/FALSE needed

我正在用ZIBR包分析行为数据,拟合零膨胀β-二项式模型,数据取值范围为[0,1),目的是探究三个试验中不同物种个体在水箱白色区域停留时间占比的差异。

数据子集与代码示例

df <-
  structure(
    list(
      fishID = c(
        "fish1","fish1","fish1", "fish105","fish105","fish105","fish106", "fish106","fish106","fish12","fish12",
        "fish12","fish16","fish16","fish16", "fish17","fish17","fish17","fish18","fish18","fish18"
      ),
      species = c(
        "melasma","melasma","melasma","prasites","prasites","prasites","prasites","prasites","prasites","teresae",
        "teresae","teresae","melasma","melasma","melasma","teresae","teresae","teresae","teresae","teresae",
        "teresae"
      ),
      whiteprop = c(
        0.482938889,0,0,0,0.028264444,0,0.101271111,0.113006667,0.031126667,0.274194444,0.521831111,0.369093333,
        0.121565556,0.230355556,0,0,0,0,0.020068889,0,0
      ),
      time = c(1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3,
               1, 2, 3, 1, 2, 3)
    ),
    row.names = c(NA,-21L),
    class = c("tbl_df",
              "tbl", "data.frame")
  )


zibr_fit <- zibr(
  logistic_cov = df$species, beta_cov = df$species, Y = df$whiteprop,
  subject_ind = df$fishID, time_ind = df$time
)

报错信息

Error in if (nrow(logistic_cov) != nrow(Y) || nrow(beta_cov) != nrow(Y)) { :
missing value where TRUE/FALSE needed

我已确认数据框无缺失值、各列长度一致,且代码中单独运行每个组件均正常,恳请各位提供解决思路!


内容的提问来源于stack exchange,提问作者Madison

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 22:03:13