Estimating the parameters of a quantile regression

Now I want to estimate the parameters of quantile regression, and I encounter the following problems. My main idea is :

y=\beta _0 +\beta _1 x_1+\beta_2x_2+\beta_3x_3+\epsilon, \epsilon\sim N(0,\sigma_1^2)

My model is following:

n=20
p=4  #include the constant
k=5  #the number of quantile

truebeta=c(0.2,0.8,0.5,-0.5)
obs_x=matrix(rnorm(n*p,2,0.5),nrow=n,ncol=(p-1))
sigma1=0.25
eps=rnorm(n,0,sigma1)
c=rep(1,n)
x=cbind(c,obs_x)
y=as.vector(x%*%truebeta+eps)

data=data.frame(cbind(y,obs_x))
names(data)=c("y","x1","x2","x3")

tau=c(0.05,0.25,0.5,0.75,0.95)
fit=rq(y~.,tau=tau,data=data)  
fited=summary(fit)
beta_qr=fit$coefficients

For the \tau quantile regressions, I don’t know how to define the beta_qr .I hope that you can give me some advices

Hey there!

I don’t know much about quantile regression. It might be a good starting point to see what they do in this paper/package: https://www.jstatsoft.org/article/view/v076i07/v76i07.pdf

You can then try to translate their approach to Stan (or just their package).

You can also check out this thread or this thread for some examples of quantile regressions.

Hope this helps!
Cheers!
Max