[R-sig-ME] Measurement error for mixed models

Viechtbauer, Wolfgang (SP) wo||g@ng@v|echtb@uer @end|ng |rom m@@@tr|chtun|ver@|ty@n|
Wed Sep 11 19:12:16 CEST 2019

Hi Krzysztof,

This can be done with lme(). Let si2 denote the known variance of observation i. With varFixed(), you can specify that the error variances are known up to a proportionality constant, sigma^2. With lmeControl(sigma=1), you can fix that proportionality constant to 1, so the error variances are equal to s2i. Then add random effects for each row of the dataset. That will be your s^2. So, putting this all together:

dat$id <- 1:nrow(dat)
lme(yi ~ x1 + ..., random = ~ 1 | id, 
    weights = varFixed(~ si2), 
    control = lmeControl(sigma = 1), 
    data = dat)

Interestingly, this is identical to what is done in meta-analysis in the 'random-effects model', where we have known sampling variances for the outcomes and we add a random effect for each row (i.e., study) to the model. You might find this of interest:


But also read the note at the end -- there is (was?) some issue with lme() when fixing sigma to a constant. Not sure if this has been fixed in the meantime.


-----Original Message-----
From: R-sig-mixed-models [mailto:r-sig-mixed-models-bounces using r-project.org] On Behalf Of Krzysztof Bartoszek via R-sig-mixed-models
Sent: Wednesday, 11 September, 2019 16:02
To: r-sig-mixed-models using r-project.org
Subject: [R-sig-ME] Measurement error for mixed models

Dear all,
As far as I managed to see the weights parameter in nlme::lme(), mgcv::gamm(), gamm4::gamm4(), can be used to pass some specific residual variance structure based on nlme's varFunc class. I was wondering if the following variance structure is possible to be obtained from the already implemented instances in varClasses, or I will need to code it myself.

I want the variance of the response for observation i to be of the form v_i^2 = s^2 + s_i^2, where s^2 is a common for all observations unknown variability and s_i^2 is known, individual specific measurement error variance (can be 0).

Thank you
Best wishes
Krzysztof Bartoszek

More information about the R-sig-mixed-models mailing list