nchopin / particles

Sequential Monte Carlo in python
MIT License
403 stars 75 forks source link

Bug in BayesianVS_gprior #76

Closed akotlar closed 9 months ago

akotlar commented 10 months ago

In BayesianVS_gprior def set_constants(self): is uninentionally indented and therefore defined only for the scope of the constructor. It should be unindented to comply with the BayesianVS interface.

E.g:

class BayesianVS_gprior(BayesianVS):
    """
    Same model as parent class, except:
    beta | sigma^2 ~ N(0, g sigma^2 (X'X)^-1)

    """

    def __init__(self, data=None, prior=None, nu=4.0, lamb=None, g=None, jitted=False):
        self.g = self.n if g is None else g
        super().__init__(
            data=data, prior=prior, nu=nu, lamb=lamb, iv2=0.0, jitted=jitted
        )

    def set_constants(self):
        self.coef_len = 0.5 * np.log(1 + self.g)
        self.coef_log = 0.5 * (self.n + self.nu)
        self.coef_in_log = nu * self.lamb + self.yty
        self.gogp1 = self.g / (self.g + 1.0)
nchopin commented 10 months ago

Fixed in experimental branch, I will run more tests before pushing the fix to master. (I think I always used BayesianVS in my experiments). Thanks for spotting this!