lindeloev / tests-as-linear

Common statistical tests are linear models (or: how to teach stats)
https://lindeloev.github.io/tests-as-linear/
487 stars 92 forks source link

rnorm_fixed can be simpler #28

Closed ldwgchen closed 2 years ago

ldwgchen commented 2 years ago

As seen at the opening source code block in 2 Settings and toy data, rnorm_fixed is a function defined as rnorm_fixed = function(N, mu = 0, sd = 1) scale(rnorm(N)) * sd + mu. Scaling something only to unscale it right after is confusing; rnorm(N, mean = mu, sd = sd) should do just fine.

lindeloev commented 2 years ago

rnorm_fixed() guarantees that the observed mean and SD exactly match the true (data-generating) values. This is helpful to infer whether the parameters can be recovered through inference without having to run many simulations. It's a way to avoid the sample deviating greatly from the true generating parameters to make it easier for the reader to recognize whether the inferred values look reasonable.