我正在研究一个复杂的模型来研究人口动态。我收到了一些警告信息,但不知道为什么?我不知道这是否对解决办法有任何影响。
我在一个样本Lotka模型中复制同样的误差。请考虑这作为一个例子,它可能不符合实际的动力学模型。
(1)请你解释一下,如何消除这些警告?
(2)对产量有影响吗?
感谢您的阅读。以下是代码:
library(deSolve)
predpreyLV<-function(t,y,p){
N<-y[1]
P<-y[2]
with(as.list(p),{
dNdt<- r*N*(1-(N/1000))-a*P*N
dPdt<- -b*P+f*P*N
return(list(c(dNdt,dPdt)))
})
}
rootfun <- function (t,y,parms){
if (t>=200 && y[2]>130)
return (0)
else
return (1)
}
eventfun <- function (t,y,parms){
y[2] = y[2]*0.99
return (y)
}
r<-0.5; a<-0.01; f<-0.01; b<-0.2;
p<-c(r=r,a=a, b=b, f=f)
y0<-c(N=25, P=5)
times<-seq(0,500,0.01)
LV.out<-ode(y=y0,times,predpreyLV, p,method="lsodar",
rootfunc = rootfun, events = list(func=eventfun, time = seq(198,200,0.01)))我收到了以下警告,并需要了解为什么会发生这种情况:
*警告信息:
1:在校验事件(事件、时间、Yname、dllname、TRUE)中:并不是所有事件时间'events$time‘都在输出’time‘中,因此它们自动包括在内。
2:在校验事件(事件、时间、Yname、dllname、TRUE):一些时间步骤非常接近事件--在这些情况下只使用事件时间。
发布于 2020-01-10 07:29:02
一种方法是将这两个时间向量都舍入到所需的精度:
times <- round(seq(0,500,0.01), 2)
evtime <- round(seq(198,200,0.01), 2)
evtime %in% times ## check if all events are in 'times'
LV.out<-ode(y=y0,times,predpreyLV, p,method="lsodar",
rootfunc = rootfun, events = list(func=eventfun, time = evtime))
plot(LV.out)希望能帮上忙!
https://stackoverflow.com/questions/59674480
复制相似问题