0

Below is a parasite growth model:

Ni(a,t) represents the expected number of parasites of age a at time t

Ni(a, t) represents the expected number parasites of age a at time t, and ki(a, t) represents the killing effect, while PMF the multiplication factor. This is a discrete model as a equals 1, 2, 3.....48. Can anybody tell me how to implement this equation in R using difference equations? Many thanks for your support.

4

2 回答 2

2

这是我能用你提供的信息做的最好的事情。把我指向它的其余部分,我也许可以让它真正工作,因为我认为它会无限地重复。

 Ki <- function(a, t){ ## You need to actually define this properly
      return(1)
    }

    Ni <- function(a, t, PMF){
      if ((a %% 1 != 0)) stop("Only Takes Integer values of a")
      if ((t %% 1 != 0)) stop("Only Takes Integer values of t")

      if (a == 1){
        x = Ni(48, t-1, PMF)
        y = exp(-Ki(48,t-1))
        result = PMF * x * y
        return(result)
      }

      if (a > 1){
        x = Ni(a-1, t-1, PMF)
        y = exp(-Ki(a-1,t-1))
        result = x * y
        return(result)
      }
    }
于 2013-07-22T10:39:14.983 回答
0

您没有一组初始条件。一旦你得到了 N(a=1..48,t=1) 的 48 个初始值,你就可以从第二个方程计算 N(a=1,t=2),然后计算 N(a=2.. 48,t=2) 来自第一个方程。重复 t=3 以此类推。

你所拥有的是递推关系,而不是微分方程。正如我刚刚解释的那样,您逐步完成递归关系。

通过查看 N(t)-N(t-1)/dt 并求解,可以将其转换为微分方程组,但这是一项数学工作而不是编程工作。

于 2013-07-22T08:45:55.997 回答