Skip to content

Distributional priors are not set correctly for models with heteroskedasticity #900

@ivlis

Description

@ivlis

This works as expected

df = pd.DataFrame({'x':[1,2,3], 'y' : [3,2,1]})

m1 = bmb.Model(
    bmb.Formula(
        "x ~ y",
    ),
    data=df,
    family="negativebinomial",
    priors={"alpha":
         bmb.Prior("InverseGamma", alpha=0.2, beta=0.3),
    },
)

what results into a model:

       Formula: x ~ y
        Family: negativebinomial
          Link: mu = log
  Observations: 3
        Priors: 
    target = mu
        Common-level effects
            Intercept ~ Normal(mu: 0.0, sigma: 6.6144)
            y ~ Normal(mu: 0.0, sigma: 3.0619)
        
        Auxiliary parameters
            alpha ~ InverseGamma(alpha: 0.2, beta: 0.3)

However if I specify a formula on alpha, setting priors does not work

    bmb.Formula(
        "x ~ y",
        "alpha ~ y",
    ),
    data=df,
    family="negativebinomial",
    priors={
        "alpha_y": bmb.Prior("InverseGamma", alpha=0.2, beta=0.3),
        "alpha_Intercept": bmb.Prior("InverseGamma", alpha=0.2, beta=0.3),
    },
)

this results into default priors:

       Formula: x ~ y
                alpha ~ y
        Family: negativebinomial
          Link: mu = log
                alpha = log
  Observations: 3
        Priors: 
    target = mu
        Common-level effects
            Intercept ~ Normal(mu: 0.0, sigma: 6.6144)
            y ~ Normal(mu: 0.0, sigma: 3.0619)
    target = alpha
        Common-level effects
            alpha_Intercept ~ Normal(mu: 0.0, sigma: 1.0)
            alpha_y ~ Normal(mu: 0.0, sigma: 1.0)

I tried - set_prior(), it gives the same result.

It could be that I'm doing something not correctly, but models with multiple targeted are not documented very well, imo.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions