我有一组数据,有一个因变量,也就是一个计数,还有几个自变量。我的主要自变量是大美元值。如果我将美元值除以10,000(使系数易于管理),则模型(负二项式和零膨胀负二项数)在Stata中运行,我可以用置信区间生成预测数。但是,从理论上讲,采用该变量的自然日志更符合逻辑。当我这样做,模型仍然运行,但现在预测的计数范围在0.22-0.77左右。如何解决这个问题,以便预测的计数正确生成?
发布于 2016-09-23 22:21:52
您的问题没有显示任何代码或数据。没有这两种成分,几乎不可能知道出了什么问题。你的问题读起来是“我对其他事情做了一些事情,结果令人惊讶。”为了提出一个好的问题,您应该使用每个人都可以访问的数据集来复制您的编码方法,比如rod93。
下面是我的尝试,它展示了两个模型与nbreg的相当相似的预测:
webuse rod93, clear
replace exposure = exposure/10000
nbreg deaths exposure age_mos, nolog
margins
predictnl d1 =predict(n), ci(lb1 ub1)
/* Compare the prediction for the first obs by hand */
di exp(_b[_cons]+_b[age_mos]*age_mos[1]+_b[exposure]*exposure[1])
di d1[1]
gen ln_exp = ln(exposure)
nbreg deaths ln_e age_mos, nolog
margins
predictnl d2 =predict(n), ci(lb2 ub2)
/* Compare the prediction for the first obs by hand */
di exp(_b[_cons]+_b[age_mos]*age_mos[1]+_b[ln_e]*ln(exposure[1]))
di d2[1]
sum d? lb* ub*, sep(2)这产生了非常相似的预测和置信区间:
. sum d? lb* ub*, sep(2)
Variable | Obs Mean Std. Dev. Min Max
-------------+---------------------------------------------------------
d1 | 21 84.82903 25.44322 12.95853 104.1868
d2 | 21 85.0432 25.24095 32.87827 105.1733
-------------+---------------------------------------------------------
lb1 | 21 64.17752 23.19418 1.895858 80.72885
lb2 | 21 59.80346 22.01917 10.9009 79.71531
-------------+---------------------------------------------------------
ub1 | 21 105.4805 29.39726 24.02121 152.7676
ub2 | 21 110.2829 29.16468 51.76427 143.856https://stackoverflow.com/questions/39665658
复制相似问题