产品描述
Stata软件中贝叶斯分析可以根据您研究问题的复杂程度,可以简单或复杂。
• 数以千计的内置模型
• 添加自己的模型
• 用bayes:作为命令的前缀
• 自适应Metropolis–Hastings
• 多链
• 收敛诊断
• 探索分布
• 模型拟合优度
• 后验预测p值
• 假设检验
• 模型比较
• 预测
• 模型平均(新)
• 更多
拟合回归模型
线性回归
• bayes: regress y x1 x2 x3
Logistic回归
• bayes: logistic z x1 x2 x3
多层回归
• bayes: mixed y x1 x2 x3 || id:
向量自回归(VAR)
• bayes: var y1 y2 y3, lags(1/3) exog(x1 x2)
*多链
• bayes, nchains(4): logistic z x1 x2 x3
拟合一般模型
多层Meta分析模型
• bayesmh lnOR U[trial], noconstant likelihood(normal(var))
prior({U[trial]}, normal({theta},{tau2}))
prior({theta}, normal(0,10000))
prior({tau2}, igamma(0.0001,0.0001))
block({theta tau2}, gibbs split)
非线性Poisson模型:变点分析
• bayesmh count, likelihood(dpoisson({mu1}*sign(year<{cp})+{mu2}*sign(year>={cp})))
prior({mu1 mu2}, flat)
prior({cp}, uniform(1851,1962))
initial({mu1 mu2} 1 {cp} 1906)
检验收敛性
• bayesgraph diagnostics {cp}
(ratio: {mu1}/{mu2})
编写自己的模型
Hurdle模型
• bayesmh (hours age) (hours0 commute), llevaluator(mychurdle, parameters({lnsig}))
prior({hours:} {hours0:} {lnsig}, flat)
进行推断
探索分布
• bayesgraph histogram {U[trial]}, ...
注:边际似然( ML )是用Laplace - Metropolis近似来计算的。
使用GUI执行任何分析
回归模型
只需在回归命令前面加上bayes:
• 支持60多个似然模型,包括多层级,生存,GLM,VAR,DSGE等
• 删失、截断、样本选择
• 直观优雅的模型设定
• 默认和自定义先验
• 全面的贝叶斯功能支持
线性回归
对于系数使用默认的正态先验,对于方差使用逆伽玛先验
• bayes: regress y x1 x2
使用Gibbs抽样
• bayes, gibbs: regress y x1 x2
Logistic回归
对系数使用默认的正态先验
• bayes: logistic y x1 x2
对x1和x2上的系数使用自定义的Cauchy先验
• bayes, prior({y:x1 x2}, cauchy(0,2.5)):
logistic y x1 x2
检验系数在x1上的收敛性
• bayesgraph diagnostics {y:x1}
检验系数{ y:x1 }大于4
• bayestest interval {y:x1}, lower(4)
生存回归
声明生存数据
• stset time, failure(died)
拟合贝叶斯指数回归
• bayes, saving(mcmc_exp): streg x1 x2,distribution(exponential)
• estimates store exp
拟合贝叶斯Weibull回归
• bayes, saving(mcmc_weibull): streg x1 x2,distribution(weibull)
• estimates store weibull
使用后验概率对模型进行比较
• bayestest model exp weibull
其他回归模型
有序Logistic回归
• bayes: ologit y x1 x2
条件Logistic回归
• bayes: clogit y x1 x2, group(id)
Poisson回归
• bayes: poisson y x1 x2
截断Poisson回归
• bayes: tpoisson y x1 x2, 11(10)
零膨胀负二项回归
• bayes: zinb y x1 x2, inflated(z1 z2)
Tobit回归
• bayes: tobit y x1 x2, ul(20)
异方差概率回归
• bayes: hetprobit y x1 x2, het(xhet)
Heckman选择
• bayes: heckman y x1 x2, select(x1 x2 x3)
多元回归
• bayes: mvreg y1 y2 y3 = x1 x2
多层级回归
• bayes: mixed y x1 x2 || id:
向量自回归( VAR )
• bayes: var y1 y2 y3, lags(1/3) exog(x1 x2)
更多
• bayes: ...
多层级模型
群体数量少?
层次众多?
想要随机效应的后验分布?
• 连续、删截、二进制、有序和计数结果
• 支持GLM和生存方法
• 随机截距和系数
• 嵌套和交叉效应
• 多层级结构
• 随机效应协方差结构
• 多变量非线性多级模型
• 全面的贝叶斯功能支持
两级模型:随机截距
School随机截取math5对math3的拟合回归
• bayes: mixed math5 math3 || school:
显示随机效应的估计值
•. bayes, showreffects:
mixed math5 math3 || school:
为系数*自定义统一先验,而不是默认的正态先验
• bayes, prior({math5:math3 _cons},
uniform(-50,50)):
mixed math5 math3 || school:
绘制随机截距的后验分布
• bayesgraph histogram {U0}, byparm
两级模型:随机系数
在math3上通过School加随机系数
• bayes: mixed math5 math3 || school: math3
*随机效应的非结构化协方差
• bayes: mixed math5 math3 || school: math3,covariance (unstructured)
三级模型
为嵌套在school中的teacher添加随机拦截
• bayes: mixed math5 math3 || school: || teacher:
交叉效应模型
包括中小学的交叉随机效应
• bayes: mixed math5 math3 || _all: R.primary || secondary:
其他多级模型
Logistic回归
• bayes: melogit y x1 x2 || id:
Poisson回归
• bayes: mepoisson y x1 x2 || id:
广义线性模型
• bayes: meglm y x1 x2 || id:,family(binomial) link(cloglog)
有序logistic回归
• bayes: meologit y x1 x2 || id:
生存回归
• bayes: mestreg x1 x2 || id:,distribution(weibull)
更多
• bayes: any multilevel command ...
多重链、预测及更多
• 多重链
• Gelman–Rubin收敛诊断
• 贝叶斯预测
• 模拟值的后验汇总
• MCMC复制
• 后验预测p值
两级模型:随机系数
使用bayes:的nchains ( )选项或bayesmh来模拟多重链
将y对协变量x1至x10进行拟合回归,生成3条链
Gelman-Rubin收敛诊断
检验Gelman - Rubin收敛诊断
直观地探究x6的系数收敛情况
• bayesgraph diagnostics {y:x6}
贝叶斯预测
• 预测新值
• 使用后验预测检验检查模型拟合
• 计算预测值的函数
• *您自己的预测函数
• 获得预测值的后验总结
• 生成MCMC复制
• 计算后验预测p值
贝叶斯预测是根据后验预测分布模拟的结果值。它们对于预测新的结果值和检验模型的拟合度是有用的。我们使用bayesmh来拟合一个通用的贝叶斯模型。
• bayesmh y ..., likelihood(...) prior(...)
预测的后验总结
计算所有观测值的后验平均值和可信区间,并将其存储在变量pmean、cril和criu中
• bayespredict pmean, mean
• bayespredict cril criu, cri
后验预测p值
模拟对结果y的预测,并保存在y _ pred . dta中
• bayespredict {_ysim}, saving(y_pred)
计算后验预测p值;使用Mata的内置功能和您自己的
MCMC复制
计算6个MCMC重复,并将其存储在变量yrep1、yrep2等中。
• bayesreps yrep*, nreps(6)
列出前10个观察结果
MCMC重复的图分布
贝叶斯计量经济学
• Panel-data模型
• 动态预测
• VAR模型
• IRF和FEVD分析
• 线性和非线性DSGE模型
• 更多
Stata 18贝叶斯分析新功能
• 贝叶斯模型平均(BMA)
– 线性回归的BMA
– 影响模型和重要预测因子
– 回归系数的后验分布图
– 模型-概率图
– 变量-包含映射
– 模型拟合和预测性能
北京天演融智软件有限公司(科学软件网)是STATA软件在中国的授权经销商,为中国的软件用户提供优质的软件销售和培训服务。
手机网站
微信号码
地址:会员服务到期
联系人:会员服务到期
微信帐号:会员服务到期