这可能是一个愚蠢的问题,但我搜索了 pyMC3 文档和论坛,似乎找不到答案。我正在尝试从我知道先验不应该有截距的数据集创建线性回归模型。目前我的实现如下所示:
formula = 'Y ~ ' + ' + '.join(['X1', 'X2'])
# Define data to be used in the model
X = df[['X1', 'X2']]
Y = df['Y']
# Context for the model
with pm.Model() as model:
# set distribution for priors
priors = {'X1': pm.Wald.dist(mu=0.01),
'X2': pm.Wald.dist(mu=0.01) }
family = pm.glm.families.Normal()
# Creating the model requires a formula and data
pm.GLM.from_formula(formula, data = X, family=family, priors = priors)
# Perform Markov Chain Monte Carlo sampling
trace = pm.sample(draws=4000, cores = 2, tune = 1000)
正如我所说,我知道我不应该拦截,但我似乎无法找到一种方法来告诉 GLM.from_formula() 不要寻找一个。大家有解决办法吗?提前致谢!