Closed ivanistheone closed 1 week ago
@ivanistheone thanks for reporting the issue. There are two things going on here.
The first one, is that if you want to set a parameter to a constant value, you should simply use the constant value, not a Prior
that calls pm.Data
under the hood (although I have to say that was a good hack! I had not thought about it). Then, you should do
import pandas as pd
import bambi as bmb
iqs = [ 82.6, 105.5, 96.7, 84.0, 127.2, 98.8, 94.3]
df = pd.DataFrame({"iq":iqs})
priors = {
"Intercept": bmb.Prior("Normal", mu=100, sigma=40),
"sigma": 15,
}
mod = bmb.Model(
"iq ~ 1",
priors=priors,
family="gaussian",
link="identity",
data=df
)
idata = mod.fit()
mod.predict(idata, kind="response")
However, this is still not working, but for a different reason. I'm fixing that right now. I'll update you when it's on main
.
I can confirm the above code (with sigma as float) works now using the Bambi version on main.
Thanks for looking into and fixing!
Hi all. I ran into an issue similar to https://github.com/bambinos/bambi/issues/750 where a variable required for posterior predictive of the response variable is not included in the inference data object.
I'm trying to fit a Gaussian model with known, fixed variance sigma=15, and custom prior norm(100,40) on the mean. This is for educational purposes, to show the simplest possible model. I found a way to add
sigma
as constant, by setting abmb.Prior("Data", value=15)
, and the complete code example is like this:Here sigma is not included in
vars_to_sample
, but the sigma info is preserved inidata
underconstant_data
:If I then try to sample response variable I get this error:
Is there some way to make
_make_dist_kwargs_and_coords
look forsigma
value in theconstant_data
?Am-I doing something wrong/unexpected by setting the sigma prior using
bmb.Prior("Data", value=15)
? I'd be happy to use another approach.Oh and the context is
pymc.__version__ == '5.17.0'
andbmb.__version__ == '0.14.0'
on macOS.