3
$\begingroup$

Suppose I want to generate independent data $(y_{i},x_{i})$ such that the conditional mean of $y_{i}$ given $x_{i}$ is a quadratic function in $x_{i}$ and the $.25$ conditional quantile of $y_{i}$ given $x_{i}$ is a function different than the conditional mean function.

I can generate such data with the given conditional mean using R. But how to make the $.25$ conditional quantile function different than the regression function?

$\endgroup$
3
  • $\begingroup$ I might be missing the point, but wouldn't $y_i =x_i^2 +\epsilon_i$ where $\epsilon_i$ is normal with mean 0, do the job? $\endgroup$ – Cettt Mar 16 '18 at 6:46
  • $\begingroup$ I am a bit unclear what exactly you require of the quantile. You could follow the advice of @Cettt and draw the noise terms from a normal distribution with a variance that depends on $x_i$, e.g., $\epsilon_i\sim N(0,x_i^2)$, then the quantiles will depend on $x_i$ not only through the mean. $\endgroup$ – Stephan Kolassa Mar 16 '18 at 7:42
  • $\begingroup$ Hi. Thank you all for the useful info. That gave me something to begin with. Thanks. I guess I worked out what I want. Thanks. @StephanKolassa,@Cettt $\endgroup$ – Megadeth Mar 16 '18 at 14:20
0
$\begingroup$

A simple approach would be to draw $X\sim U[0,1]$ and $Y\sim N(x^2,x)$, i.e., the variance of $Y$ is $x$. Then the $0.25$ quantile of $Y$ would be $z_{0.25}\sqrt{x}$. Here are simulated data, with the expectation as a black and the quantile as a red line:

plot

R code:

set.seed(1)
xx <- runif(1e3)
yy <- rnorm(length(xx),xx^2,sqrt(xx))
plot(xx,yy,pch=19,las=1,cex=0.6)

xx_pred <- seq(.01,.99,by=.01)
lines(xx_pred,xx_pred^2,lwd=2)
lines(xx_pred,qnorm(0.25,xx_pred^2,sqrt(xx_pred)),col="red",lwd=2)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.