使用所有变量进行回归而不显式声明它们

时间:2019-12-03 22:28:34

标签: function stata

我有一个数据集,我想在Stata中对其进行回归。我想将其中一个虚拟变量作为基础,因此我在ib1.month1命令中使用了regress

是否可以在我的回归中包括数据集中的所有其他变量,而无需再次明确地写出每个变量?

1 个答案:

答案 0 :(得分:2)

您可以使用ds命令:

sysuse auto, clear
drop make 

ds price foreign, not 

regress price ib1.foreign `r(varlist)' 

      Source |       SS           df       MS      Number of obs   =        69
-------------+----------------------------------   F(10, 58)       =      8.66
       Model |   345416162        10  34541616.2   Prob > F        =    0.0000
    Residual |   231380797        58  3989324.09   R-squared       =    0.5989
-------------+----------------------------------   Adj R-squared   =    0.5297
       Total |   576796959        68  8482308.22   Root MSE        =    1997.3

------------------------------------------------------------------------------
       price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
     foreign |
   Domestic  |  -3334.848   957.2253    -3.48   0.001    -5250.943   -1418.754
         mpg |  -21.80518    77.3599    -0.28   0.779    -176.6578    133.0475
       rep78 |   184.7935   331.7921     0.56   0.580    -479.3606    848.9476
    headroom |  -635.4921   383.0243    -1.66   0.102    -1402.198    131.2142
       trunk |   71.49929   95.05012     0.75   0.455    -118.7642    261.7628
      weight |   4.521161   1.411926     3.20   0.002     1.694884    7.347438
      length |  -76.49101   40.40303    -1.89   0.063    -157.3665     4.38444
        turn |  -114.2777   123.5374    -0.93   0.359    -361.5646    133.0092
displacement |   11.54012   8.378315     1.38   0.174    -5.230896    28.31115
  gear_ratio |  -318.6479    1124.34    -0.28   0.778    -2569.259    1931.964
       _cons |   13124.34     6726.3     1.95   0.056    -339.8103     26588.5
------------------------------------------------------------------------------