I have two datasets. One with quantile estimates for multiple quantiles and the other with ols estimate.
d1 <- structure(
list(
tau = c(0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95),
term = c("xyz", "xyz", "xyz", "xyz", "xyz", "xyz", "xyz", "xyz", "xyz", "xyz", "xyz", "xyz", "xyz", "xyz", "xyz", "xyz", "xyz", "xyz", "xyz"),
Value = c(
0, 9.13682889869627e-16, 0.115868979841894, 0.177249380780954, 0.19607591773447, 0.195687830776138, 0.200114980211708, 0.194414277006126,
0.187632176725543, 0.187173613121143, 0.188976803954401, 0.179502655354206, 0.181229125428629, 0.174872004143586, 0.152074703983541, 0.146260827630119,
0.138590448328074, 0.128650158320059, 0.150026804023301
),
Std..Error = c(
6.2062850595809e-16, 0.0233470616183061, 0.0307059321347318, 0.0282162883685036, 0.0200725341931686, 0.0183116985228486, 0.0191468932241407,
0.0202374458735842, 0.0189676742252486, 0.0211745244254686, 0.0198311584152537, 0.0216761318683201, 0.017955669024132, 0.0190371929314243,
0.0183546066197098, 0.0194123534398986, 0.0190844067896042, 0.0213743223242021, 0.0219487120022877
),
t.value = c(
0, 3.91348129716342e-14, 3.77350471998319, 6.28181065014945, 9.76836884907147, 10.6864926009985, 10.451564014542, 9.60666075257518, 9.89220789525049,
8.83956632792239, 9.52928719529789, 8.281120286805, 10.0931424601924, 9.1858082635139, 8.28536983300085, 7.53442018676139, 7.26197307864806, 6.01891168144255, 6.83533521272976
),
Pr...t.. = c(1, 0.999999999999969, 0.000162587936320957, 3.59170471142534e-10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5.6621374255883e-14, 4.32098801184111e-13, 1.86426696302533e-09, 9.02655727941237e-12)
),
class = "data.frame", row.names = c(NA, -19L)
)
d2 <- structure(
list(
rowname = "zzz",
`Std. Error` = 0.0155334622532616,
Estimate = 0.280017767279397
),
row.names = c(NA, -1L), class = "data.frame"
)
How to plot the confidence interval of ols estimate?
ggplot(data = d1, aes(
x = tau, y = Value,
ymin = Value - Std..Error,
ymax = Value + Std..Error
)) +
geom_ribbon(alpha = 0.5) +
geom_line(color = "blue") +
labs(x = "Quantiles", y = "xyz") + # adds the confidence intervals as error bars
geom_hline(
data = d2,
aes(yintercept = Estimate),
color = "red"
) # add OLS estimate - note it is from another data set which is totally OK
This is what I tried
ggplot(data = d1, aes(
x = tau, y = Value,
ymin = Value - Std..Error,
ymax = Value + Std..Error
)) +
geom_ribbon(alpha = 0.5) +
geom_line(color = "blue") +
labs(x = "Quantiles", y = "xyz") + # adds the confidence intervals as error bars
geom_hline(
data = d2,
aes(
yintercept = Estimate,
yinterceptmin = Estimate - `Std. Error`,
yinterceptmax = Estimate + `Std. Error`,
),
color = "red"
) +
geom_ribbon(alpha = 0.5)