1

I would like to create a random dataset which allows me to conduct regression analyses as realistically as possible (e.g. for teaching, but also to test different models). The analyses I would like to conduct would be simple multivariable regression analyses, e.g.:

$ y = \beta_1 x_1 + \beta_2 x_2 \cdots $

The data should be 'random' enough to give realistic results, and ideally should not require a linear relationship (but for example splines).

What I am looking for is a method where I can specify the parameters (including error) of several regression models - and which then creates a dataset with $n$ samples which will give the precified results when using the same models.

Gux
  • 193
  • 2
  • 10
  • 3
    Could you elaborate on what would constitute a "method"? From one point of view, writing down the regression model *is* a method, which leaves us no actual question to answer. What are you hoping to see in the answers? – whuber Aug 23 '18 at 21:53
  • I tried to clarify the question. – Gux Aug 24 '18 at 06:50
  • 3
    I cannot write comments, but have a look at the answer (using R) here: https://stats.stackexchange.com/a/59064/200663 Edit: the answer there is only concerned with linear regression, but it might give some idea on how to simulate a dataset with splines anyway. – bobbel Aug 24 '18 at 07:00
  • That is working - but I'm somewhat confused why the script simply adds the noise - shouldn't it multiply the coefficient with the noise? – Gux Aug 25 '18 at 07:33
  • 1
    No, noise in these models is additive. However, you show a linear regression and then say you want it to be complicated enough to require splines. Perhaps you mean "should not require splines"? – Peter Flom Aug 25 '18 at 11:11
  • I would like to use splines in the models - but have have changed the original function to include 3rd degree polynomial and that works well. I would like to use the data to show differences between different approaches and especially show that not all associations are linear. – Gux Aug 25 '18 at 12:12

0 Answers0