Skip to content

Weights

4 messages · Francois Maurice, Alan Haynes, Ben Bolker +1 more

#
Francois Maurice <maurice.francois at ...> writes:
Maybe not exactly what you want, but if you know the variances
corresponding to the weights you want to impose (say they are a variable
'estvars' in your data frame) I think you could
use

lme(..., weights=varFixed(~estvars), ...) 
  

in particular, to use wts 'wts' you probably want to use

lme(..., weights=varFixed(~I(1/wts)), ...)

  To make sure that I'm not crazy I would suggest that you try
some simple cases using this approach with lme and lmer, using
explicit weights in the lmer case, and see if you get the same
answers ...

  (If anyone has a better idea or knows this to be wrong,
please speak up !)
#
On 06/28/2012 12:36 PM, Ben Bolker wrote:
Hi -- this seems to work (since the fixed variance function is the default, it 
can be omitted in the weights= argument to lme). In lmer, the weight that has 
the mean standardized to one produces different results from the one that does 
not, but in lme they both produce the same results. It might be useful to 
explore that a little further.

<code>

## example data
td <- data.frame(y=1:100,
                  g=factor(rep(1:20, 5)),
                  f=factor(rep(1:5, 20)),
                  wgt=100:1)
td$relwgt <- td$wgt/mean(td$wgt)
## replicate the data by the number of weights
ltd <- td[rep(rownames(td), td$wgt),]

library(nlme)
summary(lme(y ~ 1, random= ~1|g, data=td))
summary(lme(y ~ 1, random= ~1|g, data=td, weights=~1/wgt))
summary(lme(y ~ 1, random= ~1|g, data=td, weights=~1/relwgt))
## without weights on the replicated data
summary(lme(y ~ 1, random= ~1|g, data=ltd)
detach(package:nlme)
library(lme4)
summary(lmer(y ~ 1 + (1|g), data=td))
summary(lmer(y ~ 1 + (1|g), data=td, weights=wgt))
summary(lmer(y ~ 1 + (1|g), data=td, weights=relwgt))
## without weights on the replicated data
summary(lmer(y ~ 1 + (1|g), data=ltd))
detach(package:lme4)


</code>

HTH,

Markus