在stata中隔离面板数据

时间:2014-11-25 03:27:12

标签: stata

我是Stata的初学者,我正试图找出面板数据分析。我想弄清楚的第一件事是如何对常见变量进行汇总统计,比如说年份。我的数据看起来像

  

2010 5

     

2009 5

     

2010 3

     

2008 2

     

2010 12

     

2009 ...

显然,我有更多的数据,但我想弄清楚某一年的平均值(例如2010年)

我是否需要使用我的命令:mean variable, i(year)

1 个答案:

答案 0 :(得分:1)

有几种方法可以给猫皮肤涂抹:

. webuse nlswork, clear
(National Longitudinal Survey.  Young Women 14-26 years of age in 1968)

. bysort year: sum  ln_wage

----------------------------------------------------------------------------------------------------------------------------------------------------
-> year = 68

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     ln_wage |      1375     1.44136    .3884235   .0176546   2.853805

----------------------------------------------------------------------------------------------------------------------------------------------------
-> year = 69

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     ln_wage |      1232    1.531032    .3766929   .0240972   3.204134

----------------------------------------------------------------------------------------------------------------------------------------------------
-> year = 70

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     ln_wage |      1686    1.507048    .3984743   .0240972   3.005013

----------------------------------------------------------------------------------------------------------------------------------------------------
-> year = 71

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     ln_wage |      1851    1.546859     .414415   .0253174   3.285639

----------------------------------------------------------------------------------------------------------------------------------------------------
-> year = 72

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     ln_wage |      1693    1.567283    .4319477   .0682788   4.242752

----------------------------------------------------------------------------------------------------------------------------------------------------
-> year = 73

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     ln_wage |      1981    1.578448    .4297621   .0080322   3.757158

----------------------------------------------------------------------------------------------------------------------------------------------------
-> year = 75

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     ln_wage |      2141    1.579865    .4077728   .0622126   3.925446

----------------------------------------------------------------------------------------------------------------------------------------------------
-> year = 77

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     ln_wage |      2171    1.658813    .4308272   .0044871   3.623841

----------------------------------------------------------------------------------------------------------------------------------------------------
-> year = 78

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     ln_wage |      1964     1.71629    .4327877   .0684925   4.029306

----------------------------------------------------------------------------------------------------------------------------------------------------
-> year = 80

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     ln_wage |      1847    1.729773    .4442248   .1438704   4.199647

----------------------------------------------------------------------------------------------------------------------------------------------------
-> year = 82

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     ln_wage |      2085    1.726432      .46796          0   4.254619

----------------------------------------------------------------------------------------------------------------------------------------------------
-> year = 83

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     ln_wage |      1987    1.768276    .5140673          0   4.828314

----------------------------------------------------------------------------------------------------------------------------------------------------
-> year = 85

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     ln_wage |      2085    1.831842    .5063103   .0300107   4.025415

----------------------------------------------------------------------------------------------------------------------------------------------------
-> year = 87

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     ln_wage |      2164    1.841969    .5201446   .0441609   4.005049

----------------------------------------------------------------------------------------------------------------------------------------------------
-> year = 88

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     ln_wage |      2272    1.879937    .5960048   .0049397   5.263916

. tabstat ln_wage , by(year) stat(mean)

Summary for variables: ln_wage
     by categories of: year (interview year)

    year |      mean
---------+----------
      68 |   1.44136
      69 |  1.531032
      70 |  1.507048
      71 |  1.546859
      72 |  1.567283
      73 |  1.578448
      75 |  1.579865
      77 |  1.658813
      78 |   1.71629
      80 |  1.729773
      82 |  1.726432
      83 |  1.768276
      85 |  1.831842
      87 |  1.841969
      88 |  1.879937
---------+----------
   Total |  1.674907
--------------------

. table year, c(mean ln_wage)

-------------------------
interview |
year      | mean(ln_wage)
----------+--------------
       68 |       1.44136
       69 |      1.531032
       70 |      1.507048
       71 |      1.546859
       72 |      1.567283
       73 |      1.578448
       75 |      1.579865
       77 |      1.658813
       78 |       1.71629
       80 |      1.729773
       82 |      1.726432
       83 |      1.768276
       85 |      1.831842
       87 |      1.841969
       88 |      1.879937
-------------------------