Hello and thank you in advance for what is likely a simple answer to a question I am struggling with!
I am trying to test for the equality of the absolute value of marginal effects in the same regression that have interaction terms. The marginal effects are sometimes negative and sometimes positive but I am only interested in their magnitudes. I have the coding to do the test if all the marginal effects were either positive or negative but the complication of requiring the absolute value of the marginal effects is throwing me for a loop!
Here is the coding for the regression and the marginal effects:
quietly xtreg y_var x i.levels i.levels##c.var_x, fe
margins levels, dydx(var_x) pwcompare(cim) post
The problem at this point is that the marginal effects are positive and negative. So the pairwise comparison test from Stata will just tell me if the nominal marginal effects differ from each other, not if the difference in the absolute value of the marginal effects differ from one another.
I have been pursuing two solutions for this problem:
1. Replacing the post-estimation e(b) matrix with absolute values in all the cells. I can do this with a mata command:
st_matrix("abs_eb",abs(st_matrix("e(b)")))
But then I can't figure out how to make Stata use matrix abs_eb instead of e(b) when running a test of equality of the marginal effects. Is this possible? If so, please help with the command for that.
2. Trying to calculate the test on my own using abs_eb matrix that I created and the var-cov post-estimation matrix but I am having a surprising amount of difficulty with this fairly simple formula. I think the formula for equity of coefficients (or marginal effects) in the same regression is: (B1-B2)/sqrt(VAR(B1)+VAR(B2)-2COV(B1,B2)) where B1 is the estimated coefficient for variable 1. Is this the right formula?
Thank you very much!
I am trying to test for the equality of the absolute value of marginal effects in the same regression that have interaction terms. The marginal effects are sometimes negative and sometimes positive but I am only interested in their magnitudes. I have the coding to do the test if all the marginal effects were either positive or negative but the complication of requiring the absolute value of the marginal effects is throwing me for a loop!
Here is the coding for the regression and the marginal effects:
quietly xtreg y_var x i.levels i.levels##c.var_x, fe
margins levels, dydx(var_x) pwcompare(cim) post
The problem at this point is that the marginal effects are positive and negative. So the pairwise comparison test from Stata will just tell me if the nominal marginal effects differ from each other, not if the difference in the absolute value of the marginal effects differ from one another.
I have been pursuing two solutions for this problem:
1. Replacing the post-estimation e(b) matrix with absolute values in all the cells. I can do this with a mata command:
st_matrix("abs_eb",abs(st_matrix("e(b)")))
But then I can't figure out how to make Stata use matrix abs_eb instead of e(b) when running a test of equality of the marginal effects. Is this possible? If so, please help with the command for that.
2. Trying to calculate the test on my own using abs_eb matrix that I created and the var-cov post-estimation matrix but I am having a surprising amount of difficulty with this fairly simple formula. I think the formula for equity of coefficients (or marginal effects) in the same regression is: (B1-B2)/sqrt(VAR(B1)+VAR(B2)-2COV(B1,B2)) where B1 is the estimated coefficient for variable 1. Is this the right formula?
Thank you very much!
Comment