def __init__(self, therapy):

        # selected therapy
        self._therapy = therapy

        # simulation time step
        self._delta_t = DELTA_T

        # calculate the adjusted discount rate
        self._adjDiscountRate = DISCOUNT * DELTA_T

        # initial health state
        self._initialHealthState = HealthStats.WELL

        # annual treatment cost
        if self._therapy == Therapies.STANDARD:
            self._annualTreatmentCost = ((TEST_COST * POP_SIZE * 0.13) /
                                         SIM_LENGTH)
        else:
            self._annualTreatmentCost = ((TEST_COST * POP_SIZE) / SIM_LENGTH)

        # transition probability matrix of the selected therapy
        self._prob_matrix = []
        if therapy == Therapies.STANDARD:
            self._prob_matrix[:], p = MarkovCls.continuous_to_discrete(
                standard_transition, DELTA_T)
        elif therapy == Therapies.POPULATION:
            self._prob_matrix[:], p = MarkovCls.continuous_to_discrete(
                population_transition, DELTA_T)

        # annual state costs and utilities
        self._annualStateCosts = []
        self._annualStateUtilities = []
예제 #2
0
    def __init__(self, therapy):


        # selected therapy
        self._therapy = therapy

        # simulation time step
        self._delta_t = DELTA_T

        # calculate the adjusted discount rate
        self._adjDiscountRate = DISCOUNT * DELTA_T

        # initial health state
        self._initialHealthState = HealthStats.WELL

        # annual treatment cost
        if self._therapy == Therapies.NONE:
            self._annualTreatmentCost = COST_NONE
        else:
            self._annualTreatmentCost = COST_ANTICOAG

         # transition probability matrix of the selected therapy
        self._prob_matrix = []
        if therapy == Therapies.NONE:
            self._prob_matrix[:], p = MarkovCls.continuous_to_discrete(problem1transmat, DELTA_T)
        elif therapy == Therapies.ANTICOAG:
            self._prob_matrix[:], p = MarkovCls.continuous_to_discrete(problem2transmat, DELTA_T)

        # annual state costs and utilities
        self._annualStateCosts = []
        self._annualStateUtilities = []
예제 #3
0
    def __init__(self, therapy):

        # selected therapy
        self._therapy = therapy

        # simulation time step
        self._delta_t = Data.DELTA_T

        # calculate the adjusted discount rate
        self._adjDiscountRate = Data.DISCOUNT * Data.DELTA_T

        # initial health state
        self._initialHealthState = HealthStats.WELL

        # annual treatment cost
        if self._therapy == Therapies.ASPIRIN:
            self._annualTreatmentCost = 10.0
        if self._therapy == Therapies.DABIGITRAN110:
            self._annualTreatmentCost = 3240
        if self._therapy == Therapies.DABIGITRAN150:
            self._annualTreatmentCost = 3240
        else:
            self._annualTreatmentCost = Data.WARFARIN_COST

        # transition rate matrix of the selected therapy
        self._rate_matrix = []
        self._prob_matrix = []
        # treatment relative risk
        self._treatmentRR = 0

        # calculate transition probabilities depending of which therapy options is in use
        if therapy == Therapies.ASPIRIN:
            self._rate_matrix = Data.TRANS_MATRIX_ASPIRIN
            # convert rate to probability
            self._prob_matrix[:], p = MarkovCls.continuous_to_discrete(
                self._rate_matrix, Data.DELTA_T)
        # print('Upper bound on the probability of two transitions within delta_t:', p)
        # calculate transition probabilities depending of which therapy options is in use
        if therapy == Therapies.DABIGITRAN110:
            self._rate_matrix = Data.TRANS_MATRIX_DABIGATRAN110
            # convert rate to probability
            self._prob_matrix[:], p = MarkovCls.continuous_to_discrete(
                self._rate_matrix, Data.DELTA_T)
        # print('Upper bound on the probability of two transitions within delta_t:', p)
        # calculate transition probabilities depending of which therapy options is in use
        if therapy == Therapies.DABIGITRAN150:
            self._rate_matrix = Data.TRANS_MATRIX_DABIGATRAN150
            # convert rate to probability
            self._prob_matrix[:], p = MarkovCls.continuous_to_discrete(
                self._rate_matrix, Data.DELTA_T)
        # print('Upper bound on the probability of two transitions within delta_t:', p)
        else:
            self._rate_matrix = Data.TRANS_MATRIX_WARFARIN
            self._prob_matrix[:], p = MarkovCls.continuous_to_discrete(
                self._rate_matrix, Data.DELTA_T)
        # print('Upper bound on the probability of two transitions within delta_t:', p)

        # annual state costs and utilities
        self._annualStateCosts = Data.ANNUAL_STATE_COST
        self._annualStateUtilities = Data.ANNUAL_STATE_UTILITY
    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

        # annual treatment cost
        if self._therapy == Therapies.NONE:
            self._annualTreatmentCost = 0
        if self._therapy == Therapies.ANTICOAG:
            self._annualTreatmentCost = Data.Anticoag_COST

        # transition probability matrix of the selected therapy
        self._prob_matrix = []
        # treatment relative risk
        self._treatmentRR = 0

        # calculate transition probabilities depending of which therapy options is in use
        if therapy == Therapies.NONE:
            self._prob_matrix[:], p = MarkovCls.continuous_to_discrete(
                Data.RATE_MATRIX, Data.DELTA_T)
        else:
            self._prob_matrix[:], p = MarkovCls.continuous_to_discrete(
                Data.RATE_ANTICOAG_MATRIX, Data.DELTA_T)

        self._annualStateCosts = Data.HEALTH_COST
        self._annualStateUtilities = Data.HEALTH_UTILITY
