BART是贝叶斯非参数模型,可以使用Backfitting MCMC进行拟合 。
我不使用任何软件包…… MCMC是从头开始实现的。
![](https://tecdat.cn/wp-content/uploads/2019/07/image-610.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-611.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-609.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-613.gif)
考虑协变量数据和成果为主题,。在这个 示例中,数据看起来像这样:
![](https://img-blog.csdnimg.cn/20190422160258755.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzE5NjAwMjkx,size_16,color_FFFFFF,t_70)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-612.gif)
我们可能会考虑以下概率模型
![](https://tecdat.cn/wp-content/uploads/2019/07/image-614.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-615.gif)
基本上我们使用三次多项式对条件均值进行建模。请注意,这是更一般的 模型的特例
![](https://tecdat.cn/wp-content/uploads/2019/07/image-619.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-616.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-617.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-618.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-623.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-620.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-621.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-626.gif)
在这种情况下和。该模型在参数矢量的每个元素上具有平坦的先验和在方差参数上具有形状和速率的反伽马先验。
![](https://tecdat.cn/wp-content/uploads/2019/07/image-622.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-625.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-624.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-627.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-628.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-631.gif)
每个条件后验都是高斯(因为共轭)。我们可以使用共轭Gibbs或Metropolis从中进行采样。我们也可以将整个参数矢量作为一个块进行采样,但是在这篇文章中我们将坚持反向拟合 – 这本身就是一个Gibbs采样器。我们仍然从其他条件的每个条件的条件后验中进行抽样。然而,我们利用关键的洞察力,每个条件后验取决于其他beta ,仅由残差表示
![](https://tecdat.cn/wp-content/uploads/2019/07/image-629.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-630.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-632.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-633.gif)
直观地,是在减去其他项(非)所解释的部分之后的左手平均值的部分。它也是正常分布的,
![](https://tecdat.cn/wp-content/uploads/2019/07/image-634.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-636.gif)
在正常之前,后验可以通过共轭来计算
![](https://tecdat.cn/wp-content/uploads/2019/07/image-635.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-639.gif)
Backfitting MCMC如下进行。首先,初始化所有测试版除外。这完全是任意的 – 您可以从任何参数开始。然后,在每个Gibbs迭代中,
- 计算与值在当前迭代。来自后验的样本 以电流抽取为条件。
- 计算与值在当前迭代。注意,使用步骤1中的值。来自后部的样本 。
- 对所有beta参数继续此过程。
- 绘制完所有参数后,进行采样。这个后验是另一个反伽马。
![](https://tecdat.cn/wp-content/uploads/2019/07/image-637.gif)
术语反向拟合似乎是合适的,因为在每次迭代中,我们都“退出” 我们想要使用其他测试版进行采样的分布。
![](https://tecdat.cn/wp-content/uploads/2019/07/image-638.gif)
为了获得拟合的回归线,我们需要从后验预测分布中进行采样。我们在每个Gibbs迭代中的步骤4之后通过绘制值来执行此操作
![](https://tecdat.cn/wp-content/uploads/2019/07/image-643.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-641.gif)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-640.gif)
上标表示使用来自Gibbs迭代的值的参数。
![](https://img-blog.csdnimg.cn/20190422160238531.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzE5NjAwMjkx,size_16,color_FFFFFF,t_70)
![](https://tecdat.cn/wp-content/uploads/2019/07/image-642.gif)
可下载资源
关于作者
Kaizong Ye是拓端研究室(TRL)的研究员。在此对他对本文所作的贡献表示诚挚感谢,他在上海财经大学完成了统计学专业的硕士学位,专注人工智能领域。擅长Python.Matlab仿真、视觉处理、神经网络、数据分析。
本文借鉴了作者最近为《R语言数据分析挖掘必知必会 》课堂做的准备。
非常感谢您阅读本文,如需帮助请联系我们!