Пример #1
0
def print_comparative_outcomes(multi_cohort_outcomes_no, multi_cohort_outcomes_asp):
    """ prints average increase in survival time, discounted cost, and discounted utility
    under combination therapy compared to mono therapy
    :param multi_cohort_outcomes_mono: outcomes of a multi-cohort simulated under mono therapy
    :param multi_cohort_outcomes_combo: outcomes of a multi-cohort simulated under combination therapy
    """

    # increase in mean survival time under combination therapy with respect to mono therapy
    increase_mean_survival_time = Stat.DifferenceStatPaired(
        name='Increase in mean survival time',
        x=multi_cohort_outcomes_asp.meanSurvivalTimes,
        y_ref=multi_cohort_outcomes_no.meanSurvivalTimes)

    # estimate and PI
    estimate_PI = increase_mean_survival_time.get_formatted_mean_and_interval(interval_type='p',
                                                                              alpha=D.ALPHA,
                                                                              deci=2)
    print("Increase in mean survival time and {:.{prec}%} uncertainty interval:"
          .format(1 - D.ALPHA, prec=0),
          estimate_PI)

    # increase in mean discounted cost under combination therapy with respect to mono therapy
    increase_mean_discounted_cost = Stat.DifferenceStatPaired(
        name='Increase in mean discounted cost',
        x=multi_cohort_outcomes_asp.meanCosts,
        y_ref=multi_cohort_outcomes_no.meanCosts)

    # estimate and PI
    estimate_PI = increase_mean_discounted_cost.get_formatted_mean_and_interval(interval_type='p',
                                                                                alpha=D.ALPHA,
                                                                                deci=2,
                                                                                form=',')
    print("Increase in mean discounted cost and {:.{prec}%} uncertainty interval:"
          .format(1 - D.ALPHA, prec=0),
          estimate_PI)

    # increase in mean discounted QALY under combination therapy with respect to mono therapy
    increase_mean_discounted_qaly = Stat.DifferenceStatPaired(
        name='Increase in mean discounted QALY',
        x=multi_cohort_outcomes_asp.meanQALYs,
        y_ref=multi_cohort_outcomes_no.meanQALYs)

    # estimate and PI
    estimate_PI = increase_mean_discounted_qaly.get_formatted_mean_and_interval(interval_type='p',
                                                                                alpha=D.ALPHA,
                                                                                deci=2)
    print("Increase in mean discounted utility and {:.{prec}%} uncertainty interval:"
          .format(1 - D.ALPHA, prec=0),
          estimate_PI)
Пример #2
0
    def calculate_summary_stats(self):
        """
        calculate the summary statistics
        """
        # summary statistics of mean cost
        self.statMeanPCost = Stat.SummaryStat(name='Average Palivizumab cost',
                                              data=self.PCosts)
        # summary statistics of mean QALY
        self.statMeanPQALY = Stat.SummaryStat(name='Average Palivizumab QALY',
                                              data=self.PQALYs)

        self.statMeanNCost = Stat.SummaryStat(
            name='Average no prophylaxis cost', data=self.NCosts)
        # summary statistics of mean QALY
        self.statMeanNQALY = Stat.SummaryStat(
            name='Average no prophylaxis QALY', data=self.NQALYs)
