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!
2026-04-06 18:55:17.1775501717
Conditional regression points
47 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
2
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})$.