3
$\begingroup$

I want to do some calculations using mixed model regression. I have $n_j$ observations for the $j$-th subject. (The random effect corresponds to the subject.) The problem is that I would like to add weights to the regression so that all the subjects influence equally the result, regardless of the number of observations for each subject. So the wights must be $1/n_j$ for the $j$-th subject. How can I do it in R?

$\endgroup$
4
  • 2
    $\begingroup$ stat.ethz.ch/pipermail/r-sig-mixed-models/2014q3/022570.html: From Ben Bolker: " I have successfully used weights=varFixed(~I(1/n)) [inverse-variance weighting based on the number of samples per group] in lme; alternatively, you could use weights=n in lmer (from the lme4 package) to get an equivalent result." $\endgroup$
    – mkt
    Mar 29, 2018 at 8:06
  • $\begingroup$ @mkt Thank you! I was confused with the difference between lm and lme. stats.stackexchange.com/questions/70425/… But I think I am to use weights=~n, not weights=~I(1/n) in lme. Is it so? Yet a bit confused. $\endgroup$
    – Viktor
    Mar 29, 2018 at 12:11
  • $\begingroup$ Haven't tried it myself, but not what Bolker suggests in that answer. The specific formulation should be easy to figure out in the documentation. $\endgroup$
    – mkt
    Mar 29, 2018 at 14:34
  • $\begingroup$ a little source code and a toy/dummy data frame would allow an answer with actual code that runs on the dummy data, so you can see if it does what you are wanting. Some folks would say "this is a programming question so it belongs on SE not CV, but that is them. $\endgroup$ Jul 25, 2019 at 19:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.