예제 #5
0
    def __init__(self, therapy):

                #initialize base class
        _Parameters.__init__(self,therapy)

        if therapy == Therapies.ANNUAL:
            self._rate_matrix = Data.TRANS_MATRIX
            self._prob_matrix[:], p = MarkovCls.continuous_to_discrete(self._rate_matrix, Data.DELTA_T)
        else:
            self._rate_matrix = Data.TRANS_MATRIX_SEMI
            self._prob_matrix[:], p = MarkovCls.continuous_to_discrete(self._rate_matrix, Data.DELTA_T)

        self._annualStateCosts = Data.ANNUAL_STATE_COST
        self._annualStateUtilities = Data.ANNUAL_STATE_UTILITY
    def __init__(self, therapy):

        # selected therapy
        self._therapy = therapy

        # simulation time step
        if self._therapy == Therapies.MONO:
            self._delta_t = Data.DELTA_T_G
        else:
            self._delta_t = Data.DELTA_T_GC

        # calculate the adjusted discount rate
        if self._therapy == Therapies.MONO:
            self._adjDiscountRate = Data.DISCOUNT * Data.DELTA_T_G
        else:
            self._adjDiscountRate = Data.DISCOUNT * Data.DELTA_T_GC

        # initial health state
        self._initialHealthState = HealthStats.ProgressFree

        # annual treatment cost
        if self._therapy == Therapies.MONO:
            self._annualTreatmentCost = 0
        else:
            self._annualTreatmentCost = Data.GC_COST

        # transition rate matrix of the selected therapy
        self._rate_matrix = []
        self._prob_matrix = []
        # treatment relative risk
        self._treatmentRR = 0

        # calculate transition probabilities depending of which therapy options is in use
        if therapy == Therapies.MONO:
            self._rate_matrix = Data.TRANS_MATRIX
            # convert rate to probability
            self._prob_matrix[:], p = MarkovCls.continuous_to_discrete(
                self._rate_matrix, Data.DELTA_T_G)
        # print('Upper bound on the probability of two transitions within delta_t:', p)
        else:
            self._rate_matrix = Data.TRANS_MATRIX_GC
            self._prob_matrix[:], p = MarkovCls.continuous_to_discrete(
                self._rate_matrix, Data.DELTA_T_GC)
        # print('Upper bound on the probability of two transitions within delta_t:', p)

        # annual state costs and utilities
        self._annualStateCosts = Data.MONTHLY_STATE_COST
        self._annualStateUtilities = Data.MONTHLY_STATE_Utility
