0
$\begingroup$

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)
$\endgroup$
7
  • 1
    $\begingroup$ Y = beta0 + beta1*X*rexp(n) + rnorm(n); beta1.90 = beta1 * qexp(.9). However, there is something I don't understand because rq only produces the expected value if I remove u2. (You should strongly increase n and use rq(Y ~ X, tau = .9, method = "pfn").) $\endgroup$ Commented Nov 20 at 7:12
  • $\begingroup$ Is your u2 term supposed to be an additive error term as in your first equation, or multiplied by X as in your simulation code? $\endgroup$ Commented Nov 20 at 14:39
  • $\begingroup$ The simulation code is an example. But I require beta1.90 for the very first equation I wrote where u2 is additive $\endgroup$ Commented Nov 20 at 15:09
  • 1
    $\begingroup$ Just to be sure, you’re saying that the simulation code you shared doesn’t align with your actual target model? If so, why would you do that? $\endgroup$ Commented Nov 20 at 15:18
  • $\begingroup$ I want to introduce heterogeneity like the first equation not the simulation code...its a part of my research $\endgroup$ Commented Nov 20 at 15:26

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.