Computing Bayes Factor

Hello everyone,
I am quite new to Bayesian analysis, and I am trying to find out how to compare a model to a null one. I currently have pymc3 3.11.2 installed.

I have on linear model where the intercept is different across 4 conditions, and one where it just models the mean

m1

condition_indx, conditions = pd.factorize(data.state)

with pm.Model() as model:
    a = pm.Normal("a",0,.5,shape=len(conditions))
    condition_id = pm.intX(pm.Data("condition_id",condition_indx))
    mu = pm.Deterministic("mu",a[condition_id])
    sigma = pm.Exponential("sigma",1)
    
    obs = pm.Normal("obs",mu,sigma,observed=data.value)

null model

with pm.Model() as null:
    
    a = pm.Normal("a",0,3)
    sigma = pm.Exponential("sigma",1)
    obs = pm.Normal("obs",a,sigma,observed=data.value)
    
    null_trace = pm.sample(nSample,tune=nTune,return_inferencedata=False,chains=nChains)

Is there to extract Bayes Factor from these two ? Thank you

You can do that through Arviz: arviz/bf_plot.py at main · arviz-devs/arviz · GitHub (the function is recently added, so you will need to wait for the next release or install from github main)