예제 #7
0
def calculate_prob_matrix_with():
    prob_matrix = []
    # convert back to transition probability matrix, but more frequently, not use "1 year"
    prob_matrix[:], p = MarkovCls.continuous_to_discrete(
        Data.TRANS_MATRIX_WITH, Data.DELTA_T)

    return [prob_matrix, p]
    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
예제 #9
0
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)
예제 #11
0
def calculate_prob_matrix_anticoag():
    """ :returns transition probability matrix for disease under no therapy """

    # create an empty matrix populated with zeros
    anticoag_matrix = []
    for l in anticoag_matrix:
        anticoag_matrix.append[0] * len(l)

    # call the transition rate matrix
    rate_matrix = Data.ANTICOAG_MATRIX

    # convert to transition probability matrix
    anticoag_matrix[:], p = MarkovCls.continuous_to_discrete(
        rate_matrix=rate_matrix, delta_t=Data.DELTA_T)

    return anticoag_matrix
예제 #12
0
def add_background_mortality(prob_matrix):

    # find the transition rate matrix
    rate_matrix = Data.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.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)
    # print('Upper bound on the probability of two transitions within delta_t:', p)
    return prob_matrix
예제 #13
0
def calculate_prob_matrix_none():
    """ :returns transition probability matrix for disease under no therapy """

    # create an empty matrix populated with zeros
    prob_matrix = []
    for s in prob_matrix:
        prob_matrix.append[0] * len(s)

    # call the transition rate matrix
    rate_matrix = Data.TRANS_MATRIX

    # convert to transition probability matrix
    prob_matrix[:], p = MarkovCls.continuous_to_discrete(
        rate_matrix=rate_matrix, delta_t=Data.DELTA_T)

    return prob_matrix
예제 #14
0
    def __init__(self, therapy):

        # selected therapy
        self._therapy = therapy

        # simulation time step
        self._delta_t = Data.DELTA_T

        # calculate the adjusted discount rate
        self._adjDiscountRate = Data.DISCOUNT * Data.DELTA_T

        # initial health state
        self._initialHealthState = HealthStats.UNDETECTABLE

        # annual treatment cost
        if self._therapy == Therapies.NONE:
            self._annualTreatmentCost = 0
        else:
            self._annualTreatmentCost = Data.Anticoagulant_COST

        # transition rate matrix of the selected therapy
        self._rate_matrix = []
        self._prob_matrix = []
        # treatment relative risk
        self._treatmentRR = 0

        # calculate transition probabilities depending of which therapy options is in use
        if therapy == Therapies.NONE:
            self._rate_matrix = Data.TRANS_MATRIX
            # convert rate to probability
            self._prob_matrix[:], p = MarkovCls.continuous_to_discrete(
                self._rate_matrix, Data.DELTA_T)
        # print('Upper bound on the probability of two transitions within delta_t:', p)
        # else:
        # self._rate_matrix = Data.TRANS_MATRIX_ANTICOAG
        # self._prob_matrix[:], p = MarkovCls.continuous_to_discrete(self._rate_matrix, Data.DELTA_T)
        # print('Upper bound on the probability of two transitions within delta_t:', p)

        # annual state costs and utilities
        self._annualStateCosts = Data.ANNUAL_STATE_COST
        self._annualStateUtilities = Data.ANNUAL_STATE_UTILITY
예제 #15
0
from enum import Enum
import Question2 as matrixdatat

delta_t = 0.25
Discount_Rate = 0.03

rate_matrix_wotherapy = [[
    None, matrixdata.lambda1, 0, matrixdata.lambda2,
    matrixdata.non_stroke_deathrate
], [0, None, matrixdata.rate_stroke_post, 0, 0],
                         [
                             0, matrixdata.rate_poststr_stroke, None,
                             matrixdata.rate_poststr_strokedeath,
                             matrixdata.non_stroke_mortality
                         ], [0, 0, 0, None, 0], [0, 0, 0, 0, None]]
prob_matrixwotherapy = MarkovCls.continuous_to_discrete(
    rate_matrix_wotherapy, delta_t)