Пример #3
0
def print_comparative_outcomes(sim_outcomes_amino, sim_outcomes_immuno):
    """ prints average increase in survival time, discounted cost, and discounted utility
    under immunosuppresive therapy compared to aminosalicylate therapy
    :param sim_outcomes_amino: outcomes of a cohort simulated under mono therapy
    :param sim_outcomes_immuno: outcomes of a cohort simulated under combination therapy
    """

    # increase in mean survival time under immuno therapy with respect to amino therapy
    increase_survival_time = Stat.DifferenceStatIndp(
        name='Increase in mean survival time',
        x=sim_outcomes_immuno.survivalTimes,
        y_ref=sim_outcomes_amino.survivalTimes)

    # estimate and CI
    estimate_CI = increase_survival_time.get_formatted_mean_and_interval(
        interval_type='c', alpha=D.ALPHA, deci=2)
    print(
        "Increase in mean survival time and {:.{prec}%} confidence interval:".
        format(1 - D.ALPHA, prec=0), estimate_CI)

    # increase in mean discounted cost under immuno therapy with respect to amino therapy
    increase_discounted_cost = Stat.DifferenceStatIndp(
        name='Increase in mean discounted cost',
        x=sim_outcomes_immuno.costs,
        y_ref=sim_outcomes_amino.costs)

    # estimate and CI
    estimate_CI = increase_discounted_cost.get_formatted_mean_and_interval(
        interval_type='c', alpha=D.ALPHA, deci=2, form=',')
    print(
        "Increase in mean discounted cost and {:.{prec}%} confidence interval:"
        .format(1 - D.ALPHA, prec=0), estimate_CI)
    #
    # increase in number of patients alive under immuno therapy with respect to amino therapy
    increase_patients_alive = Stat.DifferenceStatIndp(
        name='Increase in mean number of patients alive',
        x=sim_outcomes_immuno.numPatientsAlive,
        y_ref=sim_outcomes_amino.numPatientsAlive)

    # estimate and CI
    estimate_CI = increase_patients_alive.get_formatted_mean_and_interval(
        interval_type='c', alpha=D.ALPHA, deci=2)
    print(
        "Increase in mean number of patients alive and {:.{prec}%} confidence interval:"
        .format(1 - D.ALPHA, prec=0), estimate_CI)
Пример #4
0
def mytest_discrete_time(data):
    # define a discrete-time statistics
    discrete_stat = Stat.DiscreteTimeStat('Test discrete-time statistics')
    # record data points
    for point in data:
        discrete_stat.record(point)

    print('Testing discrete-time statistics:')
    print_results(discrete_stat)
Пример #5
0
def print_comparative_outcomes(sim_outcomes_SOC, sim_outcomes_NSB):
    """
    :param sim_outcomes_SOC: outcomes of a cohort simulated under SOC diagnostics
    :param sim_outcomes_NSB: outcomes of a cohort simulated under NSB diagnostics
    """

    # increase in mean survival time under combination therapy with respect to mono therapy
    increase_survival_time = Stat.DifferenceStatIndp(
        name='Increase in mean survival time',
        x=sim_outcomes_combo.survivalTimes,
        y_ref=sim_outcomes_mono.survivalTimes)

    # estimate and CI
    estimate_CI = increase_survival_time.get_formatted_mean_and_interval(
        interval_type='c', alpha=D.ALPHA, deci=2)
    print(
        "Increase in mean survival time and {:.{prec}%} confidence interval:".
        format(1 - D.ALPHA, prec=0), estimate_CI)

    # increase in mean discounted cost under combination therapy with respect to mono therapy
    increase_discounted_cost = Stat.DifferenceStatIndp(
        name='Increase in mean discounted cost',
        x=sim_outcomes_combo.costs,
        y_ref=sim_outcomes_mono.costs)

    # estimate and CI
    estimate_CI = increase_discounted_cost.get_formatted_mean_and_interval(
        interval_type='c', alpha=D.ALPHA, deci=2, form=',')
    print(
        "Increase in mean discounted cost and {:.{prec}%} confidence interval:"
        .format(1 - D.ALPHA, prec=0), estimate_CI)

    # increase in mean discounted utility under combination therapy with respect to mono therapy
    increase_discounted_utility = Stat.DifferenceStatIndp(
        name='Increase in mean discounted utility',
        x=sim_outcomes_combo.utilities,
        y_ref=sim_outcomes_mono.utilities)

    # estimate and CI
    estimate_CI = increase_discounted_utility.get_formatted_mean_and_interval(
        interval_type='c', alpha=D.ALPHA, deci=2)
    print(
        "Increase in mean discounted utility and {:.{prec}%} confidence interval:"
        .format(1 - D.ALPHA, prec=0), estimate_CI)
