pitakakariki / simr

Power Analysis of Generalised Linear Mixed Models by Simulation
68 stars 19 forks source link

Residual setting with makeLmer function #217

Open lovingpast opened 3 years ago

lovingpast commented 3 years ago

Hi there,

I have a doubt about how to set residual sd (sigma) for a PA, using makeLmer function of the simR package.

When defining the fixed effect, my parameter estimates were all standardized coefficients (i.e., I standardised/z-scored all the variables beforehand). When defining the random structures, since I extracted them from another similar but not same-structured study, I also used the standardized variances (variance divided by sum of variances) for random intercepts and slopes to match them with my manipulation for the fixed parts.

When I tried to fill the sigma of makeLmer function, I got a little bit lost. It is said in the manual that I should enter the sd of the residual. However, since I standardized the random effects, I believe the residual sd should also be different than the original unstandardized one. My question is, how should I deal with this sigma part, should I indeed use a standardized residual sd? And if yes, should it be simply valued as 1, or how should I standardize it?

Thanks!

pitakakariki commented 3 years ago

Standardising your effects shouldn't affect your residual sd.

Suppose you had a simple unstandardised case:

y[i] = b0 + b1 x[i] + e[i]

If you needed to scale x by s that gives you:

y[i] = b0 + (s b1) (x[i] / s) + e[i]

i.e. your effect size b1 is scaled but the residual term e is unaffected.