R/SIR.R

`SIR` <-
function (t, y, p) 
{
    {
        S <- y[1]
        I <- y[2]
        R <- y[3]
    }
    with(as.list(p), {
        dS.dt <- -B * I * S
        dI.dt <- B * I * S - g * I
        dR.dt <- g * I
        return(list(c(dS.dt, dI.dt, dR.dt)))
    })
}

Try the primer package in your browser

Any scripts or data that you put into this service are public.

primer documentation built on May 29, 2017, 11:26 p.m.