Пример #6
0
    def extract_outcomes(self, simulated_patients):
        for patient in simulated_patients:
            if not (patient.stateMonitor.survivalTime is None):
                self.survivalTimes.append(patient.stateMonitor.survivalTime)
            self.costs.append(
                patient.stateMonitor.costUtilityMonitor.totalDiscountedCost)
            self.utilities.append(
                patient.stateMonitor.costUtilityMonitor.totalDiscountedUtility)

        self.statSurvivalTime = Stat.SummaryStat('Survival time',
                                                 self.survivalTimes)
        self.statCost = Stat.SummaryStat('Discounted cost', self.costs)
        self.statUtility = Stat.SummaryStat('Discounted utility',
                                            self.utilities)

        self.nLivingPatients = Path.PrevalencePathBatchUpdate(
            name='# of living patients',
            initial_size=len(simulated_patients),
            times_of_changes=self.survivalTimes,
            increments=[-1] * len(self.survivalTimes))
Пример #7
0
def print_comparative_outcomes(sim_outcomes_NO, sim_outcomes_ASP):

    # increase in mean survival time under therapy with respect to no therapy
    decrease_survival_time = Stat.DifferenceStatIndp(
        name='Increase in mean survival time',
        x=sim_outcomes_ASP.survivalTimes,
        y_ref=sim_outcomes_NO.survivalTimes)

    # estimate and CI
    estimate_CI = decrease_survival_time.get_formatted_mean_and_interval(
        interval_type='c', alpha=D.ALPHA, deci=2)
    print(
        "Increase in mean survival time and {:.{prec}%} confidence interval:".
        format(1 - D.ALPHA, prec=0), estimate_CI)

    # increase in mean discounted cost under therapy with respect to no therapy
    increase_discounted_cost = Stat.DifferenceStatIndp(
        name='Increase in mean discounted cost',
        x=sim_outcomes_ASP.costs,
        y_ref=sim_outcomes_NO.costs)

    # estimate and CI
    estimate_CI = increase_discounted_cost.get_formatted_mean_and_interval(
        interval_type='c', alpha=D.ALPHA, deci=2, form=',')
    print(
        "Increase in mean discounted cost and {:.{prec}%} confidence interval:"
        .format(1 - D.ALPHA, prec=0), estimate_CI)

    # increase in mean discounted utility under combination therapy with respect to no therapy
    increase_discounted_utility = Stat.DifferenceStatIndp(
        name='Increase in mean discounted utility',
        x=sim_outcomes_ASP.utilities,
        y_ref=sim_outcomes_NO.utilities)

    # estimate and CI
    estimate_CI = increase_discounted_utility.get_formatted_mean_and_interval(
        interval_type='c', alpha=D.ALPHA, deci=2)
    print(
        "Increase in mean discounted utility and {:.{prec}%} confidence interval:"
        .format(1 - D.ALPHA, prec=0), estimate_CI)
Пример #8
0
    def get_mortality_estimate_credible_interval(self, alpha):
        """
        :param n_samples: number of resamples from parameter values
        :param alpha: the significance level
        :returns tuple (mean, [lower, upper]) of the posterior distribution"""

        # calculate the credible interval
        sum_stat = Stat.SummaryStat(name='Posterior samples',
                                    data=self.mortalityResamples)

        estimate = sum_stat.get_mean()  # estimated mortality probability
        credible_interval = sum_stat.get_PI(alpha=alpha)  # credible interval

        return estimate, credible_interval
Пример #9
0
def mytest_continuous_time(times, observations):
    # define a continuous-time statistics
    continuous_stat = Stat.ContinuousTimeStat(
        'Test continuous-time statistics', 0)

    for obs in range(0, len(times)):
        # find the increment
        inc = 0
        if obs == 0:
            inc = observations[obs]
        else:
            inc = observations[obs] - observations[obs - 1]
        continuous_stat.record(times[obs], inc)

    print('Testing continuous-time statistics:')
    print_results(continuous_stat)
Пример #10
0
    def __init__(self, name, initial_size, sim_rep=0, collect_stat=True):
        """
        :param name: name of this sample path
        :param initial_size: (int) value of the sample path at simulation time 0
        :param sim_rep: (int) simulation replication of this sample path
        :param collect_stat: set to True to collect statistics on average, max, min, stDev, etc for this sample path
        """

        self.name = name
        self.simRep = sim_rep
        self.currentSize = initial_size     # current size of the sample path
        self._times = [0]                   # times at which changes occur
        self._values = [initial_size]       # size of this sample path over time
        # statistics on this prevalence sample path
        self.ifCollectStat = collect_stat
        if collect_stat:
            self.stat = Stat.ContinuousTimeStat(name=name, initial_time=0)
