1

In a previous question (Equivalent to Welch's t-test in GLS framework) it was asked whether nlme can reproduce Welch's t-test.

Below is an abridged version of this older question:

A standard independent samples t-test (where it is assumed that the samples being compared are drawn from populations with equal variance) can be expressed as follows:

$$Y_i = \beta_0 + \beta_1 X_i + \varepsilon_i$$

where $Y$ is the outcome and $X$ is a binary variable corresponding to group membership. The significance test of $\beta_1$ will produce the same t statistic as the standard independent samples t-test. Thus, the two commands below produce the same statistics (with the same degrees of freedom):

t.test(extra~group, data = sleep, var.equal = TRUE)  
lm(extra~group, data = sleep)

The provided answer to this question indicated that using gls (in the nlme package) with specificed weights

weights=varIdent(form = ~ 1 | group)) 

would do the trick.

I am curious whether this can also be implemented in lme4 (using lmer). When going through the help file of lme4 I could not find anything that corresponds to the weight option in nlme::gls.

Sven Hohenstein
  • 6,285
  • 25
  • 30
  • 39
Felix Thoemmes
  • 572
  • 4
  • 18
  • According to http://rpsychologist.com/r-guide-longitudinal-lme-lmer, "Only `lme` allows modeling heteroscedastic residual variance at level 1 [via `weights=`]". – amoeba Jun 29 '17 at 11:22
  • See also https://stats.stackexchange.com/questions/267439 ("lme4 does not support fitting of variance structures"). – amoeba Jun 29 '17 at 11:27
  • 1
    But then, see https://stats.stackexchange.com/a/214007/28666 where BenBolker gives a hack to make it work in lmer! – amoeba Jun 29 '17 at 11:28
  • 1
    I tried the hack and it works. I updated Jake's answer in https://stats.stackexchange.com/questions/142685 to include this hack there. Unless he (Jake) does not like it and removes my edit, your Q will be a duplicate :-) – amoeba Jun 29 '17 at 11:43

0 Answers0