Conditional regression points

47 Views Asked by At

Suppose I have a model $$y=\beta_0+\beta_1x+\beta_3\sqrt{x}e_1,$$ where the "beta" coefficients are known and $e_1$ is Normal(0,1). Now I simulate $n=100$ points from that model and have the scatter-plot. The question is: how could I get (and plot) the points conditioned to a specific value of $x$ in R? That is, given the simulated points $(x_i,y_i)$, how could I extract those $y_i|x=0.5$, for example? Thank you very much in advance!

2

There are 2 best solutions below

0
On BEST ANSWER

Since $E[e] = E[e|X] = 0 $, your model is the estimator of $$ E[Y|x] = \beta_0 + \beta_1 x + \beta_3\sqrt{x}E[e] = \beta_0 + \beta_1 x, $$ which is given by $$ \hat{y}= \hat{\beta}_0 + \hat{\beta}_1x. $$ Hence, you can extract the predicted value for certain $x_0$ by plugging in this $x_0$ into the model, i.e., $$ \widehat{E[Y|X=x_0]} = \hat{\beta}_0 + \hat{\beta}_1x_0. $$

In the case you meant to simulate $y_i$ for a given $x=x_0$ using R programming language, then note that the conditional distribution of $Y$ given $X=x_0$ is $N(\beta_0 + \beta_1x, \beta_3^2x)$, hence just simulate value from the aforementioned distribution by $\text{rnorm}(1, \text{mean} = \beta_0 + \beta_1x_0, \text{sd} = \beta_3 \sqrt{x_0})$.

0
On

The probability to observe a specific $y$ given $x$ is $P(y|x)=N({(y-\beta_0 -x\beta_1) \over \beta_2 {\sqrt x}}),1)$. So the $y's$ you are looking for are ones for which this expression is as large as possible.