Skip to content

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

Description

@mcincam100

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
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions