Displaying 1 result from an estimated 1 matches for "scaled_recovery".
2007 Jun 06
3
Using odesolve to produce non-negative solutions
...cale the components that take the derivative negative
if (shat+S<0) {
shat_old <- shat
shat <- -1*S
scaled_transmission <- (shat/shat_old)*(beta*S*I/N)
ihat <- scaled_transmission - (death*I) - (recover*I)
}
if (ihat+I<0) {
ihat_old <- ihat
ihat <- -1*I
scaled_recovery <- (ihat/ihat_old)*(recover*I)
rhat <- scaled_recovery +(birth*(vax)) - (death*R)
}
if (rhat+R<0) {
rhat <- -1*R
}
nhat <- shat + ihat + rhat
if (nhat+N<0) {
nhat <- -1*N
}
## return derivatives
list(c(shat,ihat,rhat,nhat),c(0))
}