Hi all,
I'm looking to swap the order of columns in a matrix, and make all bar one of the columns cumulative of another. For example, I'd like to make matrix reg look like matrix mean
So, the first step is to swap the order of the columns, and the second is to make 1.foreign = 1.foreign + _cons and 2.foreign = 2.foreign + _cons. Any pointers / code would be appreciated! I've tried looking at invorder() but I cannot get it to work, and don't really understand the examples in the matrix help files.
Out of curiosity, and on a similar note, i'd be interested to know why the SEs from regress price i.foreign are not the same as the results from mean price, over(foreign)
I'm looking to swap the order of columns in a matrix, and make all bar one of the columns cumulative of another. For example, I'd like to make matrix reg look like matrix mean
Code:
sysuse auto, clear replace foreign= 2 if _n<14 mean price, over(foreign) level(95) matrix define mean = r(table) regress price i.foreign matrix define reg = r(table) mat def reg = reg[1..rowsof(reg),2...] //this gets rid of the base column mat def reg = reg[invorder(reg),.] //this does not work... mat li mean mean[9,3] price: price: price: Domestic Foreign _subpop_3 b .5610282 .63846818 .74588462 se .04053582 .05589942 .11667455 t 13.840308 11.421732 6.3928649 pvalue 4.229e-22 6.520e-18 1.361e-08 ll .48024044 .5270608 .51335258 ul .64181597 .74987556 .97841665 df 73 73 73 crit 1.9929971 1.9929971 1.9929971 eform 0 0 0 mat li reg reg[9,3] 1. 2. foreign foreign _cons b .07743998 .18485641 .5610282 se .06911881 .12151304 .04084935 t 1.1203893 1.5212887 13.73408 pvalue .26632347 .13262877 1.128e-21 ll -.06037902 -.0574337 .47957692 ul .21525897 .42714653 .64247949 df 71 71 71 crit 1.9939434 1.9939434 1.9939434 eform 0 0 0
Out of curiosity, and on a similar note, i'd be interested to know why the SEs from regress price i.foreign are not the same as the results from mean price, over(foreign)
Comment