def __init__(self, seed, therapy): # initializing the base class _Parameters.__init__(self, therapy) self._rng = Random.RNG( seed ) # random number generator to sample from parameter distributions self._hivProbMatrixRVG = [ ] # list of dirichlet distributions for transition probabilities self._lnRelativeRiskRVG = None # random variate generator for the natural log of the treatment relative risk self._annualStateCostRVG = [ ] # list of random variate generators for the annual cost of states self._annualStateUtilityRVG = [ ] # list of random variate generators for the annual utility of states # HIV transition probabilities j = 0 for prob in Data.TRANS_MATRIX: self._hivProbMatrixRVG.append(Random.Dirichlet(prob[j:])) j += 1 # treatment relative risk # find the mean and st_dev of the normal distribution assumed for ln(RR) if self._therapy == Therapies.MONO: sample_mean_lnRR = math.log(Data.Treatment_RR_GC) sample_std_lnRR = \ (math.log(Data.Treatment_RR_G_CI[1])-math.log(Data.Treatment_RR_G_CI[0]))/(2*stat.norm.ppf(1-0.05/2)) self._lnRelativeRiskRVG = Random.Normal(loc=sample_mean_lnRR, scale=sample_std_lnRR) else: sample_mean_lnRR = math.log(Data.Treatment_RR_GC) sample_std_lnRR = \ (math.log(Data.Treatment_RR_GC_CI[1]) - math.log(Data.Treatment_RR_GC_CI[0])) / ( 2 * stat.norm.ppf(1 - 0.05 / 2)) self._lnRelativeRiskRVG = Random.Normal(loc=sample_mean_lnRR, scale=sample_std_lnRR) # annual state cost for cost in Data.MONTHLY_STATE_COST: # find shape and scale of the assumed gamma distribution estDic = Est.get_gamma_params(mean=cost, st_dev=cost / 4) # append the distribution self._annualStateCostRVG.append( Random.Gamma(a=estDic["a"], loc=0, scale=estDic["scale"])) # annual state utility for utility in Data.MONTHLY_STATE_UTILITY: # find alpha and beta of the assumed beta distribution estDic = Est.get_beta_params(mean=utility, st_dev=utility / 4) # append the distribution self._annualStateUtilityRVG.append( Random.Beta(a=estDic["a"], b=estDic["b"])) # resample parameters self.__resample()
def __init__(self, seed, therapy): # initializing the base class _Parameters.__init__(self, therapy) self._rng = Random.RNG( seed ) # random number generator to sample from parameter distributions self._hivProbMatrixRVG_LDCT = [ ] # list of dirichlet distributions for transition probabilities of LDCT self._hivProbMatrixRVG_PLCO = [] #self._lnRelativeRiskRVG = None # random variate generator for the natural log of the treatment relative risk self._annualStateCostRVG = [ ] # list of random variate generators for the annual cost of states self._annualStateUtilityRVG = [ ] # list of random variate generators for the annual utility of states # HIV transition probabilities j = 0 for prob in Data.TRANS_MATRIX_LDCT: self._hivProbMatrixRVG_LDCT.append(Random.Dirichlet(prob[j:])) j += 1 # you should make sure everything you use is not "0" in the dirichlet for prob in Data.TRANS_MATRIX_PLCO: self._hivProbMatrixRVG_PLCO.append(Random.Dirichlet(prob[j:])) j += 1 # treatment relative risk # find the mean and st_dev of the normal distribution assumed for ln(RR) # annual state cost, we assume gamma distribution for cost in Data.ANNUAL_STATE_COST: # find shape and scale of the assumed gamma distribution estDic = Est.get_gamma_params(mean=cost, st_dev=cost / 4) # append the distribution self._annualStateCostRVG.append( Random.Gamma(a=estDic["a"], loc=0, scale=estDic["scale"])) # annual state utility, we assume beta distribution for utility in Data.ANNUAL_STATE_UTILITY: # find alpha and beta of the assumed beta distribution estDic = Est.get_beta_params(mean=utility, st_dev=utility / 4) # append the distribution self._annualStateUtilityRVG.append( Random.Beta(a=estDic["a"], b=estDic["b"]))
def __init__(self, seed, therapy): # initializing the base class _Parameters.__init__(self, therapy) self._rng = Random.RNG( seed ) # random number generator to sample from parameter distributions self._hivProbMatrixRVG = [ ] # list of dirichlet distributions for transition probabilities self._lnRelativeRiskRVG = None # random variate generator for the treatment relative risk self._annualStateCostRVG = [ ] # list of random variate generators for the annual cost of states self._annualStateUtilityRVG = [ ] # list of random variate generators for the annual utility of states # HIV transition probabilities j = 0 for prob in Data.TRANS_MATRIX: self._hivProbMatrixRVG.append(Random.Dirichlet(prob[j:])) j += 1 # treatment relative risk # find the mean and st_dev of the normal distribution assumed for ln(RR) sample_mean_lnRR = math.log(Data.TREATMENT_RR) sample_std_lnRR = (Data.TREATMENT_RR_CI[1] - Data.TREATMENT_RR_CI[0] ) / (2 * stat.norm.ppf(1 - 0.05 / 2)) self._lnRelativeRiskRVG = Random.Normal(mean=sample_mean_lnRR, st_dev=sample_std_lnRR) # annual state cost for cost in Data.ANNUAL_STATE_COST: # find shape and scale of the assumed gamma distribution shape, scale = Est.get_gamma_parameters(mean=cost, st_dev=cost / 4) # append the distribution self._annualStateCostRVG.append(Random.Gamma(shape, scale)) # annual state utility for utility in Data.ANNUAL_STATE_UTILITY: # find alpha and beta of the assumed beta distribution a, b = Est.get_beta_parameters(mean=utility, st_dev=utility / 5) # append the distribution self._annualStateUtilityRVG.append(Random.Beta(a, b)) # resample parameters self.__resample()
def __init__(self, seed, therapy): self._rng = Random.RNG( seed ) # random number generator to sample from parameter distributions self._StrokeProbMatrixRVG = [ ] # list of dirichlet distributions for transition probabilities self._lnRelativeRiskRVG = None # random variate generator for the treatment relative risk # Stroke transition probabilities j = 0 for prob in Data.TRANS_MATRIX: self._StrokeProbMatrixRVG.append(Random.Dirichlet(prob[j:])) j += 1 # resample parameters self.__resample()
def test_dirichlet(rnd, a): # dirichlet random variate generator dirichlet_dist = RVGs.Dirichlet(a) # obtain samples samples = get_samples_multivariate(dirichlet_dist, rnd) # report mean and variance a0 = sum(a) if type(a) == list: a = np.array(a) mean = a * (1.0/a0) var = np.zeros(len(a)) for i in range(len(a)): var[i] = (a[i]*(a0-a[i]))/(((a0)**2)*(a0+1.0)) print_test_results_multivariate('Dirichlet', samples, expectation=mean, variance=var)