【发布时间】:2019-03-05 23:47:13
【问题描述】:
我正在尝试在 R 中运行游戏,但收到一条奇怪的错误消息。
一般来说,我有一些计数,每体积的水采样,我想通过这个计数来纠正。我正在尝试生成一个平滑函数,该函数适合作为深度函数的计数,考虑到采样体积的差异。
test <- structure(list(depth = c(2.5, 7.5, 12.5, 17.5, 22.5, 27.5, 32.5,
37.5, 42.5, 47.5, 52.5, 57.5, 62.5, 67.5, 72.5, 77.5, 82.5, 87.5,
92.5, 97.5), count = c(53323, 665, 1090, 491, 540, 514, 612,
775, 601, 497, 295, 348, 357, 294, 292, 968, 455, 148, 155, 101
), vol = c(2119.92, 111.76, 156.64, 71.28, 77.44, 73.92, 62.48,
78.32, 74.8, 81.84, 53.68, 80.96, 80.08, 79.2, 79.2, 77.44, 77.44,
84.48, 73.04, 59.84)), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -20L), .Names = c("depth", "count", "vol"
))
gam(count ~ s(depth) + offset(vol), data = test, family = "poisson")
Error in if (pdev - old.pdev > div.thresh) { : missing value where TRUE/FALSE needed
知道为什么这不起作用吗?如果我摆脱了偏移量,或者我设置了family = "gaussian",那么函数就会按预期运行。
编辑:我发现
gam(count ~ s(depth) + offset(log(vol)), data = test, family = "poisson")
确实运行了,我想我看到有人说想要为这些记录转换偏移变量,所以也许这实际上工作正常。
【问题讨论】: