加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

esttab输出分组ttest结果

(2014-07-07 18:55:15)
标签:

股票

分类: 04STATA数据处理

http://bbs.pinggu.org/thread-2438126-1-1.html

http://bbs.pinggu.org/thread-2438091-1-1.html

 

现有若干变量y1,y2,y3,y4,y5,y6. 有两分组变量:A,B。A,B分别有三个取值1,2,3
需要对每一个y输出如下ttest (数值和p-value)表格:
                               A1                                          A2                                           A3                                     A1-A3

B1       ttest y==0 if A==1&B==1        ttest y==0 if A==2&B==1        ttest y==0 if A==3&B==1      ttest y if B==1 & A˜=2, by A  

B2       ttest y==0 if A==1&B==2        ttest y==0 if A==2&B==2        ttest y==0 if A==3&B==2      ttest y if B==2 & A˜=2, by A  

B3       ttest y==0 if A==1&B==3        ttest y==0 if A==2&B==3        ttest y==0 if A==3&B==3      ttest y if B==3 & A˜=2, by A 

B1-B3  ttest y if A==1 & B˜=2, by B     ttest y if A==2 & B˜=2, by B    ttest y if A==3 & B˜=2, by B 

需要用esttab对每一个y输出如上表格,每一个单元格显示分组均值(或差值)和p-value(如上ttest命令的结果)

哪位高人有什么好办法么?非常感谢!
由于网页版面格式受限,示例的格式不清楚,下面的excel文档是格式的要求

 


use "reg example.dta", clear
g y=1
expandcl 6,cl(y) gen(dependent)
forv i=1/6{
replace y=y`i' if dependent==`i'
}
statsby _b _se,clear by(dependent A): reg y x*

 

http://s5/mw690/001Rt2X3gy6KgpksCQ474&690

 


        * t-test

        . sysuse auto,clear

        . ttable3 price wei len mpg, by(foreign)

        . ttable3 price wei len mpg, by(foreign) f(%8.2f)


        * Median test

        . ttable3 price wei len mpg, by(foreign) median


        * Restrict to two-groups

        . tab rep78

        . ttable3 price wei len mpg if rep78==3|rep78==4, by(rep78)


 

    ----+  Save in Excel or Word +-------------------------------------------


    you can use the user-written logout command to export the results into

    Excel or Word:


        . logout, save(Tab2_corr) excel replace: ttable3 price wei len mpg,

            by(foreign) notitle


 

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有