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_G)
            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_gamma_params(mean=utility, st_dev=utility/4)
            # append the distribution
            self._annualStateUtilityRVG.append(
                Random.Gamma(a=estDic["a"], b=estDic["b"]))

        # resample parameters
        self.__resample()
Exemplo n.º 2
0
    def __init__(self, seed, therapy):

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

        self._rng = Random.RNG(seed)    # random number generator to sample from parameter distributions
        self._infectionProbMatrixRVG = []  # 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

 #transition probabilities
      #  j = 0
        # for prob in Data.TRANS_MATRIX:
          #  self._infectionProbMatrixRVG.append(Random.Dirichlet(prob[j:]))
          #  j += 1

        # annual state cost
        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
        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"]))

        # resample parameters
        self.__resample()
Exemplo n.º 3
0
def test_gamma(rnd, shape, scale):
    # gamma random variate generator
    gamma_dist = RVGs.Gamma(shape, scale)

    # obtain samples
    samples = get_samples(gamma_dist, rnd)

    # report mean and variance
    print_test_results('Gamma', samples,
                       expectation=shape*scale,
                       variance=shape*scale**2)
Exemplo n.º 4
0
    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):

        # 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"]))