

Graph export all_sports_across_age.tif, replace Svy: reg sports i.cohort i.AGE i.AGE#i.cohort if sports>0 Graph export gammalinkall_sports_across_age.tif, replace Plot5opts(msymbol(S) lcolor(gs14) mcolor(gs14)) /// Plot4opts(msymbol(T) lcolor(gs11) mcolor(gs11)) /// Plot3opts(msymbol(O) lcolor(gs8) mcolor(gs8)) /// Plot2opts(msymbol(X) lcolor(gs5) mcolor(gs5)) /// New in Stata 12 is the marginsplot command, which makes it easy to graph statistics from fitted models.marginsplot graphs the results from margins, and margins itself can compute functions of fitted values after almost any estimation command, linear or nonlinear. I shows how the marginsplot command (introduced in Stata 12) provides a graphical and often much easier means for presenting and understanding the results from margins, and explain why margins does not present marginal effects for. Plot1opts(msymbol(D) lcolor(gs0) mcolor(gs0)) /// Stata 11 introduced new tools for making such calculationsfactor variables and the margins command. Marginsplot, title("Cohort, age, sports") xtitle("Age") /// Svy: glm sports i.cohort i.AGE i.AGE#i.cohort if sports>0, family(gamma) link(log) Thank you for your question and the information about writing c.var1!Īs you can see, there are no other variables. I would like the variables to be treated as categorial ones. with regression and the original variable What would you recommend? Should I use the natural log and waive the interpretable scale or should i use gamma log link. Is there anything wrong with the margins command in my second code?

The estimators however, differ between the models.
Marginsplot stata code#
The problem is: With the glm code, I get the same result as if I use the first code but with the original variable which is not log transformed. Margins, over(var 1 var2) predict(xb) vsquish Svy: glm depvar i.var1#i.var2, family(gamma) link(log) When I plotted the model via marginsplot this resulted in a partially negative y scale which for the topic does not make sense and the scale of course is not interpretable. What I did because of that was to use the natural log of the variable. In Stata such plots can be produced by the marginsplot command (R marginsplot). Stata’s own documentation on its graphic commands for regression analysis provides a great start to learning about these commands, but Mitchell’s book takes you several steps beyond this. I calculate with a variable which is highly skewed to the right. literature, as graphs are much easier to read than tables in many cases. once you are familiar with the marginsplot command.
