# 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[2*n+1]:[3*n]

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

dI <-c(phi, rep(0,n-1)) - gamma*I - mu*I - a*I - LTFU*I

dT <-gamma*I + c(0, a[1:n] T[1:n-1]) - muT - a*T - LTFU*T

return(list(c(dI, dT)))

})

}