rate_matrix_wtherapy = [[
    None, matrixdata.lambda1, 0, matrixdata.lambda2,
    matrixdata.non_stroke_deathrate
], [0, None, matrixdata.rate_stroke_post, 0, 0],
                        [
                            0, matrixdatat.rate_poststr_stroke_withtherapy,
                            None, matrixdata.rate_poststr_strokedeath,
                            matrixdatat.therapy_non_stroke_deathrate
                        ], [0, 0, 0, None, 0], [0, 0, 0, 0, None]]
prob_matrixwtherapy = MarkovCls.continuous_to_discrete(rate_matrix_wtherapy,
                                                       delta_t)

TRANS = [prob_matrixwotherapy[0], prob_matrixwtherapy[0]]
예제 #16
0
import scr.MarkovClasses as MarkovCls

POP_SIZE = 2000     # cohort population size
SIM_LENGTH = 15   # length of simulation (years)
ALPHA = 0.05        # significance level for calculating confidence intervals
DELTA_T = 0.25         # years (length of time step, how frequently you look at the patient)
DISCOUNT = 0.03     # annual discount rate

# transition matrix

TRANS_MATRIX=[[None,TM.srroke_afterfirst,0,TM.death_afterfirst,TM.non_stroke_deathrate],
              [0,None,TM.rate_post_stroke,0,0],
              [0,TM.rate_poststr_stroke,None,TM.rate_poststr_strokedeath,TM.non_stroke_mortality],
              [0,0,0,None,0],
              [0,0,0,0,None]]
Prob_TransMatrix_None=MarkovCls.continuous_to_discrete(TRANS_MATRIX,DELTA_T)


TRANS_MATRIX_COMBO=[[None,TM.srroke_afterfirst,0,TM.death_afterfirst,TM.non_stroke_deathrate],
                    [0,None,TM.rate_post_stroke,0,0],
                    [0,TM.rate_poststr_stroke_withtherapy,None,TM.rate_poststr_strokedeath,TM.therapy_non_stroke_deathrate],
                    [0,0,0,None,0],
                    [0,0,0,0,None]]
Prob_TransMatrix_Anti=MarkovCls.continuous_to_discrete(TRANS_MATRIX_COMBO,DELTA_T)


# annual health utility of each health state
ANNUAL_STATE_UTILITY = [
    1.00,   # Well
    0.20,   # Stroke
    0.90,    # Post-Stroke
예제 #17
0
파일: HW11.py 프로젝트: landuan/HW11
                        [None,Stroke_Survive,0,Stroke_Death,Non_Stroke_Mort],
                        [0,None,Post_Stroke_Survive,0,0],
                        [0,Post_Stroke_Survive,None,Post_Stroke_Survive,Non_Stroke_Mort],
                        [0,0,0,None,0],
                        [0,0,0,0,None]
    ]

Drug_Matrix = [
                        [None,Stroke_Survive,0,Stroke_Death,Non_Stroke_Mort],
                        [0,None,Post_Stroke_Survive,0,0],
                        [0,Drug_Post_Stroke,None,Drug_Post_Stroke,Drug_Non_Stroke_Mort],
                        [0,0,0,None,0],
                        [0,0,0,0,None]
    ]

Prob_Non_Drug_Matrix = MarkovCls.continuous_to_discrete(No_Drug_Matrix,delta_t)
Prob_Drug_Martix     = MarkovCls.continuous_to_discrete(Drug_Matrix,delta_t)


HEALTH_UTILITY = [
    1,  # well
    0.2,  # stroke
    0.9,  # post-stroke
    0  # dead
]

