Hello,
I am using coefplot (with STATA 17) to plot coefficients from multiple models on the same plot and since the number of observations varies from model to model, I would like to attach markers that indicate the number of observations in each model.
I know that coefplot maintains a number of internal variables that can be used with malabel, including @se and @pval. But the number of observations in the model is not one of these, so it would have to be accessed using aux().
However, when I attempt to use aux() to access N and then use it as a marker label, I receive the message “e(N) not found”. I assume this must be because I have not correctly identified where exactly the scalar “N” is stored for each model and am not correctly calling it using aux(). Could you help me identify the correct aux() call to fetch the N for each model?
I have an illustrative example using the auto.dta dataset below. The code for attaching the label comes from this example of labels at the end of confidence intervals (https://repec.sowi.unibe.ch/stata/co...ers.html#h-3-4). There is one example in the coefplot documentation of using aux and N to edit coefplot, in this case changing the marker size relative to the number of observations. (https://repec.sowi.unibe.ch/stata/co...rkers.html#h-4) I tried to follow the principle in this example, but I receive the message "e(N) not found" or "e(_N) not found".
I am using coefplot (with STATA 17) to plot coefficients from multiple models on the same plot and since the number of observations varies from model to model, I would like to attach markers that indicate the number of observations in each model.
I know that coefplot maintains a number of internal variables that can be used with malabel, including @se and @pval. But the number of observations in the model is not one of these, so it would have to be accessed using aux().
However, when I attempt to use aux() to access N and then use it as a marker label, I receive the message “e(N) not found”. I assume this must be because I have not correctly identified where exactly the scalar “N” is stored for each model and am not correctly calling it using aux(). Could you help me identify the correct aux() call to fetch the N for each model?
I have an illustrative example using the auto.dta dataset below. The code for attaching the label comes from this example of labels at the end of confidence intervals (https://repec.sowi.unibe.ch/stata/co...ers.html#h-3-4). There is one example in the coefplot documentation of using aux and N to edit coefplot, in this case changing the marker size relative to the number of observations. (https://repec.sowi.unibe.ch/stata/co...rkers.html#h-4) I tried to follow the principle in this example, but I receive the message "e(N) not found" or "e(_N) not found".
Code:
estimates clear sysuse auto, clear eststo modelA: reg price mpg eststo modelB: reg price trunk eststo modelC: reg price length *check to see what is among the list of scalars estimates restore modelA ereturn list *e(N) appears among the list of scalars coefplot modelA modelB modelC, /* */ aux(N) /* */ mlabel(string(@aux1)) mlabcolor(none) /* */ addplot(scatter @at @ul, ms(i) mlabel(@mlbl) mlabcolor(black) mlabpos(3) mlabsize(vsmall)) *If I try to access N using aux(N) I get the message "e(N) not found" coefplot modelA modelB modelC, /* */ aux(_N) /* */ mlabel(string(@aux1)) mlabcolor(none) /* */ addplot(scatter @at @ul, ms(i) mlabel(@mlbl) mlabcolor(black) mlabpos(3) mlabsize(vsmall)) *If I try to access N using aux(_N) I get the message "e(_N) not found" coefplot modelA modelB modelC, /* */ mlabel(string(@pval)) mlabcolor(none) /* */ addplot(scatter @at @ul, ms(i) mlabel(@mlbl) mlabcolor(black) mlabpos(3) mlabsize(vsmall)) *This, with the internal variable stored under @pval, works as intended
Comment