Dear all,
I am struggling with a problem which I have been reading on the forums about and it did not seem to me that there is a precise answer to my question. However, I still hope there is one. I am working with PIRLS data and trying to conduct multilevel analysis. There are different weights for each level of analysis in the PIRLS dataset (e.g. there is a school weight, class weight, student weight). Is there a function in R which would let me use different weights for different levels of my model? If yes, which package contains it? I would be very grateful for any help! |
Hello,
The link you've posted is to a page that does NOT have a dataset, it has links to other pages. The proper way of posting a data example would be # paste the output of this in a post dput(head(yourdata, 20)) # or 30 Now, if I understand your question, function sample() does have a weights argument, 'prob'. (Package base.) See help("sample") Hope this helps, Rui Barradas Em 10-06-2012 20:00, Tamara escreveu: > Dear all, > > I am struggling with a problem which I have been reading on the forums about > and it did not seem to me that there is a precise answer to my question. > However, I still hope there is one. > > I am working with http://timss.bc.edu/ PIRLS data and trying to conduct > multilevel analysis. There are different weights for each level of analysis > in the PIRLS dataset (e.g. there is a school weight, class weight, student > weight). > Is there a function in R which would let me use different weights for > different levels of my model? > If yes, which package contains it? > > I would be very grateful for any help! > > > > > > > -- > View this message in context: http://r.789695.n4.nabble.com/sampling-weights-for-multilevel-models-tp4632947.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. |
In reply to this post by Tamara
On Mon, Jun 11, 2012 at 7:00 AM, Tamara <[hidden email]> wrote:
> Dear all, > > I am struggling with a problem which I have been reading on the forums about > and it did not seem to me that there is a precise answer to my question. > However, I still hope there is one. > > I am working with http://timss.bc.edu/ PIRLS data and trying to conduct > multilevel analysis. There are different weights for each level of analysis > in the PIRLS dataset (e.g. there is a school weight, class weight, student > weight). > Is there a function in R which would let me use different weights for > different levels of my model? > If yes, which package contains it? > As far as I know there is no function that does what you want. In particular, lme() and lmer() don't work correctly with sampling weights. It does depend on why you want a multilevel model. If you are primarily interested in the mean model and the variance components are just needed to get appropriate standard errors, then you can use the svyglm() function in the survey package to fit a linear regression with appropriate standard errors. On the other hand, if you are interested in estimating the variance components for their own sake, you need some other software. I do have longer-term plans to add multilevel modelling capabilities to the survey package, but it's harder than it may appear. -thomas -- Thomas Lumley Professor of Biostatistics University of Auckland ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. |
In reply to this post by Rui Barradas
Thank you very much, Rui!
But I am afraid that I won't be able to use this function for multilevel analysis, as unfortunately I don't see how exactly I will combine it with functions in the R packages for multilevel analysis . |
Thank you very much, Thomas!
As I need to estimate the variance components, I will most probably have to switch from R to HLM or Mplus to apply different weights to different levels. Although I prefer R in general. |
Free forum by Nabble | Edit this page |