Re: [R] Weighting data when running regressions

From: Elena Wilson <wilson_family_at_optusnet.com.au>
Date: Tue, 11 Mar 2008 10:18:24 +1100

It works!!!
Thanks a lot Chuck!

-----Original Message-----
From: Chuck Cleland [mailto:ccleland_at_optonline.net] Sent: Monday, 10 March 2008 11:29 PM
To: Elena Wilson
Cc: r-help_at_r-project.org
Subject: Re: [R] Weighting data when running regressions

On 3/10/2008 7:49 AM, Elena Wilson wrote:
> Dear R-Help,
>
> I'm new to R and struggling with weighting data when I run regression.
I've
> tried to use search to solve my problem but haven't found anything helpful
> so far.
>
> I (successfully) import data from SPSS (15) and try to run a linear
> regression on a subset of my data file where WEIGHT is the name of my
> weighting variable (numeric), e.g.:
>
> library(foreign)
>
> data1=read.spss("File.sav", use.value.labels = FALSE, to.data.frame =
TRUE)
>
> summary(data1) ' shows me all the variables OK
>
> attach(data1)
>
> linmod=lm(Y~X1+X2+X3+X4W, subset=(X5==1 & X6==7), weights==WEIGHT)
>
> and I get the following Error message:
>
> Error in weights == WEIGHT :
>
> comparison (1) is possible only for atomic and list types
>
> It works perfectly if I don't use the ", weights==WEIGHT" bit

   Try it with just one equals sign after weights:

linmod=lm(Y~X1+X2+X3+X4W, subset=(X5==1 & X6==7), weights=WEIGHT)

> Could you please let me know what I am doing wrong?
>
> Thank you in advance,
>
> Lena
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_r-project.org 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.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

______________________________________________
R-help_at_r-project.org 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.
Received on Tue 11 Mar 2008 - 00:13:09 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 11 Mar 2008 - 00:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive