在Stata中的汇总统计表中添加一列差异
如果我使用 table
在 Stata 中制作双向汇总统计表,我可以添加另一列作为其他两列的差异吗?
假设我有三个变量 (a, b, c
)。我在 a
和 b
上生成五分位数,然后在每个五分位数-五分位数交叉点生成 c
均值的双向表。我想生成第六列,它是 b
的每个五分位数的 b
的顶部和底部五分位数之间的平均值 c
的差异。
我可以为每个五分位数-五分位数交集生成均值 c
表,但我无法找出差异列。
* generate data
clear
set obs 2000
generate a = rnormal()
generate b = rnormal()
generate c = rnormal()
* generate quantiles for for a and b
xtile a_q = a, nquantiles(5)
xtile b_q = b, nquantiles(5)
* calculate the means of each quintile intersection
table a_q b_q, c(mean c)
* if I want the top and bottom b quantiles
table a_q b_q if b_q == 1 | b_q == 5, c(mean c)
更新:这是我想要执行的操作的示例。
If I make a two way summary statistics table in Stata using table
, can I add another column that is the difference of two other columns?
Say that I have three variables (a, b, c
). I generate quintiles on a
and b
then generate a two-way table of means of c
in each quintile-quintile intersection. I would like to generate a sixth column that is the difference of mean c
between the top and bottom quintiles of b
for each quintile of a
.
I can generate the table of mean c
for each quintile-quintile intersection, but I can't figure out the difference column.
* generate data
clear
set obs 2000
generate a = rnormal()
generate b = rnormal()
generate c = rnormal()
* generate quantiles for for a and b
xtile a_q = a, nquantiles(5)
xtile b_q = b, nquantiles(5)
* calculate the means of each quintile intersection
table a_q b_q, c(mean c)
* if I want the top and bottom b quantiles
table a_q b_q if b_q == 1 | b_q == 5, c(mean c)
Update: Here's an example of what I would like to do.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
collapse
命令,您可以创建您想要的自定义表格。然后你应该在输出中获得类似这样的内容:
如果你不太熟悉 Stata,以下帮助页面可能有助于理解代码
With the
collapse
command you can create customized tables like the one you have in mind.Then you should obtain something like this in your output:
If you are not very familiar with Stata, the following help pages might be useful in understanding the code