如何进行回归以报告所有因素变量? [英] How to run a regression which report all factor variables?

查看:112
本文介绍了如何进行回归以报告所有因素变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想运行一个regression来计算factor变量的所有级别的估计值.默认情况下,Stata忽略一个虚拟对象作为base级别.

I want to run a regression that calculates the estimated values for all levels of a factor variable. By default, Stata omits one dummy as a base level.

当我使用allbaselevels选项时,它仅显示base级别的零值:

When I use the allbaselevels option, it just shows a zero value for a base level:

regress adjusted_volume i.rounded_time, allbaselevels

当常量删除后,SAS显示所有类别变量的估计值.

SAS shows all the estimated values of categorical variables when the constant has been removed.

我如何在Stata中做同样的事情?

How can i do the same thing in Stata?

推荐答案

选项allbaselevels是几个显示选项之一,当报告来自诸如.但是将其指定为选项不会对计算产生任何影响.

The option allbaselevels is one of several display options, which can be useful when reporting results from estimation commands such as regress. But specifying it as an option does not make any difference in the calculations.

Stata 手册指出:

"... allbaselevels选项与基本级别非常相似,除了allbaselevels列出了交互以及主要效果中的基本级别. allbaselevels将使输出更易于理解..."

"...The allbaselevels option is much like baselevels, except allbaselevels lists base levels in interactions as well as in main effects. Specifying allbaselevels will make the output easier to understand..."

您真正要寻找的是 ibn. 因子变量运算符:

What you are actually looking for is the ibn. factor-variable operator:

. sysuse auto, clear
(1978 Automobile Data)

. regress mpg ibn.rep78
note: 5.rep78 omitted because of collinearity

  Source |       SS           df       MS          Number of obs   =        69
-------------+----------------------------------   F(4, 64)        =      4.91
   Model |  549.415777         4  137.353944       Prob > F        =    0.0016
Residual |  1790.78712        64  27.9810488       R-squared       =    0.2348
-------------+----------------------------------   Adj R-squared   =    0.1869
   Total |   2340.2029        68  34.4147485       Root MSE        =    5.2897

------------------------------------------------------------------------------
     mpg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
   rep78 |
      1  |  -6.363636   4.066234    -1.56   0.123    -14.48687    1.759599
      2  |  -8.238636   2.457918    -3.35   0.001    -13.14889    -3.32838
      3  |  -7.930303    1.86452    -4.25   0.000    -11.65511   -4.205497
      4  |   -5.69697    2.02441    -2.81   0.006    -9.741193   -1.652747
      5  |          0  (omitted)
         |
   _cons |   27.36364   1.594908    17.16   0.000     24.17744    30.54983
------------------------------------------------------------------------------

当然,您还需要指定noconstant选项:

Of course, you also need to specify the noconstant option:

. regress mpg ibn.rep78, noconstant

  Source |       SS           df       MS          Number of obs   =        69
-------------+----------------------------------   F(5, 64)        =    227.47
   Model |  31824.2129         5  6364.84258       Prob > F        =    0.0000
Residual |  1790.78712        64  27.9810488       R-squared       =    0.9467
-------------+----------------------------------   Adj R-squared   =    0.9426
   Total |       33615        69  487.173913       Root MSE        =    5.2897

------------------------------------------------------------------------------
     mpg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
   rep78 |
      1  |         21   3.740391     5.61   0.000     13.52771    28.47229
      2  |     19.125   1.870195    10.23   0.000     15.38886    22.86114
      3  |   19.43333   .9657648    20.12   0.000       17.504    21.36267
      4  |   21.66667   1.246797    17.38   0.000      19.1759    24.15743
      5  |   27.36364   1.594908    17.16   0.000     24.17744    30.54983
------------------------------------------------------------------------------

这篇关于如何进行回归以报告所有因素变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