Hello everyone,
for my Master's thesis I would like to compare average marginal effects across samples. I am looking at the association of stunting in children and parental education, with my dependent variable being stunting (a dummy) and my independent variable being the number of years the most educated parent went to school. The effect should be compared for boys and girls. In addition, I report odds ratios for each regression separately without testing for differences (such a test would suffer from both conceptual and econometric problems) To this end, I use the following code:
*******************************************
xi: svy, subpop(male_D): logit stunting highest_education_years, or
margins, dydx(*) post
estimates store a1
xi: svy, subpop(female_D): logit stunting highest_education_years, or
margins, dydx(*) post
estimates store a2
suest a1 a2
test [a1_stunting]highest_education_years = [a2_stunting]highest_education_years
******************************************
However, this does only work if I exclude the margins commands, i.e. if I compare odds ratios across samples. As I mentioned, I would prefer comparing Average Marginal Effects (see Mood 2010 for an explanation on why AME are preferable). With the margins commands, the code stops at the suest command because e(b) and e(V) cannot be retrieved. Essentially, I only need suest because I don't really know how Stata would label the equations without it (it's not simply "a1" and "a2" although I use estimates store). Does anyone know how to solve this? (Please note that I would like to avoid using interaction terms because I find them difficult to interpret in a non-linear setting. I am therefore looking specifically for a solution based on separate regressions)
Alternatively, I tried to to the testing by hand using z=[b1-b2]/sqrt[Var(b1)+Var(b2)] with b1 being the education coefficient from model a1 and b2 for model a2:
******************************************
xi: svy, subpop(male_D): logit stunting highest_education_years, or
margins, dydx(*) post
mat A[1,1] = el(e(b),1,1)
mat A[2,1] = sqrt(el(e(V),1,1))
xi: svy, subpop(female_D): logit stunting highest_education_years, or
margins, dydx(*) post
mat A[1,2] = el(e(b),1,1)
mat A[2,2] = sqrt(el(e(V),1,1))
*test statistic
mat z = J(1,1,.)
mat z[1,1] = (A[1,1]-A[1,2])/sqrt(A[2,1]^2+A[2,2]^2)
matrix list z
display 2*(1-normal(abs(z[1,1]))) //This line should give me the p-value
****************************************
The code works but I assume here that "z" follows a standard normal distribution (However, the sample size is very large, so this might be a minor problem). In addition, I am not completely sure whether the formula for the test statistic is correct. You have probably noticed that I use the svy prefix and stata would usually calculate an adjusted Wald test in such a case. Does anyone know how the respective formula would have to look like?
Thank you very much in advance!
Kind regards,
Christian
for my Master's thesis I would like to compare average marginal effects across samples. I am looking at the association of stunting in children and parental education, with my dependent variable being stunting (a dummy) and my independent variable being the number of years the most educated parent went to school. The effect should be compared for boys and girls. In addition, I report odds ratios for each regression separately without testing for differences (such a test would suffer from both conceptual and econometric problems) To this end, I use the following code:
*******************************************
xi: svy, subpop(male_D): logit stunting highest_education_years, or
margins, dydx(*) post
estimates store a1
xi: svy, subpop(female_D): logit stunting highest_education_years, or
margins, dydx(*) post
estimates store a2
suest a1 a2
test [a1_stunting]highest_education_years = [a2_stunting]highest_education_years
******************************************
However, this does only work if I exclude the margins commands, i.e. if I compare odds ratios across samples. As I mentioned, I would prefer comparing Average Marginal Effects (see Mood 2010 for an explanation on why AME are preferable). With the margins commands, the code stops at the suest command because e(b) and e(V) cannot be retrieved. Essentially, I only need suest because I don't really know how Stata would label the equations without it (it's not simply "a1" and "a2" although I use estimates store). Does anyone know how to solve this? (Please note that I would like to avoid using interaction terms because I find them difficult to interpret in a non-linear setting. I am therefore looking specifically for a solution based on separate regressions)
Alternatively, I tried to to the testing by hand using z=[b1-b2]/sqrt[Var(b1)+Var(b2)] with b1 being the education coefficient from model a1 and b2 for model a2:
******************************************
xi: svy, subpop(male_D): logit stunting highest_education_years, or
margins, dydx(*) post
mat A[1,1] = el(e(b),1,1)
mat A[2,1] = sqrt(el(e(V),1,1))
xi: svy, subpop(female_D): logit stunting highest_education_years, or
margins, dydx(*) post
mat A[1,2] = el(e(b),1,1)
mat A[2,2] = sqrt(el(e(V),1,1))
*test statistic
mat z = J(1,1,.)
mat z[1,1] = (A[1,1]-A[1,2])/sqrt(A[2,1]^2+A[2,2]^2)
matrix list z
display 2*(1-normal(abs(z[1,1]))) //This line should give me the p-value
****************************************
The code works but I assume here that "z" follows a standard normal distribution (However, the sample size is very large, so this might be a minor problem). In addition, I am not completely sure whether the formula for the test statistic is correct. You have probably noticed that I use the svy prefix and stata would usually calculate an adjusted Wald test in such a case. Does anyone know how the respective formula would have to look like?
Thank you very much in advance!
Kind regards,
Christian
Comment