I regressed a series of data with OLS, and I calculated the standard error (SE) of the slope and of the intercept. Moreover, I calculated the confidence bands for the regression following the equations in the answer to this question.
Now I am wondering how I can generate a set of random regression lines within this distribution of regression lines. Clearly, I cannot just pick random values of the slope and intercept values from a normal distribution defined by mean and SE, because slope and intercept are not independent. As expected, when I do this, I pick a bunch of lines that lie outsideis illustrated by the 95% confidence interval. Is there a simple way to generate regressions that are representative of the true distribution of regression lines (i.e. "combined" slope and intercept values)?
The details of whyIn order to illustrate what I need this are probably irrelevantmean, but in casehere is a short summary of interest,my problem. I have a series of data (dataset A; blue points in below figure) that deviate from a linear trend defined by another dataset (dataset B; red points in below figure). Using some constraints from chemistry, I can correct A by projecting each point onto the linear trend defined by B (red regression line in below figure). In order to propagateconsider the uncertainty fromin the regression of dataset B in the corrected values for dataset A, I was thinking of picking lines at random from the distribution of regressions of dataset B, and repeating the projection forprojecting A onto each of thethese lines. I just do not know how to pick lines that are representative of the distribution of regressions.
Below is now a zoom into the same plot as above. Now, the black lines show 100 regression lines picked at random. These lines were generated by choosing random values for the slope and intercept from normal distributions with mean and standard errors obtained from the regression.
Here is the same with 1000 lines
There seem to be more than 5% of the lines that fall out of the 95% confidence bands, and the method of picking a random slope and a random intercept value does not work. This makes sense, considering that slope and intercept are not independent. Is there a simple way to generate regressions that are representative of the true distribution of regression lines around the "best fit"?
Thanks and please let me know if any of this is unclear