HEALTH_COST = [
    0,
    5000,  # stroke - one time cost
    200,  # post-stroke /year
    750, # when anticoagulation is used
예제 #18
0
RATE_MATRIX = [
    [0, lambda1, 0, lambda2, rate_non_stroke_mortality],
    [0, 0, lambda5, 0, 0],
    [0, lambda3, 0, lambda4, rate_non_stroke_mortality],
    [0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0]
]

print("")
print("Rate matrix for anticoagulation therapy")
print(RATE_MATRIX[0])
print(RATE_MATRIX[1])
print(RATE_MATRIX[2])
print(RATE_MATRIX[3])
print(RATE_MATRIX[4])

DELTA_T = 0.25

print("")
print("DELTA_T =", DELTA_T)
print("")
print("Transform rate matrix to transition probability matrix")

TRANS_MATRIX_ANTICOAG = []
TRANS_MATRIX_ANTICOAG[:], T = MarkovCls.continuous_to_discrete(RATE_MATRIX, DELTA_T)
print(TRANS_MATRIX_ANTICOAG[0],",")
print(TRANS_MATRIX_ANTICOAG[1],",")
print(TRANS_MATRIX_ANTICOAG[2],",")
print(TRANS_MATRIX_ANTICOAG[3],",")
print(TRANS_MATRIX_ANTICOAG[4])
    def get_discrete_prob_matrix(self):
            # convert back to transition probability matrix
        self._prob_matrix[:], p = MarkovCls.continuous_to_discrete(self._prob_matrix, Data.DELTA_T)

        print('Upper bound on the probability of two transitions within delta_t:', p)
예제 #20
0
    def simulate_fiveshort(self, sim_length_short):
        """ simulate the patient over the specified simulation length """

        # random number generator for this patient
        self._rng = rndClasses.RNG(self._id)


        if self.vaccine==0:
            k=0
            # while the patient is alive and simulation length is not yet reached
            while (self.healthstat != 8) and k * ma.delta_t < sim_length_short:
                # find the transition probabilities of the future states
                trans_probs = ma.prob_matrix[0][self.healthstat]
                # create an empirical distribution
                empirical_dist = rndClasses.Empirical(trans_probs)
                # sample from the empirical distribution to get a new state
                # (returns an integer from {0, 1, 2, ...})
                new_state_index = empirical_dist.sample(self._rng)
                # caculate cost and utality
                cost = ma.cost_matrix[self.healthstat] + ma.salary * ma.work_loss_day[self.healthstat]
                utility = ma.utility_matrix[self.healthstat] * ma.delta_t
                # update total discounted cost and utility (corrected for the half-cycle effect)
                self.totalDiscountCost += \
                    EconCls.pv(cost, ma.discount_rate * ma.delta_t, k + 1)
                self.totalDiscountUtility += \
                    EconCls.pv(utility, ma.discount_rate * ma.delta_t, k + 1)
                # update diseases:
                if self.healthstat==HealthStats.Pneumoniae.value:
                    self.pneumonaie+=1
                if self.healthstat==HealthStats.Meningitis.value:
                    self.meningitis+=1
                if self.healthstat==HealthStats.AOM_T.value or self.healthstat==HealthStats.AOM_NT.value:
                    self.aom+=1
                # update disability number
                if self.healthstat == HealthStats.Disability.value:
                    self._ndisability = 1
                # update deafness number
                if self.healthstat == HealthStats.Deaf.value :
                    self._ndeaf = 1
                # update health state
                self.healthstat = new_state_index[0]
                #update number of deahts
                if self.healthstat==HealthStats.DEATH.value:
                    self._ndeath=1
                # increment time step
                k += 1
        if self.vaccine==1:
            k=0
            while (self.healthstat!=8) and k * ma.delta_t<sim_length_short:
                new_rate_matrix=gen_vaccine_prob_matrix(self.shot)
                prob_matrixm = MarkovCls.continuous_to_discrete(new_rate_matrix, ma.delta_t)
                trans_probsm = prob_matrixm[0][self.healthstat]
                empirical_dist = rndClasses.Empirical(trans_probsm)
                new_state_index = empirical_dist.sample(self._rng)
                cost = ma.cost_matrix[self.healthstat] + ma.salary * ma.work_loss_day[self.healthstat]
                utility = ma.utility_matrix[self.healthstat] * ma.delta_t
                self.totalDiscountCost += \
                    EconCls.pv(cost, ma.discount_rate * ma.delta_t, k + 1)
                self.totalDiscountUtility += \
                    EconCls.pv(utility, ma.discount_rate * ma.delta_t, k + 1)
                # update disability number
                if self.healthstat == HealthStats.Disability.value:
                    self._ndisability = 1
                # update deafness number
                if self.healthstat == HealthStats.Deaf.value:
                    self._ndeaf = 1
                # update diseases:
                if self.healthstat==HealthStats.Pneumoniae.value:
                    self.pneumonaie+=1
                if self.healthstat==HealthStats.Meningitis.value:
                    self.meningitis+=1
                if self.healthstat==HealthStats.AOM_T.value or self.healthstat==HealthStats.AOM_NT.value:
                    self.aom+=1

                print(self.healthstat)
                self.healthstat = new_state_index[0]
                #update number of deaths
                if self.healthstat==HealthStats.DEATH.value:
                    self._ndeath=1

                if k==3:
                    self.shot+=1
                    self.totalDiscountCost+= \
                        EconCls.pv(ma.vaccine_administration+ma.vaccine_cost, ma.discount_rate * ma.delta_t, k + 1)
                if k==5:
                    self.shot+=1
                    self.totalDiscountCost+= \
                        EconCls.pv(ma.vaccine_administration+ma.vaccine_cost, ma.discount_rate * ma.delta_t, k + 1)
                if k==11:
                    self.shot+=1
                    self.totalDiscountCost+= \
                        EconCls.pv(ma.vaccine_administration+ma.vaccine_cost, ma.discount_rate * ma.delta_t, k + 1)

                # increment time step
                k += 1
예제 #21
0
                   rate_pneumoniae_to_recovery, None, 0, 0, 0, 0, 0, 0,
                   rate_pneumoniae_to_death
               ],
               [
                   rate_meningitis_to_recovery, 0, None,
                   rate_memingitis_to_disability, rate_memingitis_to_deafness,
                   0, 0, 0, rate_meningitis_to_death
               ], [0, 0, 0, None, 0, 0, 0, 0, 0],
               [0, 0, 0, 0, None, 0, 0, 0, 0],
               [
                   rate_bacteremia_to_recovery, 0, 0, 0, 0, None, 0, 0,
                   rate_bacteremia_to_death
               ], [rate_aom_to_recovery, 0, 0, 0, 0, 0, None, 0, 0],
               [rate_aom_to_recovery, 0, 0, 0, 0, 0, 0, None, 0],
               [0, 0, 0, 0, 0, 0, 0, 0, None]]
