I am running quantile regressions for several independent variables separately (same dependent). I want to plot only the slope estimates over several quantiles of each variable in a single plot.
Here's a toy data:
set.seed(1988)
y <- rnorm(50, 5, 3)
x1 <- rnorm(50, 3, 1)
x2 <- rnorm(50, 1, 0.5)
# Running Quantile Regression
require(quantreg)
fit1 <- summary(rq(y~x1, tau=1:9/10), se="boot")
fit2 <- summary(rq(y~x2, tau=1:9/10), se="boot")
I want to plot only the slope estimates over quantiles. Hence, I am giving parm=2
in plot
.
plot(fit1, parm=2)
plot(fit2, parm=2)
Now, I want to combine both these plots in a single page.
What I have tried so far;
- I tried setting
par(mfrow=c(2,2))
and plotting them. But it's producing a blank page. - I have tried using
gridExtra
and gridGraphics without success. Tried to convert base graphs into Grob objects as stated here - Tried using function
layout
function as in this document - I am trying to look into the source code of
plot.rqs
. But I am unable to understand how it's plotting confidence bands (I'm able to plot only the coefficients over quantiles) or to changemfrow
parameter there.
Can anybody point out where am I going wrong? Should I look into the source code of plot.rqs
and change any parameters there?