I am trying to plot the results for a select number of independent variables from 8 separate regressions using coefplot. Among these 8 estimates, there are 4 dependent variables. For each of the 4 dependent variables, I am measuring the effect of 1 key independent variables (plus some controls).
I want to show the effects of each of these four outcomes with coefplot as a separate window pane. Because I will estimate two different independent variables on the same outcome, but in different models, it would be more efficient to include them in the same window. Therefore, I want two plots (from separate models) in the same window four times.
The figure I've made is legible but rough. The problem is 1.) I only have one legend that labels two of my independent variables. Ideally, I'd like to show a legend with all four possible independent variables. 2.) In every pane, all four possible independent variables are shown on the y axis. This is unnecessary. There should only be two. Using the "keep" or "drop" command only seems to work for the whole figure and I cannot figure out how to selectively use it for certain panes.
This is an impasse I can't work past. To make matters worse, my data is protected state administrative data on a server without internet access meaning I cannot reproduce it. I used the auto dataset to try and recreate my setup. Please forgive how crude this is.
You can see I estimate price and headroom first and alternate the independent variable (trunk and displacement). Then I estimate MPG and weight with rep78 and gear ratio as IVs. Each model controls for length. Again, I want a legend for trunk, displacement, rep78 and gear ratio. I also only want the relevant IVs shown (e.g. when estimating price, we would see trunk and displacement but NOT rep78 and gear ratio).
Code:
reg price trunk length eststo m1 reg price displacement length eststo m2 reg headroom trunk length eststo m3 reg headroom displacement length eststo m4 reg mpg rep78 length eststo m5 reg mpg gear_ratio length eststo m6 reg weight rep78 length eststo m7 reg weight gear_ratio length eststo m8 coefplot (m1, label("Trunk")) /// (m2, label("Displacement")), /// bylabel(Price Estimates) /// || (m3, label("Trunk")) /// (m4, label("Displacement")), /// bylabel(Headroom Estimates) /// || (m5, label ("Rep 78")) /// (m6, label ("Gear Ratio")), /// bylabel(MPG Estimates) /// || (m7, label("Rep 78")) /// (m8, label ("Gear Ratio")), /// bylabel(Weight Estimates) /// keep (trunk displacement rep78 gear_ratio) /// xline (0) byopts(title("I don't know anything about cars")) /// mlabel(cond(@pval<.001, "***", /// Array cond(@pval<.01, "**", /// cond(@pval<.05, "*", ""))))
0 Response to Multiple Legends and Reducing Variables with Four Panes in Coefplot
Post a Comment