[R] analysis of data with observation weights

Michal Bojanowski bojaniss at poczta.onet.pl
Thu Nov 14 23:15:33 CET 2002


Hello John,

Thursday, November 14, 2002, 9:07:51 PM, you wrote:

JF> Dear Michal,

JF> As far as I know (and I'd be happy to be wrong), there's no *general* way 
JF> of introducing case weights in R. The glm function, however, accommodates 
JF> case weights via its weights argument, and this might be sufficient to do 
JF> what you want to do. You'll have to be careful with inferences, though.

JF> Perhaps someone else on the list can provide additional information.

JF> John

Thank you for your answer professor Fox.

I did perform an "experiment" (which follows) using 'weight' argument, but in lm() function. The
help page states, that this argument should contain weights used in weighted
regression fitting process. I dont feel strong in WLS I must say (to state it
diplomatically) so I dont know if it is possible use 'weight' argument to solve
my problem.

I generated the data:

x <- rep(c(1,2), c(6,4))
y <- rep(c(1,2,3,4),c(2,3,3,2))

# which look like
cbind(x,y)

# now I fit a model
summary(m <- lm(y~x))

# now when I create "collapsed" data
x1 <- rep(c(1,2), c(3,2))
y1 <- rep(c(1,2,3,4), c(1,1,2,1))

# with frequencies
w <- c(2,3,1,2,2)

# which look like
cbind(x1,y1,w)

# and fit a model
summary(m1 <- lm(y1~x1, weight=w))

I'm gettin the same coefficients, but different standard errors. I guess this is
what you had in mind.

I guess I need a book on WLS... Thank you for the answer anyway.


Michal



ps. Also, I would like to thank you for your fine lecture about S/R in Ann Arbor
this summer -- which I attended with great pleasure.





~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~
Michal Bojanowski
Institute for Social Studies
University of Warsaw
Poland
http://www.iss.uw.edu.pl

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list