Trying to create a deterministic mathematical model that models birth cohorts (i.e. people born in the same year are modelled individually). Expecting ageing to be exponential. Very new to R. I have adapted from published example but do not know if it is doing what I want it to.
function(times, state, parameters) {
a= c(1/diff(x), 0)
n=length(parameters$a)
x=exp(x)
I=state[1:n]
T=state[2n+1]:[3n]
with(as.list(c(state,parameters)),{
dI <-c(phi, rep(0,n-1)) - gammaI - muI - aI - LTFUI
dT <-gammaI + c(0, a[1:n]T[1:n-1]) - muT - aT - LTFU*T
return(list(c(dI, dT)))
})
}