Пример #11
0
def mytest_ratio_stat_paied(x, y):
    # define
    stat = Stat.RatioStatPaired('Test RatioStatPaired', x, y)

    print('Testing RatioStatPaired:')
    print_results(stat)
Пример #12
0
def mytest_ratio_stat_indp(x, y):
    # define
    stat = Stat.RatioStatIndp('Test RatioStatIndp', x, y)
    print('Testing RatioStatIndp:')
    print_results(stat)
Пример #13
0
def mytest_diff_stat_paired(x, y):
    # define
    stat = Stat.DifferenceStatPaired('Test DifferenceStatPaired', x, y)
    print('Testing DifferenceStatPaired:')
    print_results(stat)
Пример #14
0
def mytest_diff_stat_indp(x, y):
    # define
    stat = Stat.DifferenceStatIndp('Test DifferenceStatIndp', x, y)
    print('Testing DifferenceStatIndp:')
    print_results(stat)
Пример #15
0
def mytest_summary_stat(data):
    # define a summary statistics
    sum_stat = Stat.SummaryStat('Test summary statistics', data)
    print('Testing summary statistics:')
    print_results(sum_stat)
Пример #16
0
def mytest_relativeDiff_stat_paied(x, y):
    # define
    stat = Stat.RelativeDifferencePaired('Test RelativeDifferencePaired', x, y)

    print('Testing RelativeDifferencePaired:')
    print_results(stat)
    def extract_outcomes(self, simulated_patients):
        """ extracts outcomes of a simulated cohort
        :param simulated_patients: a list of simulated patients"""

        # record survival time
        for patient in simulated_patients:
            # survival time
            if not (patient.stateMonitor.survivalTime is None):
                self.survivalTimes.append(patient.stateMonitor.survivalTime)

            # USE THIS SECTION IF NO INFORMATION ABOUT TIMES; USE THE BELOW SECTION IF WANT INFO ON TIMES
            if patient.stateMonitor.ifHOSP_TBD:
                self.nHOSP_TBD += 1
            if patient.stateMonitor.ifHOSP_TBM:
                self.nHOSP_TBM += 1
            if patient.stateMonitor.ifDX_TBD:
                self.nDX_TBD += 1
            if patient.stateMonitor.ifDX_TBM:
                self.nDX_TBM += 1
            if patient.stateMonitor.ifCLEARED:
                self.nCLEARED += 1
            if patient.stateMonitor.ifDEAD:
                self.nDEAD += 1

            # USE THIS SECTION IF WANT INFORMATION ABOUT TIME FOR EACH TRANSITION; USE ABOVE IF DON'T WANT
            # if patient.stateMonitor.ifHOSP_TBM:
            #     self.timesINFECTEDtoHOSP_TBM.append(patient.stateMonitor.timeINFECTEDtoHOSP_TBM)
            #     self.nHOSP_TBM += 1
            # if patient.stateMonitor.ifHOSP_TBD:
            #     self.timesINFECTEDtoHOSP_TBD.append(patient.stateMonitor.timeINFECTEDtoHOSP_TBD)
            #     self.nHOSP_TBD += 1
            # if patient.stateMonitor.ifDX_TBM:
            #     self.timesHOSP_TBMtoDX_TBM.append(patient.stateMonitor.timeHOSP_TBMtoDX_TBM)
            #     self.nDX_TBM += 1
            # if patient.stateMonitor.ifDX_TBD and patient.stateMonitor.ifHOSP_TBD:
            #     self.timesHOSP_TBDtoDX_TBD.append(patient.stateMonitor.timeHOSP_TBDtoDX_TBD)
            #     self.nDX_TBD += 1
            # if patient.stateMonitor.ifDX_TBD and (patient.stateMonitor.ifHOSP_TBD is False):  # and \
            #         # (patient.stateMonitor.ifHOSP_TBD is False) and (patient.stateMonitor.ifDEAD is False):
            #     self.timesINFECTEDtoDX_TBD.append(patient.stateMonitor.timeINFECTEDtoDX_TBD)
            #     self.nDX_TBD += 1
            # if patient.stateMonitor.ifCLEARED and patient.stateMonitor.ifDX_TBD:
            #     self.timesDX_TBDtoCLEARED.append(patient.stateMonitor.timeDX_TBDtoCLEARED)
            #     self.nCLEARED += 1
            # if patient.stateMonitor.ifCLEARED and patient.stateMonitor.ifDX_TBM:
            #     self.timesDX_TBMtoCLEARED.append(patient.stateMonitor.timeDX_TBMtoCLEARED)
            #     self.nCLEARED += 1
            # if patient.stateMonitor.ifCLEARED and (patient.stateMonitor.ifDX_TBD is False) and \
            #         (patient.stateMonitor.ifDX_TBM is False):
            #     self.timesINFECTEDtoCLEARED.append(patient.stateMonitor.timeINFECTEDtoCLEARED)
            #     self.nCLEARED += 1
            # # times from HOSP_TBM to DEAD
            # if patient.stateMonitor.ifDEAD and patient.stateMonitor.ifHOSP_TBM and \
            #         (patient.stateMonitor.ifCLEARED is False) and (patient.stateMonitor.ifHOSP_TBD is False) and \
            #         (patient.stateMonitor.ifDX_TBD is False) and (patient.stateMonitor.ifDX_TBM is False):
            #     self.timesHOSP_TBMtoDEAD.append(patient.stateMonitor.timeHOSP_TBMtoDEAD)
            #     self.nDEAD += 1
            # # times from HOSP_TBD to DEAD
            # if patient.stateMonitor.ifDEAD and patient.stateMonitor.ifHOSP_TBD and \
            #         (patient.stateMonitor.ifCLEARED is False) and (patient.stateMonitor.ifHOSP_TBM is False) and \
            #         (patient.stateMonitor.ifDX_TBM is False) and (patient.stateMonitor.ifDX_TBD is False):
            #     self.timesHOSP_TBDtoDEAD.append(patient.stateMonitor.timeHOSP_TBDtoDEAD)
            #     self.nDEAD += 1
            # # get rid of cleared and the two hosps
            # if patient.stateMonitor.ifDEAD and patient.stateMonitor.ifDX_TBM and \
            #         (patient.stateMonitor.ifCLEARED is False) and (patient.stateMonitor.timeHOSP_TBMtoDEAD is None) and\
            #         (patient.stateMonitor.ifHOSP_TBD is False) and (patient.stateMonitor.ifDX_TBD is False):
            #     self.timesDX_TBMtoDEAD.append(patient.stateMonitor.timeDX_TBMtoDEAD)
            #     self.nDEAD += 1
            # if patient.stateMonitor.ifDEAD and patient.stateMonitor.ifDX_TBD and \
            #         (patient.stateMonitor.ifCLEARED is False) and (patient.stateMonitor.timeHOSP_TBDtoDEAD is None) and\
            #         (patient.stateMonitor.ifHOSP_TBM is False) and (patient.stateMonitor.ifDX_TBM is False):
            #     self.timesDX_TBDtoDEAD.append(patient.stateMonitor.timeDX_TBDtoDEAD)
            #     self.nDEAD += 1
            # if patient.stateMonitor.ifDEAD and patient.stateMonitor.ifCLEARED and \
            #         (patient.stateMonitor.timeHOSP_TBMtoDEAD is None) and (patient.stateMonitor.timeHOSP_TBDtoDEAD is None) and \
            #         (patient.stateMonitor.timeDX_TBMtoDEAD is None) and (patient.stateMonitor.timeDX_TBDtoDEAD is None):
            #     self.timesCLEAREDtoDEAD.append(patient.stateMonitor.timeCLEAREDtoDEAD)
            #     self.nDEAD += 1

            # discounted cost and discounted utility
            self.costs.append(
                patient.stateMonitor.costUtilityMonitor.totalDiscountedCost)
            # self.utilities.append(patient.stateMonitor.costUtilityMonitor.totalDiscountedUtility)

            # discounted cost of all the patients who present to healthcare
            if not patient.stateMonitor.ifINFECTEDtoCLEARED:
                self.costsPresenting.append(
                    patient.stateMonitor.costUtilityMonitor.totalDiscountedCost
                )
                if patient.stateMonitor.survivalTime is None:
                    self.listYLLPresenting.append(0)
                else:
                    self.listYLLPresenting.append(
                        62.77 - (patient.stateMonitor.survivalTime / 52))
                if patient.stateMonitor.mortality56Day:
                    self.nMortality56Day += 1

            # total YLL due to TB infection
            if not patient.stateMonitor.ifCLEARED:
                if not (patient.stateMonitor.survivalTime is None):
                    self.totalYLL += 62.77 - (
                        patient.stateMonitor.survivalTime / 52)
                    self.listYLL.append(62.77 -
                                        (patient.stateMonitor.survivalTime /
                                         52))
                else:
                    self.listYLL.append(0)

            if patient.stateMonitor.mortality2Months:
                self.nMortality2Months += 1
            if patient.stateMonitor.mortality2Years:
                self.nMortality2Years += 1
            if patient.stateMonitor.mortality5Years:
                self.nMortality5Years += 1
            if patient.stateMonitor.mortality1Year:
                self.nMortality1Year += 1

        # Gather Data
        self.nHospitalized = self.nHOSP_TBD + self.nHOSP_TBM
        self.mortality56Day = self.nMortality56Day / D.POP_SIZE
        self.mortality2Months = self.nMortality2Months / D.POP_SIZE
        self.mortality1Year = self.nMortality1Year / D.POP_SIZE
        self.mortality2Years = self.nMortality2Years / D.POP_SIZE
        self.mortality5Years = self.nMortality5Years / D.POP_SIZE

        # self.timesINFECTED = self.timesINFECTEDtoCLEARED + self.timesINFECTEDtoDX_TBD + self.timesINFECTEDtoHOSP_TBM + \
        #     self.timesINFECTEDtoHOSP_TBD
        # self.timesHOSP_TBD = self.timesHOSP_TBDtoDEAD + self.timesHOSP_TBDtoDX_TBD
        # self.timesHOSP_TBM = self.timesHOSP_TBMtoDEAD + self.timesHOSP_TBMtoDX_TBM
        # self.timesDX_TBM = self.timesDX_TBMtoCLEARED + self.timesDX_TBMtoDEAD
        # self.timesDX_TBD = self.timesDX_TBDtoCLEARED + self.timesDX_TBDtoDEAD
        # self.timesCLEARED = self.timesCLEAREDtoDEAD

        # Summary Statistics
        self.statSurvivalTime = Stat.SummaryStat('Survival time',
                                                 self.survivalTimes)

        # self.statTimeINFECTEDtoHOSP_TBD = Stat.SummaryStat('Infected to HOSP_TBD', self.timesINFECTEDtoHOSP_TBD)
        # self.statTimeINFECTEDtoHOSP_TBM = Stat.SummaryStat('Infected to HOSP_TBM', self.timesINFECTEDtoHOSP_TBM)
        # self.statTimeINFECTEDtoDX_TBD = Stat.SummaryStat('Infected to DX_TBD', self.timesINFECTEDtoDX_TBD)
        # self.statTimeINFECTEDtoCLEARED = Stat.SummaryStat('Infected to Cleared', self.timesINFECTEDtoCLEARED)
        # self.statTimeCLEAREDtoDEAD = Stat.SummaryStat('Cleared to Dead', self.timesCLEAREDtoDEAD)
        # self.statTimeHOSP_TBDtoDEAD = Stat.SummaryStat('HOSP_TBD to Dead', self.timesHOSP_TBDtoDEAD)
        # self.statTimeHOSP_TBDtoDX_TBD = Stat.SummaryStat('HOSP_TBD to DX_TBD', self.timesHOSP_TBDtoDX_TBD)
        # self.statTimeHOSP_TBMtoDEAD = Stat.SummaryStat('HOSP_TBM to DEAD', self.timesHOSP_TBMtoDEAD)
        # self.statTimeHOSP_TBMtoDX_TBM = Stat.SummaryStat('HOSP_TBM to DX_TBM', self.timesHOSP_TBMtoDX_TBM)
        # self.statTimeDX_TBDtoDEAD = Stat.SummaryStat('DX_TBD to Dead', self.timesDX_TBDtoDEAD)
        # self.statTimeDX_TBDtoCLEARED = Stat.SummaryStat('DX_TBD to Cleared', self.timesDX_TBDtoCLEARED)
        # self.statTimeDX_TBMtoDEAD = Stat.SummaryStat('DX_TBM to Dead', self.timesDX_TBMtoDEAD)
        # self.statTimeDX_TBMtoCLEARED = Stat.SummaryStat('DX_TBM to Cleared', self.timesDX_TBMtoCLEARED)
        #
        # self.statTimesINFECTED = Stat.SummaryStat('Infected', self.timesINFECTED)
        # self.statTimesHOSP_TBM = Stat.SummaryStat('HOSP_TBM', self.timesHOSP_TBM)
        # self.statTimesHOSP_TBD = Stat.SummaryStat('HOSP_TBD', self.timesHOSP_TBD)
        # self.statTimesDX_TBD = Stat.SummaryStat('DX_TBD', self.timesDX_TBD)
        # self.statTimesDX_TBM = Stat.SummaryStat('DX_TBM', self.timesDX_TBM)
        # self.statTimesCLEARED = Stat.SummaryStat('Cleared', self.timesCLEARED)

        self.statCost = Stat.SummaryStat('Discounted cost', self.costs)
        # self.statCostPresenting = Stat.SummaryStat('Discounted cost (Presenting)', self.costsPresenting)
        # self.statUtility = Stat.SummaryStat('Discounted utility', self.utilities)

        # survival curve
        self.nLivingPatients = Path.PrevalencePathBatchUpdate(
            name='# of living patients',
            initial_size=len(simulated_patients),
            times_of_changes=self.survivalTimes,
            increments=[-1] * len(self.survivalTimes))
