I am trying to create a coefficient plot using ggplot that combines the results of two different regressions. The coefficients, standard errors and confidence interval bounds of each regression are stored as a data frame of the form:
## regression1:
var betas crse upper lower
1 x1 0.517251974 0.58176862 0.37751553 0.05698842
2 x2 -0.260210445 0.03521915 -0.12118217 -0.25923872
3 x3 0.680752318 0.08844444 0.75410023 0.40740441
4 x4 0.663395004 0.05090350 0.26316403 0.06362598
5 x5 -0.551992451 0.03289870 -0.08751219 -0.21647271
## regression2:
var betas crse upper lower
1 x1 -0.343254719 0.05498965 0.01451302 -0.20104246
2 x2 0.126434568 0.02243139 0.17040108 0.08247165
3 x3 -0.178460203 0.06215729 -0.05663415 -0.30028625
4 x4 0.301058265 0.03737595 0.37431378 0.22780275
5 x5 -0.054594805 0.02037967 -0.01465139 -0.09453822
My approach was to combine both regressions into one data frame using:
combined <- rbind(regression1, regression2)
And then I use ggplot:
ggplot(combined, aes(x=var, y=betas)) +
geom_point(aes(x=var, y=betas),
color="red",
shape=15) +
geom_errorbar(aes(ymin=lower, ymax=upper),
width=.25,
size=.65)
However, the lines of the two models with the coefficient / confidence intervals overlap each other in the plot and it is not easy to distinguish which one is which. Is there a way to separate the lines so that they can be distinguished? Perhaps I am using the wrong approach and I should not rbind the two plots.
