43.9 Conditional Distribution Sampling
Typically, a distribution is sampled normally to determine a time-to-event value for a specific patient. However, there are cases where DES models require additional control over distribution sampling beyond the standard sampling rates. Use of a TableProb distribution for background mortality is a good example where you would need conditional distribution sampling.
Consider the DES Tutorial Example model, TableProb Distribution.trex from the prior section. The starting age for people in that model is 40. We don't want the TableProb distribution to generate any age of background death values less than 40 because the patients have already lived to 40. Therefore, we need to use conditional sampling to determine the age of death given the condition that the person already lived to 40.
The syntax for conditional sampling has two forms.
-
DistSampleCond( distribution_index; lower_bound)
-
DistSampleCond( distribution_index; lower_bound; upper_bound)
When you issue a the DistSampleCond command it generates a new sample. Be careful about calling this function too many times and resampling a distribution inappropriately.
The DES Tutorial Example model TableProb Distribution - Standard vs. Conditional Sampling.trex demonstrates the difference between standard sampling and conditional sampling. The histogram for standard sampling is repeated here from the prior section.
The histogram for conditional sampling is then shown below.
You can see that no samples are generated that do not meet the condition of being 40 or older.
Now let's examine the more complete DES Tutorial Example model DES.Model.With.RepeatingEvents.trex which considers background mortality at both the Mild and Severe states. The figure below shows the Mild Time node with the variable Time_BackgroundDeath representing the time to death from background mortality.
The variable Time_BackgroundDeath is defined as:
-
Time_BackgroundDeath = t_Age_BackgroundDeath - age
-
where the tracker t_age_BackgroundDeath = DistSampleCond(5; startAge) is set for each treatment and
-
where age = startAge + _time
There are two important considerations with these non-standard events.
First, the age of death from background mortality is defined by the distribution: Age_BackgroundMort. This distribution is sampled from a mortality table. It will return values between 0 and 105 depending on the probabilities in the mortality table (tMortBackground). In this model, our patients start at age 50, as defined by startAge = 50.
This model uses the DistSampleCond function. That function allows you to return a sample from a distribution where the value is conditional. Specifically, in this case the model starts at age 50 based on the startAge parameter. It would not make sense to sample an age of death earlier than 50, so the function DistSampleCond uses a lower bound of startAge to always return an age of death greater than 50.
Note that the DistSampleCond function is only called once per person and is stored in a tracker. If that function were placed in the time-to-event expression directly, the distribution would be resampled, which we don't want.
Second, time-to-event value needs to take into account time passing. In this model, once an event has occurred, a certain amount of time will have elapsed. In the case of background mortality, this is taken into account with the defintion Time_BackgroundDeath which subtracts the current age of the patient.
For example, if the age at death from conditional sampling is 75, then the time-to-event from starting age of 50 would be 25 years. Now let's assume that the person progresses to Severe 10 years later. Then the same expression would be the age at death 75 less the current age of 60, so the time to background would appropriately be 15 years.