Пример #18
0
def mytest_relativeDiff_stat_indp(x, y):
    # define
    stat = Stat.RelativeDifferenceIndp('Test RelativeDifferenceIndp', x, y)

    print('Testing RelativeDifferenceIndp:')
    print_results(stat)
Пример #19
0
def print_comparative_outcomes(multi_cohort_outcomes_SOC, multi_cohort_outcomes_NSB):
    """ prints average increase in survival time, discounted cost, and discounted utility
    under combination therapy compared to mono therapy
    :param multi_cohort_outcomes_mono: outcomes of a multi-cohort simulated under mono therapy
    :param multi_cohort_outcomes_combo: outcomes of a multi-cohort simulated under combination therapy
    """

    # increase in mean survival time under combination therapy with respect to mono therapy
    increase_mean_survival_time = Stat.DifferenceStatPaired(
        name='Increase in mean survival time',
        x=multi_cohort_outcomes_NSB.meanSurvivalTimes,
        y_ref=multi_cohort_outcomes_SOC.meanSurvivalTimes)

    # estimate and PI
    estimate_PI = increase_mean_survival_time.get_formatted_mean_and_interval(interval_type='p',
                                                                              alpha=D.ALPHA,
                                                                              deci=2)
    print("Increase in mean survival time and {:.{prec}%} uncertainty interval:"
          .format(1 - D.ALPHA, prec=0),
          estimate_PI)

    # increase in mean number of hospitalizations
    increase_mean_nHosp = Stat.DifferenceStatPaired(
        name='Increase in mean number of kids hospitalized',
        x=multi_cohort_outcomes_NSB.nHospitalized,
        y_ref=multi_cohort_outcomes_SOC.nHospitalized)

    # estimate and PI
    estimate_PI = increase_mean_nHosp.get_formatted_mean_and_interval(interval_type='p',
                                                                              alpha=D.ALPHA,
                                                                              deci=2)
    print("Increase in mean number of hospitalizations and {:.{prec}%} uncertainty interval:"
          .format(1 - D.ALPHA, prec=0),
          estimate_PI)

    # increase in mean number of YLLs
    increase_mean_YLLs = Stat.DifferenceStatPaired(
        name='Increase in mean number of Years of Life Lost',
        x=multi_cohort_outcomes_NSB.totalYLL,
        y_ref=multi_cohort_outcomes_SOC.totalYLL)

    # estimate and PI
    estimate_PI = increase_mean_YLLs.get_formatted_mean_and_interval(interval_type='p',
                                                                              alpha=D.ALPHA,
                                                                              deci=2)
    print("Increase in mean number of Years of Life Lost and {:.{prec}%} uncertainty interval:"
          .format(1 - D.ALPHA, prec=0),
          estimate_PI)

    # increase in mean number of patients w/ TBM
    increase_mean_TBM = Stat.DifferenceStatPaired(
        name='Increase in mean number of cases of TB meningitis',
        x=multi_cohort_outcomes_NSB.nTBM,
        y_ref=multi_cohort_outcomes_SOC.nTBM)

    # estimate and PI
    estimate_PI = increase_mean_TBM.get_formatted_mean_and_interval(interval_type='p',
                                                                              alpha=D.ALPHA,
                                                                              deci=2)
    print("Increase in mean number of cases of TB meningitis and {:.{prec}%} uncertainty interval:"
          .format(1 - D.ALPHA, prec=0),
          estimate_PI)

    # increase in mean 2-month mortality
    increase_mean_mortality2Month = Stat.DifferenceStatPaired(
        name='Increase in mean 2-month mortality',
        x=multi_cohort_outcomes_NSB.mortality2Month,
        y_ref=multi_cohort_outcomes_SOC.mortality2Month)

    # estimate and PI
    estimate_PI = increase_mean_mortality2Month.get_formatted_mean_and_interval(interval_type='p',
                                                                              alpha=D.ALPHA,
                                                                              deci=2)
    print("Increase in mean 2-month mortality and {:.{prec}%} uncertainty interval:"
          .format(1 - D.ALPHA, prec=0),
          estimate_PI)

    # increase in mean 2-year mortality
    increase_mean_mortality2Year = Stat.DifferenceStatPaired(
        name='Increase in mean 2-year mortality',
        x=multi_cohort_outcomes_NSB.mortality2Years,
        y_ref=multi_cohort_outcomes_SOC.mortality2Years)

    # estimate and PI
    estimate_PI = increase_mean_mortality2Year.get_formatted_mean_and_interval(interval_type='p',
                                                                              alpha=D.ALPHA,
                                                                              deci=2)
    print("Increase in mean 2-year mortality and {:.{prec}%} uncertainty interval:"
          .format(1 - D.ALPHA, prec=0),
          estimate_PI)

    # increase in mean 5-year mortality
    increase_mean_mortality5Year = Stat.DifferenceStatPaired(
        name='Increase in mean 5-year mortality',
        x=multi_cohort_outcomes_NSB.mortality5Years,
        y_ref=multi_cohort_outcomes_SOC.mortality5Years)

    # estimate and PI
    estimate_PI = increase_mean_mortality5Year.get_formatted_mean_and_interval(interval_type='p',
                                                                              alpha=D.ALPHA,
                                                                              deci=2)
    print("Increase in mean 5-year mortality and {:.{prec}%} uncertainty interval:"
          .format(1 - D.ALPHA, prec=0),
          estimate_PI)

    # increase in mean discounted cost under combination therapy with respect to mono therapy
    increase_mean_discounted_cost = Stat.DifferenceStatPaired(
        name='Increase in mean discounted cost',
        x=multi_cohort_outcomes_NSB.meanCosts,
        y_ref=multi_cohort_outcomes_SOC.meanCosts)

    # estimate and PI
    estimate_PI = increase_mean_discounted_cost.get_formatted_mean_and_interval(interval_type='p',
                                                                                alpha=D.ALPHA,
                                                                                deci=2,
                                                                                form=',')
    print("Increase in mean discounted cost and {:.{prec}%} uncertainty interval:"
          .format(1 - D.ALPHA, prec=0),
          estimate_PI)