在R

时间:2019-07-17 13:41:18

标签: ode differential-equations

我想找到一组微分方程的稳态平衡状态。我希望在函数内部包含一些内容,以使ODE集可以收敛到稳定状态。

某些参数值会导致合理的解决方案,而其他参数值不会收敛于稳定性。请参见代码示例。

我尝试过“ hmax”。虽然语法适用于“ hmax = 1”或“ hmax = 2”,但ODE集合永远不会变得稳定。

seiitdr <- function(time, state, parameters) {

  with(as.list(c(state, parameters)), {

    dS <- + mu *(N) - ((beta * S * I)+(beta * S * IA))/(N)                                             - mu*S        
    dE <-  ((beta * S * I)+(beta * S * IA))/(N)      - sigma * E                                       - mu*E
    dI <-                                 (1-deltaA) * sigma * E          - rho * I                    - mu*I
    dIA <-                                deltaA * sigma * E - rho * IA                                - mu*IA
    # dD <-                                                       (1-omega) * rho * I - mu*D
    dR <-                                                                   rho * IA + omega * rho * I - mu*R    

    return(list(c(dS, dE, dI, dIA, dR)))
  })
}

### Set initital parameters
N = 5506000
S0 = N
E0 = 0
I0 = 1
IA0 = 0
R0 = 0

init       <- c(S = S0, E = E0, I = I0, IA = IA0,  R = R0)

### Set parameter estimates
deltaA = 0.55             #range: 0.37 – 0.74
sigma = 1/4.3             #range: 4.3 days-1 (CI: 2.3-8.6 days-1)
rho = 1/4.5               #range: 3 - 6
omega = 0.35              #range: 20-50%
mu = (44.2/1000)/365      #births per person per day

R0_analysis <- function(R0value, time){
  R_0 = R0value
  maxtime = time
  beta = (R_0*(rho+mu)*(sigma+mu))/sigma
  parameters <- c(beta = beta, rho = rho, sigma = sigma, omega = omega, deltaA = deltaA, mu = mu)
  RS <- runsteady(y = init, fun = seiitdr, parms = parameters,  times = c(0,maxtime),hmax = 1, stol = 0)
  steady <- attr(RS,'steady')
  RSvec <- data.frame(RS)
  RSvec[RSvec < 0 ] <- 0
  fin <- data.frame(insert(RSvec$y,ats = 1, values = c(R_0,steady)))
  row.names(fin) <- c("R0","steady", row.names(RSvec))
  #Compartments
  return(fin) 
}

R1 <- R0_analysis(1,100000000)
R1_1 <- R0_analysis(1.1,100000000)
R1_2 <- R0_analysis(1.2,100000)
R2 <- R0_analysis(2,10000000)
R2_1 <- R0_analysis(2.1,1000000)
R3 <- R0_analysis(3,10000000)
R4 <- R0_analysis(4,1000000)
R5 <- R0_analysis(5,10000) #not working!

我希望当R0等于或大于1时,所有解决方案都是稳定的。

0 个答案:

没有答案