Skip to content

sample weights in ols

6 messages · Thomas Lumley, jour4life

#
Hello all,

I am wondering if there is a way to specify sampling weights for an ols
model using sample weights.

For instance, right now, my code is:

fit.ex<-lm(y~x1+x2+x3+...xk,data=dataset,weights=weightvariable.)
summary(fit.ex)

But, there is almost no difference in the coefficients nor standard errors.
I am skeptical that I am using the option correctly since many posts state
that the "weights" option is for weighted least squares. Or is this the same
thing?

Any help is appreciated!

Thanks

Carlos

--
View this message in context: http://r.789695.n4.nabble.com/sample-weights-in-ols-tp3510865p3510865.html
Sent from the R help mailing list archive at Nabble.com.
#
On Tue, May 10, 2011 at 2:50 PM, jour4life <jour4life at gmail.com> wrote:
You want svyglm() in the survey package.

    -thomas
#
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?

Thanks,

Carlos

--
View this message in context: http://r.789695.n4.nabble.com/sample-weights-in-ols-tp3510865p3514920.html
Sent from the R help mailing list archive at Nabble.com.
#
On Thu, May 12, 2011 at 2:43 AM, jour4life <jour4life at gmail.com> wrote:
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