[R] sample weights in ols

Thomas Lumley tlumley at uw.edu
Wed May 11 22:17:39 CEST 2011


On Thu, May 12, 2011 at 2:43 AM, jour4life <jour4life at gmail.com> wrote:
> I have a follow up question. When using svyglm, it does not matter that I am
> not using survey design and only weights?
> In other words,
>
> fit<-svyglm(y~x1+x2+...xk,data=dataset,weights=weightvariable)
>
> Or am I going to have to construct a survey design variable, using only the
> weight variable?

You will have to construct a survey design.  It's not difficult.

my.first.survey.design <- svydesign(id=~1, weights=~weightvariable,
data=dataset)

fit<-svyglm(y~x1+x2+...xk, design=my.first.survey.design)

   -thomas

-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland



More information about the R-help mailing list