prob_matrix = MarkovCls.continuous_to_discrete(rate_matrix, delta_t)
print(prob_matrix)

cost_matrix = [0, 652, 3851, 0, 0, 2863, 119, 357, 0]

utility_matrix = [1, 0.9941, 0.9768, 0.7393, 0.8611, 0.9941, 0.995, 0.82, 0]

work_loss_day = [
    0, worklossday_pneumoniae, worklossday_meningitis, 0, 0,
    worklossday_bacteremia, worklossday_aom, worklossday_aom, 0
]

salary = 30

cohort_size = 200000
예제 #22
0
print("Annual rate of transition from stroke to post-stroke (lambda5):",
      lambda5)

RATE_MATRIX = [[0, lambda1, 0, lambda2, rate_non_stroke_mortality],
               [0, 0, lambda5, 0, 0],
               [0, lambda3, 0, lambda4, rate_non_stroke_mortality],
               [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]

print("")
print("Rate matrix for no therapy")
print(RATE_MATRIX[0])
print(RATE_MATRIX[1])
print(RATE_MATRIX[2])
print(RATE_MATRIX[3])
print(RATE_MATRIX[4])

DELTA_T = 0.25

print("")
print("DELTA_T =", DELTA_T)
print("")
print("Transform rate matrix to transition probability matrix")

TRANS_MATRIX = []
TRANS_MATRIX[:], S = MarkovCls.continuous_to_discrete(RATE_MATRIX, DELTA_T)
print(TRANS_MATRIX[0], ",")
print(TRANS_MATRIX[1], ",")
print(TRANS_MATRIX[2], ",")
print(TRANS_MATRIX[3], ",")
print(TRANS_MATRIX[4])