I am trying to simulate data with tau = 0.5. I am using the following r code to simulate data.
#rm(list=ls())
library(quantreg)
set.seed(12)
n = 100
tau = 0.5
u <- runif(n)
z <- rbinom(n, 1, 0.37)
v <- rnorm(n)
d <- z * (u > 0.5 * v)
x <- runif(n, 0, 1)
x1 <- (u - tau) + x * 2
y <- (1 - d) * x + d * x1
Does it correct? Also, are there any r function available to simulate y for given x and tau values? I noticed arima.sim() available to simulate time series data.