【问题标题】:Summarizing statistics (mean, sd) in Stata, when there are three dichotomous explanatory variables当存在三个二分解释变量时,在Stata中汇总统计数据(平均值,标准差)
【发布时间】:2015-02-05 01:44:27
【问题描述】:

当存在三个二分 IV 时,我正在尝试为 DV 创建一个汇总统计表(平均值,标准差)。使用命令tab IV1 Iv2, sum (DV) 我可以只为两个IV 变量创建一个汇总统计表,但不能为三个。但是,我需要三个 IV 及其交互的摘要统计信息。有什么办法吗?替代命令?谢谢!

【问题讨论】:

  • 对于一些宗教人士来说,DV 的意思是“上帝愿意”。对于许多经济学家来说,IV 意味着“工具变量”。您的意思是因变量和自变量,但这两个缩写在统计科学中都不是通用的。

标签: stata summary


【解决方案1】:

你可以像这样创建一个交互变量:

webuse nlswork
egen interaction = group(race nev_mar union), label
tab interaction, sum(ln_wage)

【讨论】:

    【解决方案2】:

    在这里,我使用与 Dimitriy 相同的精心挑选的沙箱。

    webuse nlswork, clear 
    quietly statsby n=r(N) mean=r(mean)  sd=r(sd), by(race nev_mar union)  subsets clear: summarize ln_wage
    egen nvars = rownonmiss(race nev_mar union )
    sort nvars race nev_mar union 
    format mean sd %4.3f 
    l race-sd, sepby(nvars) noobs 
    
    +-------------------------------------------------+  
    |  race   nev_mar   union       n    mean      sd |
    |-------------------------------------------------|
    |     .         .       .   28534   1.675   0.478 |
    |-------------------------------------------------|
    | white         .       .   13590   1.796   0.464 |
    | black         .       .    5426   1.647   0.458 |
    | other         .       .     211   1.890   0.510 |
    |     .         0       .   15509   1.758   0.466 |
    |     .         1       .    3718   1.740   0.477 |
    |     .         .       0   14720   1.702   0.466 |
    |     .         .       1    4507   1.927   0.432 |
    |-------------------------------------------------|
    | white         0       .   11399   1.794   0.462 |
    | white         1       .    2191   1.808   0.474 |
    | white         .       0   10774   1.753   0.465 |
    | white         .       1    2816   1.961   0.422 |
    | black         0       .    3955   1.651   0.455 |
    | black         1       .    1471   1.634   0.467 |
    | black         .       0    3779   1.551   0.432 |
    | black         .       1    1647   1.867   0.440 |
    | other         0       .     155   1.893   0.553 |
    | other         1       .      56   1.881   0.369 |
    | other         .       0     167   1.865   0.510 |
    | other         .       1      44   1.983   0.507 |
    |     .         0       0   11936   1.707   0.464 |
    |     .         0       1    3573   1.930   0.429 |
    |     .         1       0    2784   1.682   0.474 |
    |     .         1       1     934   1.914   0.444 |
    |-------------------------------------------------|
    | white         0       0    9071   1.751   0.462 |
    | white         0       1    2328   1.961   0.423 |
    | white         1       0    1703   1.766   0.479 |
    | white         1       1     488   1.958   0.420 |
    | black         0       0    2745   1.556   0.433 |
    | black         0       1    1210   1.867   0.429 |
    | black         1       0    1034   1.536   0.430 |
    | black         1       1     437   1.866   0.469 |
    | other         0       0     120   1.856   0.550 |
    | other         0       1      35   2.020   0.553 |
    | other         1       0      47   1.888   0.391 |
    | other         1       1       9   1.842   0.235 |
    +-------------------------------------------------+
    

    因此,您可以紧凑地获得所有三向组合、所有双向、所有单向和整体摘要。此外,此摘要集现在是内存中的数据集,因此您可以进一步操作它、导出它等等。

    【讨论】:

      猜你喜欢
      • 2017-05-21
      • 1970-01-01
      • 2022-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-28
      • 2019-10-25
      • 2021-06-24
      相关资源
      最近更新 更多