def print_comparative_outcomes(calibrated_model_no_drug, calibrated_model_with_drug): """ prints expected and percentage increase in average survival time when drug is available :param calibrated_model_no_drug: calibrated model simulated when drug is not available :param calibrated_model_with_drug: calibrated model simulated when drug is available """ # increase in survival time increase_stat = Stat.DifferenceStatPaired( name='Increase in mean survival time', x=calibrated_model_with_drug.multiCohorts.multiCohortOutcomes. meanSurvivalTimes, y_ref=calibrated_model_no_drug.multiCohorts.multiCohortOutcomes. meanSurvivalTimes) # mean and prediction interval mean = increase_stat.get_mean() pred_int = increase_stat.get_PI(alpha=D.ALPHA) print( "Expected increase in mean survival time (years) and {:.{prec}%} prediction interval:" .format(1 - D.ALPHA, prec=0), mean, pred_int) # % increase in mean survival time relative_diff_stat = Stat.RelativeDifferencePaired( name='% increase in mean survival time', x=calibrated_model_with_drug.multiCohorts.multiCohortOutcomes. meanSurvivalTimes, y_ref=calibrated_model_no_drug.multiCohorts.multiCohortOutcomes. meanSurvivalTimes) # estimate and prediction interval mean = relative_diff_stat.get_mean() pred_int = relative_diff_stat.get_PI(alpha=D.ALPHA) print( "Expected percentage increase in mean survival time and {:.{prec}%} confidence interval:" .format(1 - D.ALPHA, prec=0), mean, pred_int)
def get_relative_diff_mean_interval(self, scenario_name_base, scenario_names, outcome_name, deci=0, form=None): """ :return: dictionary of mean and percentile interval of the relative difference of the selected outcome """ if type(scenario_names) is not list: scenario_names = [scenario_names] list_mean_PI = {} for name in scenario_names: ratio_state = Stat.RelativeDifferencePaired( name='', x=self.scenarios[name].outcomes[outcome_name], y_ref=self.scenarios[scenario_name_base]. outcomes[outcome_name], order=1) list_mean_PI[name] = Support.get_mean_interval(stat=ratio_state, interval_type='p', deci=deci, form=form) if len(scenario_names) == 1: return list_mean_PI[scenario_names[0]] else: return list_mean_PI
def get_relative_diff_mean_PI(self, time_index0, time_index1, order=0, deci=0, format=None): """ :return: the mean relative difference of trajectories at two time indeces """ stat = Stat.RelativeDifferencePaired('', x=self.get_obss(time_index1), y_ref=self.get_obss(time_index0), order=order) if format is None: return stat.get_mean(), stat.get_PI(alpha=0.05) else: return stat.get_formatted_mean_and_interval(interval_type='p', alpha=0.05, deci=deci, form=format)
def mytest_relativeDiff_stat_paied(x, y): # define stat = Stat.RelativeDifferencePaired(x, y, name='Test RelativeDifferencePaired') print('Testing RelativeDifferencePaired:') print_results(stat)