Modelos epidemiológicos SIR. Aplicación en R (paquete deSolve)

Modelos epidemiológicos SIR


#The S-I-R epidemilogical disease model, for use with ode in the deSolve package.
N <- 10^3; I <- R <- 1; S <- N - I - R
parms <- c(B=.01, g=4)
months <- seq(0, 3, by=0.01)
require(deSolve)
SIR.out <- data.frame( ode(c(S,I,R), months, SIR, parms) )
matplot(months, SIR.out[,-1], type='l')
legend('right', c('R', 'I', 'S'), lty=3:1, col=3:1, bty='n')

#The S-I-R epidemilogical disease model with births and deaths (population dynamics), for use with ode in the deSolve package. This model uses mass action transmission.
library(deSolve)
N <- 10^6; R <- 0; I <- 1; S <- N - I - R
g <- 1/(13/365); b <- 1/50;
age <- 5; R0 <- 1 + 1/(b*age)
B <- R0 * (g + b) / N
parms <- c(B = B, g = g, b = b, m=b)
years <- seq(0,30, by=.1)
SIRbd.out <- data.frame(ode(c(S=S,I=I,R=R), years, SIRbd, parms, hmax=.01))
matplot(SIRbd.out[,1], sqrt(SIRbd.out[,-1]), type='l',
lty=1:3, ylab="sqrt(No. of Individuals)", xlab='Years')
legend('right', c('S','I','R'), lty=1:3, col=1:3, bty='n')

#The S-I-R epidemilogical disease model with frequency dependent transmission, for use with ode in the deSolve package.
R <- 0; S <- 1000; I <- 1000; N <- S+I+R
parmsf <- c(B=1, g=1)
Months <- seq(0, 8, by=0.1)
outf <- ode(c(S,I,R), Months, SIRf, parmsf)
matplot(Months, outf[,-1], type='l', ylab="Prevalence (I/N)")
legend('right', legend=c('S','I','R'), lty=1:3, col=1:3, bty='n')


Comentarios

  1. No me da los comendos directos en R, me lo podria pasar directo por favor?

    ResponderEliminar
  2. Puedes copiar y pegarlos en un archivo .R fácilmente.
    Saludos

    ResponderEliminar

Publicar un comentario