Hi everybody,
I have the following dataset:
My aim is to contain a table of means of "Exret" sorted by size (categorical variable that goes from 1 to 5) and B2M (categorical variable that goes from 1 to 5). I would like to sort the Exret means on the rows by size and on the columns by B2M. To have an idea of what I mean:
table size B2M, c(mean Exret)
However, I need to add to modifications to this table. First, I have a dummy variable ("dall") according to which I would sort the variable Exret, i.e. I need a table as the one produced with the code of above but where every entry should be divided into the categories of "dall" (which means zero and one). Furthermore, every entry should report the t-statistic for the null hypothesis of a zreo mean. I attach below a visual example of what I would like to do.
I tried to create two distinct variable of Exret, one for each value of "dall" but I can get only two distinct table and I want a unique one. Furthermore, I can't find how to get the t-statistic below the mean.
I have the following dataset:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(date PFnumber Return MeR SMB HML RF) byte(dunemp dinflation dfomc duninfl dunfomc dinflfomc dall) float Exret double firstbeta float(firstbetastatic size B2M exretA exretN) 2758 1 -.46 .04 -.3 .18 .016 0 0 0 0 0 0 0 -.476 1.4879545137011279 1.0128056 1 1 . -.476 11611 5 1.19 .64 .75 -.1 .018 0 0 0 0 0 0 0 1.172 .529238700062847 .7444988 1 5 . 1.172 6312 2 .08 .03 .12 .27 .019 0 0 0 0 0 0 0 .061 .5535918342666777 .8976381 1 2 . .061 9611 5 .04 0 .19 -.4 .024 0 0 0 0 0 0 0 .015999999 .4749225004099712 .7444988 1 5 . .015999999 13907 4 .41 1.01 .29 -.53 .021 0 0 0 0 0 0 0 .389 .469481372849392 .7557166 1 4 . .389 14266 3 -.11 -.66 .41 .15 .019 0 0 0 0 0 0 0 -.129 .6212392009081008 .7998899 1 3 . -.129 5205 3 -.18 0 -.06 0 .036 0 0 0 0 0 0 0 -.216 .831576466663534 .7998899 1 3 . -.216 17447 3 -.59 -.27 -.18 -.29 .014 0 0 0 0 0 0 0 -.604 1.0311082397263975 .7998899 1 3 . -.604 4140 5 -.76 -.57 .23 -.17 .015 0 0 0 0 0 0 0 -.775 1.0797220465688908 .7444988 1 5 . -.775 15504 5 -.44 -1.1 -.28 .43 .006 0 1 0 1 0 1 1 -.446 .4334751155209491 .7444988 1 5 -.446 . 12263 3 -.12 .54 -.51 .08 .011 0 0 0 0 0 0 0 -.131 .5380154342389192 .7998899 1 3 . -.131 3728 3 .06 .39 -.15 -.46 .027 0 0 0 0 0 0 0 .033 1.1760068623254416 .7998899 1 3 . .033 7565 5 .7 1.5 -.31 -1.09 .036 0 0 1 0 1 1 1 .664 .69895095080145 .7444988 1 5 .664 . 15075 5 .94 2.87 -.35 -1.36 .02 0 0 0 0 0 0 0 .92 .2934694266349103 .7444988 1 5 . .92 5919 4 .21 .98 -.49 .39 .017 0 0 0 0 0 0 0 .193 .7090840191200938 .7557166 1 4 . .193 10233 5 1.03 .74 -.08 .29 .015 0 0 0 0 0 0 0 1.015 .5712486792705823 .7444988 1 5 . 1.015 12822 1 .84 .13 .17 -.2 .021 0 0 0 0 0 0 0 .8189999 .7636763451047806 1.0128056 1 1 . .8189999 13207 2 .28 -.19 .37 .27 .02 0 0 0 0 0 0 0 .26 .7328015471319895 .8976381 1 2 . .26 2484 2 -.24 -.31 .04 .05 .022 0 1 0 1 0 1 1 -.262 1.2391570819266435 .8976381 1 2 -.262 . 3065 2 .5 -.13 .46 -.23 .02 0 0 0 0 0 0 0 .48 1.4494875065537562 .8976381 1 2 . .48 end format %td date
table size B2M, c(mean Exret)
However, I need to add to modifications to this table. First, I have a dummy variable ("dall") according to which I would sort the variable Exret, i.e. I need a table as the one produced with the code of above but where every entry should be divided into the categories of "dall" (which means zero and one). Furthermore, every entry should report the t-statistic for the null hypothesis of a zreo mean. I attach below a visual example of what I would like to do.
I tried to create two distinct variable of Exret, one for each value of "dall" but I can get only two distinct table and I want a unique one. Furthermore, I can't find how to get the t-statistic below the mean.
Dall | B2M | |||||
Size | 1 | 2 | 3 | 4 | 5 | |
0 | 1 | 5.3 (1.95) |
6.6 (1.24) |
5.3 (1.95) |
6.6 (1.24) |
5.3 (1.95) |
1 | 4.1 (7) |
1.89 (2.02) |
4.1 (7) |
1.89 (2.02) |
4.1 (7) |
|
0 | 2 | 1.3 (1.95) |
4.6 (1.24) |
5.3 (1.95) |
6.99 (1.24) |
5.3 (6.95) |
1 | 4.1 (7) |
1.89 (2.02) |
4.1 (7) |
1.89 (2.02) |
4.1 (7) |
|
0 | 3 | 5.3 (1.95) |
6.6 (1.24) |
5.3 (1.95) |
6.6 (1.24) |
5.3 (1.95) |
1 | 1.3 (1.95) |
4.6 (1.24) |
5.3 (1.95) |
6.99 (1.24) |
5.3 (6.95) |
|
0 | 4 | 5.3 (1.95) |
6.6 (1.24) |
5.3 (1.95) |
6.99 (1.24) |
5.3 (6.95) |
1 | 4.1 (7) |
1.89 (2.02) |
4.1 (7) |
4.6 (1.24) |
5.3 (1.95) |
|
0 | 5 | 5.3 (1.95) |
6.6 (1.24) |
4.1 (7) |
4.6 (1.24) |
5.3 (1.95) |
1 | 4.6 (1.24) |
5.3 (1.95) |
6.99 (1.24) |
5.3 (6.95) |
5.3 (1.95) |
Comment