Dear R experts,

I sent this question to the r-help list but didn’t get much response, probably because it is more of a stats question. But as this blog is syndicated on r-bloggers I thought I would try it again here on this blog. If I am barking up the wrong tree, feel free to flame.

When I have to analyze educational datasets with samples of children from samples of schools and which include sampling weights, I use the survey package e.g. to calculate means and confidence intervals or to do a linear model. But this kind of design (e.g. children nested inside schools) also as I understand it requires looking at the mixed effects. But this isn’t possible using the survey package. Perhaps I am better advised to use nlme – I guess I could use the sample weights as predictors in nlme regressions but I don’t think that is correct.

It seems that this kind of design (in fact any stratified survey sample which includes nested levels) needs analysing from both perspectives – (survey weights and mixed effects) at once – but the packages of choice for each of these perspectives, survey and nlme, each don’t seem to have slots for the other perspective.

If someone could put me on the right track I could be more specific with reproducible examples etc

Best Wishes

Steve Powell

Did you try the “stats” area at stackexchange.com? (or maybe stackoverflow.com)

Thanks Carl, yes I did, at http://stats.stackexchange.com/ which I guess is the right place. Didn’t get any response though.

Hi Steve, my understanding of this issue is that you would use the hierarchical model to appropriately model the data, and then make any adjustments needed due to survey weighting through post-stratification. This requires that your model includes the criteria which your survey weights distinguish, as well as any interactions that might be important. If you search for ‘survey weights’ on Andrew Gelman’s blog you will probably find a much more distinguished response to this question (hopefully consistent with what I describe above!).

Good luck – Nick

Thanks Nick! Indeed Andrew Gelman’s blog was very useful. I am still reading through.

Incidentally, I just today found that lavaan, my favourite sem package, now has a sister lavaan.survey which is a wrapper for both lavaan and the survey package. So as sem can do multi-level modelling, this might be another option.

The asreml package has the capability to do what you want. I’m fairly certain it is free if you are part of an educational institution.

Hi Steve,

I have a similar issue, so if you could post any findings on your r-blogger’s syndicated blog I would be most appreciative!

Hi Steve,

R-bloggers should not be used for forum questions.

Your post is removed. Please do not do this again (imagine how the site would look if 10 more bloggers would start asking questions on the site)

If you will come up with a good answer, THAT would be a good post for r-bloggers

Cheers,

Tal