Ben, you are right, "weights=varFixed(~I(1/n))" seems to work like a charm! And my apologies to the MLwiN team, which do a great job. In time: in order to use multiple weigths (in different levels), we have to use varIdent, right? Somethight, like: weights=varIdent(~1|I(1/n1)*I(1/n2)*I(1/n3)) Best, Rodrigo
On 28-08-2014 14:52, Ben Bolker wrote:
On 14-08-28 07:01 AM, Rodrigo Travitzki wrote:
Dear R masters, I'm looking for a R package to do multilevel analysis of a weighted data (is a weigthed sample of brazilian educational data) but could not find it. There is just a "weights" option in lme(), but is not about frequency (or probability) weigths in data. In some foruns, no response either. So, could you please confirm this information for me? There is any R package/function which do this? I really don't want to use proprietary software, but if there is no option, I'll need to do so. Thank you very much. Best wishes, Rodrigo Travitzki
It depends a little bit what you want to do/the meaning of the weights. 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. If you want to deal with survey weighting, the story seems to be considerably more complicated -- I don't claim to understand it, but Andrew Gelman (a fairly prominent applied Bayesian statistician) claims that it's "a mess" (to use his phrase). If the weights represent probability of inclusion in a survey, I believe he would recommend model-based inference -- that is, fit an unweighted multilevel regression model and then use post-stratification/weighting to make predictions (see http://andrewgelman.com/?s=survey+weights for various discussion and links to papers). good luck, Ben Bolker
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models