def _validate_priors(self, level_sigma_prior, level_nu_prior,
                         slope_sigma_prior, slope_nu_prior,
                         y, sdy):
        if level_sigma_prior is None:
            sdy = self._compute_sdy(sdy, y, "level_sigma_prior")
            level_sigma_prior = R.SdPrior(
                sigma_guess=.01 * sdy,
                upper_limit=sdy)
        if not isinstance(level_sigma_prior, R.SdPrior):
            raise Exception("Unexpected type for level_sigma_prior.")

        if slope_sigma_prior is None:
            sdy = self._compute_sdy(sdy, y, "slope_sigma_prior")
            slope_sigma_prior = R.SdPrior(
                sigma_guess=.01 * sdy,
                upper_limit=sdy)
        if not isinstance(slope_sigma_prior, R.SdPrior):
            raise Exception("Unexpected type for slope_sigma_prior.")

        if level_nu_prior is None:
            level_nu_prior = R.UniformPrior(0.1, 100)
        if not isinstance(level_nu_prior, R.DoubleModel):
            raise Exception("Unexpected type for level_nu_prior.")

        if slope_nu_prior is None:
            slope_nu_prior = R.UniformPrior(0.1, 100)
        if not isinstance(slope_nu_prior, R.DoubleModel):
            raise Exception("Unexpected type for slope_nu_prior.")

        self._level_sigma_prior = level_sigma_prior
        self._slope_sigma_prior = slope_sigma_prior
        self._level_nu_prior = level_nu_prior
        self._slope_nu_prior = slope_nu_prior
Exemplo n.º 2
0
    def __init__(self,
                 x,
                 y=None,
                 expected_r2=.5,
                 prior_df=.01,
                 expected_model_size=1,
                 prior_information_weight=.01,
                 diagonal_shrinkage=.5,
                 optional_coefficient_estimate=None,
                 max_flips=-1,
                 mean_y=None,
                 sdy=None,
                 prior_inclusion_probabilities=None,
                 sigma_upper_limit=np.Inf,
                 tail_thickness_prior=R.UniformPrior(0.1, 100)):
        """
        Args:
          tail_thickness_prior: An object with a boom() method, which returns a
            boom.DoubleModel describing the prior on the tail thickness
            parameter.

          All other arguments are as documented in RegressionSpikeSlabPrior.
        """
        super().__init__(
            x=x,
            y=y,
            expected_r2=expected_r2,
            prior_df=prior_df,
            expected_model_size=expected_model_size,
            prior_information_weight=prior_information_weight,
            diagonal_shrinkage=diagonal_shrinkage,
            optional_coefficient_estimate=optional_coefficient_estimate,
            max_flips=max_flips,
            mean_y=mean_y,
            sdy=sdy,
            prior_inclusion_probabilities=prior_inclusion_probabilities,
            sigma_upper_limit=sigma_upper_limit)
        self._nu_prior = tail_thickness_prior