ARIMA quantile regression in R

I would like to perform a quantile regression of a autoregressive integrated moving average (ARIMA) model (p,0,q) of a stock return in R. My question is: how can I include the moving average process in the regression? I read I need to use rq (which is available in "quantreg" package) but I cannot follow the procedure for an ARIMA case. Can anybody help me pls? packages used and code until now:

library(quantmod) #to get the stock prices
library(quantreg) #to get the function for quantile regression
ticker <- c("AAPL")
myenv <- new.env()
symnames <- getSymbols(ticker, env=myenv)
rt <- diff(log(ts), lag = 1)
rt_final <- rt[-1:-1,]
fit_rt<-auto.arima(rt_final); summary(fit_rt)
x <- fitted(fit_rt)
y <- cbind(x, lx = lag(x),llx=lag(lag(x))) #include two for now
qregr <- rq(x ~ lx + llx, data = y) #this is where I need to include the MA(2) process, right?
qregr <- rq(x ~ lx + llx, tau = seq(0.05, 0.95, by = 0.05), data = y); summary(qregr)
plot(qregr)


thanks,

• What is the rq function, and where did you read about it? – Carl Sep 25 '16 at 2:55

Rob J Hyndman: I've read Koenker, and I've used rq. Homoscedasticity will give you parallel lines. I don't want parallel lines, and I don't even want linear functions, or a family of linear functions. Forecast quantiles are almost never linear.