如何分析贝叶斯分析的输出

问题描述 投票:1回答:1

我正在尝试使用pymc3和bambi软件进行贝叶斯分析。

我的数据形状是136x5,前5行如下:

   AGE GENDER  AVAR  BVAR   OUTVAR
0   60      F   0.9     0   8260.0
1   56      F   5.4     1  15888.0
2   55      F   1.2     1  19734.4
3   52      F   1.7     1  15904.2
4   49      F   1.6     0  14848.0

其中OUTVAR是目标变量,其他是预测变量。

我使用了以下Python3代码:

from bambi import Model
model = Model(bdf)
results = model.fit('OUTVAR ~ AGE + GENDER + AVAR + BVAR', samples=5000, chains=2)
print(results[1000:].summary())

得到以下输出:

Auto-assigning NUTS sampler...
Initializing NUTS using advi...
Average Loss = 1,476.2:  21%|██████████████▊                                                       | 10601/50000 [00:01<00:07, 5542.87it/s]
Convergence achieved at 10700
Interrupted at 10,699 [21%]: Average Loss = 1,520.6
Multiprocess sampling (2 chains in 2 jobs)
NUTS: [OUTVAR_sd, BVAR, AVAR, AGE, GENDER, Intercept]
Sampling 2 chains: 100%|██████████████████████████████████████████████████████████████████████████| 11000/11000 [11:40<00:00, 15.71draws/s]
There were 154 divergences after tuning. Increase `target_accept` or reparameterize.
The chain reached the maximum tree depth. Increase max_treedepth, increase target_accept or reparameterize.
There were 241 divergences after tuning. Increase `target_accept` or reparameterize.
The chain reached the maximum tree depth. Increase max_treedepth, increase target_accept or reparameterize.
The number of effective samples is smaller than 10% for some parameters.

                     mean           sd  hpd0.95_lower  hpd0.95_upper  effective_n  gelman_rubin
AGE              6.936836    81.741918    -158.176468     165.050530          589      1.005245
AVAR           -78.356403   410.942267    -896.068374     718.650196         2414      1.000314
BVAR          2639.993063  2262.101985   -1528.841953    7297.760056          553      1.000544
GENDER[T.M]   -615.092080  1659.905226   -3855.789966    2756.704710         1392      1.003126
Intercept    11739.843222  3591.680335    5239.872556   19053.145349          179      1.007447
OUTVAR_sd     8936.351700   283.640474    8402.347757    9318.495791         6027      1.000028

如何分析以及我可以从此值表中进行哪些推断?

编辑:具体来说,我想确认mean是否表示每个变量的系数值。但是,在通常的线性回归中,结果变量没有系数,而在此列出。另外,我不清楚每个变量的effective_n值是什么意思。谢谢你的帮助。

bayesian pymc bambi
1个回答
2
投票

在这种情况下,mean是后验分布的均值。对于像这样的简单情况,后验均值通常接近传统最小二乘回归得到的点估计值。

OUTVAR_sd行不适用于结果变量;它代表了模型错误。将真正的OUTVAR评分视为模型预测的OUTVAR的总和,再加上正态分布的误差。然后OUTVAR_sd是该误差项的后验估计。

effective_n是每个变量链中独立样本数量的启发式估计。这几乎总是小于标称数,因为连续样本是相关的。有关简要说明,请参阅this blog post

© www.soinside.com 2019 - 2024. All rights reserved.