function(mu = rep(0, times = 100), upsilon = rep(0.1, times = 100), tau = rep(0.01, times = 100), view.plot = 0) { #program compute.proportions.active() # #Computes proportion sexually active given forces of mortality (mu) and #movement from inactive to active status (upsilon) and active to inactive #status (tau), for an hypothetical cohort. These vectors must have the #same length (but there is no check for this). Note that the force of new #infection, a competing decrement for the sexually active population, is #assumed equal to zero here before the model is initialized before the #epidemic begins. # x <- rep(0, length = length(mu)) names(x) <- 0:(length(x) - 1) y <- x x[1] <- 1000 y[1] <- 0 xd <- xy <- yd <- yx <- rep(0, times = length(mu)) for(i in 1:(length(x) - 1)) { xd[i] <- x[i] * (1 - exp( - (mu[i] + upsilon[i]))) * (mu[i]/(mu[i] + upsilon[i])) xy[i] <- x[i] * (1 - exp( - (mu[i] + upsilon[i]))) * (upsilon[i]/(mu[i] + upsilon[i])) yd[i] <- y[i] * (1 - exp( - (mu[i] + tau[i]))) * (mu[i]/(mu[i] + tau[i])) yx[i] <- y[i] * (1 - exp( - (mu[i] + tau[i]))) * (tau[i]/(mu[i] + upsilon[i])) x[i + 1] <- x[i] - (xd[i] + xy[i]) + yx[i] y[i + 1] <- y[i] - (yd[i] + yx[i]) + xy[i] } proportion.active <- y/(x + y) write.ascii(compute.proportions.active) proportion.active }