I'm sure that this question has been asked some how some way. But I've tried and I can't figure it! I'm trying to manage my legends in ggplot2. here's my code:
g <- ggplot(results, aes(x=index, color=includes_truth))
g <- g + geom_linerange(aes(ymax=ub.CACE_hat, ymin=lb.CACE_hat), alpha=.5)
g <- g + theme_bw()
g <- g + theme(axis.ticks.y = element_blank(),
axis.text.y = element_blank(),
axis.title.y = element_blank(),
legend.position="bottom")
g <- g + ylab(expression("Estimate" %+-% 1.96*" Bootstrapped Standard Error"))
g <- g + ggtitle("Coverage of Bootstrapped 95% Confidence Interval")
g <- g + geom_hline(yintercept=true_cace,colour="red", linetype = "longdash")
g <- g + coord_flip()
I'm happy with the legend for the two kinds of intervals (includes truth or not) But I want the geom_hline to have a legend too that reads "True CACE".
I'd post a pic, but don't have enough rep just yet....
Here's the first 10 lines of the dataset:
lb.CACE_hat ub.CACE_hat index includes_truth
910 -0.2925184 0.0081482459 -0.3425184 FALSE
835 -0.2760973 0.0009649981 -0.3260973 FALSE
382 -0.2749657 -0.0095546577 -0.3249657 FALSE
164 -0.2726825 -0.0171725490 -0.3226825 FALSE
931 -0.2615927 -0.0092937132 -0.3115927 FALSE
451 -0.2614677 0.0094599885 -0.3114677 FALSE
876 -0.2585660 0.0187700913 -0.3085660 FALSE
827 -0.2565962 0.0316608976 -0.3065962 FALSE
671 -0.2565856 0.0078546241 -0.3065856 FALSE
203 -0.2491911 0.0304410876 -0.2991911 FALSE