Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating age and age bins in continuous-time simulation #113

Open
mcincam100 opened this issue Dec 1, 2023 · 0 comments
Open

Updating age and age bins in continuous-time simulation #113

mcincam100 opened this issue Dec 1, 2023 · 0 comments

Comments

@mcincam100
Copy link

Any progress on implementing ways to update age in a continuous time model? In my case I am modeling criminal justice trajectories, and the transition hazards vary over age bands (12-17 yo, 18-24 yo, etc.). Thus in my simulation I should have people transitioning between age bins, and therefore experiencing different hazards, as the time progresses. Can this be done now in hesim? I am thinking of something like this, but wanted to check if there have been any new functions that you've experimented with:

Update age and age category

for (i in seq_len(nrow(patients))) {
sojourn_time <- data[i, "Tstop"] - data[i, "Tstart"] # Calculate sojourn time
patients[i, "age"] <- patients[i, "age"] + sojourn_time
patients[i, "age_category"] <- cut(patients[i, "age"], breaks = age_categories, labels = FALSE, right = FALSE)

#Check if age has reached max_age
if (patients[i, "age"] >= max_age) {
break # Stop the simulation for this patient
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant