def __init__(self, therapy): # selected therapy self._therapy = therapy # simulation time step self._delta_t = Data.DELTA_T self._adjDiscountRate = Data.DISCOUNT * Data.DELTA_T # initial health state self._initialHealthState = HealthStats.WELL ##THIS IS CHECKED # cost treatment per preg if self._therapy == Therapies.BASELINE: self._annualTreatmentCost = 0 elif self._therapy == Therapies.SUPPLIES_NO_TRAINING: self._annualTreatmentCost = Data.COST_SUPPLIES elif self._therapy == Therapies.BETTER_TRAINING: self._annualTreatmentCost = Data.COST_TRAINING else: self._annualTreatmentCost = Data.COST_TRAINING + Data.COST_SUPPLIES # transition probability matrix of the selected therapy self._prob_matrix = [] self._continuous_matrix = [] # calculate transition probabilities depending of which therapy options is in use # if therapy == Therapies.BASELINE: # self._prob_matrix = Data.BASELINE_MATRIX # elif therapy == Therapies.SUPPLIES_NO_TRAINING: # self._prob_matrix = Data.SUPPLIES_NO_TRAINING_MATRIX # elif therapy == Therapies.BETTER_TRAINING: # self._prob_matrix = Data.BETTER_TRAINING_MATRIX # else: # self._prob_matrix = Data.BETTER_SUPPLIES_AND_TRAINING_MATRIX #checked above # calculate transition probabilities depending of which therapy options is in use if therapy == Therapies.BASELINE: self._continuous_matrix = SupportLibrary.discrete_to_continuous( Data.BASELINE_MATRIX, Data.DELTA_T) elif therapy == Therapies.SUPPLIES_NO_TRAINING: self._continuous_matrix = SupportLibrary.discrete_to_continuous( Data.SUPPLIES_NO_TRAINING_MATRIX, Data.DELTA_T) elif therapy == Therapies.BETTER_TRAINING: self._continuous_matrix = SupportLibrary.discrete_to_continuous( Data.BETTER_TRAINING_MATRIX, Data.DELTA_T) else: self._continuous_matrix = SupportLibrary.discrete_to_continuous( Data.BETTER_SUPPLIES_AND_TRAINING_MATRIX, Data.DELTA_T) self._prob_matrix, p = SupportLibrary.continuous_to_discrete( self._continuous_matrix, Data.DELTA_T) #annual state cvsots and utilities self._annualStateCosts = Data.HEALTH_COST self._annualStateUtilities = Data.HEALTH_UTILITY # adjusted discount rate self._adjDiscountRate = Data.DISCOUNT_RATE * Data.DELTA_T
def add_background_mortality(prob_matrix): # find the transition rate matrix rate_matrix = MarkovCls.discrete_to_continuous(prob_matrix, 1) # add mortality rates for s in HealthStats: if s not in [HealthStats.HIV_DEATH, HealthStats.BACKGROUND_DEATH]: rate_matrix[s.value][HealthStats.BACKGROUND_DEATH.value] \ = -np.log(1 - Data.ANNUAL_PROB_BACKGROUND_MORT) # convert back to transition probability matrix prob_matrix[:], p = MarkovCls.continuous_to_discrete(rate_matrix, Data.DELTA_T)
def add_background_mortality(prob_matrix): rate_matrix, p = MarkovCls.discrete_to_continuous(prob_matrix, 1) #add all cause mortality rates for s in HealthStats: if s not in [HealthStats.STROKEDEATH]: rate_matrix[s.value][HealthStats.value] \ = -np.log(1-Data.ANNUAL_ALL_CAUSE_MORT) # convert back to transition probability matrix prob_matrix = MarkovCls.continuous_to_discrete(rate_matrix, Data.DELTA_T) print ('All-Cause Mortality. Upper bound of the probabilty of two transitions within delta_t:', p)
def add_background_mortality(prob_matrix): # find the transition rate matrix rate_matrix = MarkovCls.discrete_to_continuous(prob_matrix, 1) # add mortality rates for s in HealthStats: # add background rates to non-death states (background mortality rate for death-state is assumed 0) if s not in [HealthStats.DEATH, HealthStats.BACKGROUND_DEATH]: rate_matrix[s.value][HealthStats.BACKGROUND_DEATH.value] = -np.log( 1 - Data.ANNUAL_PROB_BACKGROUND_MORT) # convert back to transition probability matrix prob_matrix[:], p = MarkovCls.continuous_to_discrete( rate_matrix, Data.DELTA_T) print('Upper bound on the probability of two transitions within delta_t:', p)