r语言 - 重新排列数据以拟合事件时模型时出错



我有平均发芽数据(3 个重复的 n=50 颗种子(,我正在重新排列这些数据以拟合 R 包 DRC 中的事件时间模型(Ritz 等人,2013 年(。我的一些计数变为负数,我认为这就是为什么当我尝试使用 drm 功能时出现错误的原因。为什么计数为负数,这是我的 drm 错误背后的问题吗?

使用繁缕数据集似乎工作正常。

library(drc)
# Data
time<-c(6, 19, 33, 47, 62, 75, 89)
count<-c(0, 1.66, 3.33, 1.33, 0, 0, 0)
data<-data.frame(time, count)
#From Ritz (2013)
germ <- data.frame(start = c(0, data$time), end = c(data$time, Inf)) 
germ$count <- c(0, diff(data$count), 50 - tail(data$count, 1))
head(germ)
tail(germ)
## Fitting the event-time model (by specifying the argument type explicitly)
germ.m1 <- drm(count~start+end, data = germ, fct = LL.3(), type = "event")
summary(germ.m1)

我预计所有计数都是积极的,但有几个是负面的。任何帮助都非常感谢!

我不知道这个问题,但我确实找到了一个简单的(但也许是笨拙的(解决方案。

# Same as in question
germ <- data.frame(start = c(0, data$time), end = c(data$time, Inf))
# Substitute for germ$count from question
cnt <- c(data$count) # cnt = count
rem<-50-sum(data$count) # 50 = number of seeds sown; 
                        # rem = remainder(# of seeds that did not germinate)
germ$count<-c(cnt, rem)

通过这种解决方法,计数全部为正数,模型已安装!!

最新更新