Ejemplo n.º 1
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 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()
Ejemplo n.º 2
0
def test_normal(rnd, mean, sigma):
    #normal random variate generator
    normal_dist = RVGs.Normal(mean, sigma)

    # obtain samples
    samples = get_samples(normal_dist, rnd)

    # report mean and variance
    print_test_results('Normal', samples,
                       expectation=mean,
                       variance=sigma**2
                       )
Ejemplo n.º 3
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()