楼主: raymond87
10094 6

[回归分析求助] margin 和 predict 求得的预测值有何区别? [推广有奖]

  • 1关注
  • 0粉丝

已卖:120份资源

本科生

41%

还不是VIP/贵宾

-

威望
0
论坛币
24 个
通用积分
19.7596
学术水平
6 点
热心指数
12 点
信用等级
4 点
经验
749 点
帖子
67
精华
0
在线时间
87 小时
注册时间
2008-4-20
最后登录
2018-6-7

楼主
raymond87 发表于 2014-5-29 19:42:54 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
小弟在做完回归模型后,想要看看符合特定条件的个案所对应的概率。但是用margin 和 predict 求得的概率不一致;还请知道的坛友帮忙解答一下。


为了便于解释,我用stata自带的数据做演示。

webuse margex
reg y i.sex i.group
margin sex

得到的结果是:
------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         sex |
          0  |   60.56034   .5781782   104.74   0.000     59.42713    61.69355
          1  |   78.88236   .5772578   136.65   0.000     77.75096    80.01377
------------------------------------------------------------------------------

可以看到,sex==1 时,概率为78.88

如果我用predict 预测 sex==1的概率的话,
predict   p1   if    sex==1
tab        p1                          //  p1有三个取值,因为group有三个取值。

     Fitted |
     values |      Freq.     Percent        Cum.
------------+-----------------------------------
   71.64348 |        984       65.51       65.51
    79.6811 |        452       30.09       95.61
   90.28271 |         66        4.39      100.00
------------+-----------------------------------
      Total |      1,502      100.00


然后sum一下
sum  p1

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
          y1 |      1502    74.88129    4.923423   71.64348   90.28271



——————————————————————————————————————————————

这样,用margin得出的sex==1的概率值就是78.88;
而用predict得出的sex==1时的概率值就是74.88。

那么请问,如果我想知道性别为1的概率,到底该用哪一个呢?

谢谢大家!



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:predict margin Pred edi 预测值 模型

沙发
raymond87 发表于 2014-5-30 19:12:46
自己顶一个

藤椅
hplcdadong 发表于 2014-5-31 06:14:10
They should be the same, but you have to understand how they calculate the probability using "margins":

webuse margex,clear
reg y i.sex i.group
margins sex          //here you are actually calculating "average margin"

preserve
replace sex=1
predict p
sum p              //this should be the same as that by above "margins sex" when sex=1
restore
已有 2 人评分经验 学术水平 热心指数 信用等级 收起 理由
Sunknownay + 2 + 2 + 2 热心帮助其他会员
crystal8832 + 10 + 1 鼓励积极发帖讨论

总评分: 经验 + 10  学术水平 + 2  热心指数 + 3  信用等级 + 2   查看全部评分

板凳
raymond87 发表于 2014-5-31 15:20:24
hplcdadong 发表于 2014-5-31 06:14
They should be the same, but you have to understand how they calculate the probability using "margin ...
Thank you very much !

I have just run your codes and received the same results ,using  the commands of  "margins" and "predict"  respectively.

May I ask some additional questions,please?
What does it serve when I treat every obervation as if it is a male (or a female), just as what the command of margins have done?

Or, when I have to calculate the probility of the group of male, which is a proper way between the  following two ways ?
(1) Calculating all the obs while treating the female samples as male samples? (margins)
(2)Only  Calculating the male samples ( reg y i.sex i.group ;  predict p1 if sex==1)

Thanks again !

报纸
raymond87 发表于 2014-6-1 18:41:40
顶上去、、、

地板
hplcdadong 发表于 2014-6-3 05:06:20
Whether or not to use "predict" or "margins" depends on your study aim. The major aim of margins is to make it much easier to explain regression results.

Every time when we deal with "margins", it's better to have a clear understanding of the following basic concepts:

1) The aim of "margins" and "marginal effects"
2) What kinds of margins do we have (average margins, margins at means and margins at the representative values; actually in the real world in most cases it is a mixer of "margins at the representative values" with "average margins" or "margins atmeans")?
3) What kinds of marginal effects do we have (the similar issues as in 2))?

The following two articles will help you a lot (you can get them easily in this forum and the internet):

*1. Richard Williams. Using the margins command to estimate and interpret adjusted      
predictions and marginal effects. Stata J. 2012;12:308-331
*2. Bill Rising . How to get an edge with margins and marginsplot. Presenations at  
2012 UK Stata Users Group Meeting, London, 12 Sep 2012


Good luck!
已有 2 人评分学术水平 热心指数 信用等级 收起 理由
Sunknownay + 2 + 2 + 2 热心帮助其他会员
yizst2 + 1 + 1 精彩帖子

总评分: 学术水平 + 3  热心指数 + 3  信用等级 + 2   查看全部评分

7
raymond87 发表于 2014-6-4 16:39:38
hplcdadong 发表于 2014-6-3 05:06
Whether or not to use "predict" or "margins" depends on your study aim. The major aim of margins is  ...
Thank you very much !

Words cannot express my appreciation for your patient and detailed explanation !{:3_48:}

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-5-5 04:57