While learning how to use the margins command, I could not make sense of the following even after reading documentation (Help files, Stata Journal articles) and past forum entries containing explanations from experts including Richard A. Williams and Clyde Schechter, and I seek your help.
I have a regression model similar to this one, using real data in the field of innovation:
where x is a continuous variable bounded between zero and five.
After running that logit model, I ran two margins commands in order to see what the predicted probability of “y” was at alternative values of x. In order to calculate adjusted predictions at representative values (using the term mentioned by Richard A. Williams at this link: http://www3.nd.edu/~rwilliam/xsoc73994/Margins01.pdf ) I used the following code:
I was able to obtain results, but was puzzled when the results displayed in the result column “Margin” at alternative levels of "x" turned out to be more than 100 times, and in some cases more than 1000 times, larger at the same level of "x" compared to the results I obtained after running the next piece of code following the same regression model shown earlier:
I’m aware that the former margins code uses the default “asobserved” whereas the latter uses “atmeans” but I could not make sense of how the results from the former, at any given level of x, could be more than 100 times to 1000 times greater than the results obtained from the latter. Before going any further, I wanted to ask whether comparing the results from the two margins commands above makes sense at all, and whether differences could really be as large as the ones I’m observing in my comparison.
Just to give you a sense of the magnitude of differences, the sample-wide average for “y” in my data is 0.10. That is the same result that I get when I do:
But I get a result of 0.00006 after the following:
Thank you for helping me to make sense of this.
I have a regression model similar to this one, using real data in the field of innovation:
Code:
Logit y x xsquared controlvar1 controlvar2, cluster(id) robust
After running that logit model, I ran two margins commands in order to see what the predicted probability of “y” was at alternative values of x. In order to calculate adjusted predictions at representative values (using the term mentioned by Richard A. Williams at this link: http://www3.nd.edu/~rwilliam/xsoc73994/Margins01.pdf ) I used the following code:
Code:
Margins, at(x=(0(0.1)5))
Code:
Margins, at(x=(0(0.1)5)) atmeans
Just to give you a sense of the magnitude of differences, the sample-wide average for “y” in my data is 0.10. That is the same result that I get when I do:
Code:
margins
Code:
margins, atmeans
Comment