Dear Stata users,
I have a large matrix that I'd like to subset it by its column equation names. My original matrix looks like the following :
I'd like to subset it into five matrices based on the first part of its column equation name. I could do it manually as following :
However, given that the matrix columns will likely change based on my model specifications. I wonder if there's a way to automate this routine? Clearly syntax such as
mat e_tau2 = c[1, "tau2_*:"]' won't work
I have a large matrix that I'd like to subset it by its column equation names. My original matrix looks like the following :
Code:
. mat list cut cut[1,20] tau1_1: tau2_1: tau2_2: tau2_3: tau2_4: tau2_5: tau2_6: _cons _cons _cons _cons _cons _cons _cons b .17826254 -1.041928 -.7895766 -.50704795 -.25593288 .13586857 .70962046 tau2_7: tau2_8: tau2_9: tau3_1: tau3_2: tau3_3: tau4_1: _cons _cons _cons _cons _cons _cons _cons b 1.1027288 1.6016368 1.9813423 -.71304087 .19229588 1.5388753 -.55037033 tau4_2: tau4_3: tau5_1: tau5_2: tau5_3: tau5_4: _cons _cons _cons _cons _cons _cons b .34203077 1.5677015 -.28412486 .01651519 .72999177 1.4822046
I'd like to subset it into five matrices based on the first part of its column equation name. I could do it manually as following :
Code:
mat e_tau1 = c[1, "tau1_1:"] mat e_tau2 = c[1, "tau2_1:" .. "tau2_9:"]' mat e_tau3 = c[1, "tau3_1:" .. "tau3_3:"]' mat e_tau4 = c[1, "tau4_1:" .. "tau4_3:"]' mat e_tau5 = c[1, "tau5_1:" .. "tau5_4:"]'
mat e_tau2 = c[1, "tau2_*:"]' won't work
Comment