I am trying to perform a Monte-Carlo simulation on quantile regression using R. Currently I am getting stuck simulating the data from the model below.
Y=beta_0+beta_1*X1*u1+u2
where, u2~N(0,1),u1~exp(1) So my question is, how do I simulate my data and then get my true slope parameter for a specific τ, say 0.8?
The code below here is an example where the outcome Y is different from the outcome above. My question is how can I write the True slope of the .90 quantile function (6th line in code) for the outcome above?
n = 1000
beta0 = 2; beta1 = 0.3
set.seed(123)
X = rbinom(n, 1,0.2)
Y = beta0 + beta1*X + .4*X*rnorm(n)
beta1.90 = beta1 + qnorm(.90)*.4 # True slope of the .90 quantile function
beta1.90
library(quantreg)
fit.90 = rq(Y ~ X, tau = .90)
summary(fit.90)
Y = beta0 + beta1*X*rexp(n) + rnorm(n); beta1.90 = beta1 * qexp(.9). However, there is something I don't understand becauserqonly produces the expected value if I removeu2. (You should strongly increasenand userq(Y ~ X, tau = .9, method = "pfn").) $\endgroup$u2term supposed to be an additive error term as in your first equation, or multiplied byXas in your simulation code? $\endgroup$