Message-ID: <47D5B7BF.4020806@biostat.ku.dk>
Date: 2008-03-10T22:35:43Z
From: Peter Dalgaard
Subject: Mimicking SPSS weighted least squares
In-Reply-To: <DA501E8C-BE17-4E98-B51B-9B4773693C77@auckland.ac.nz>
Rolf Turner wrote:
> On 11/03/2008, at 4:04 AM, Ben Domingue wrote:
>
>
>> Howdy,
>> In SPSS, there are 2 ways to weight a least squares regression:
>> 1. You can do it from the regression menu.
>> 2. You can set a global weight switch from the data menu.
>> These two options have no, in my experience, been equivalent.
>> Now, when I run lm in R with the weights= switch set accordingly, I
>> get the same set of results you would see with option #1 in SPSS.
>> Does anybody know how to duplicate option #2 from SPSS in R?
>>
>
> I think it's up to you to find out what ``option #2 from SPSS'' actually
> *does*. If you know that, then you can (with a modicum of effort)
> duplicate that option in R. The help file for lm() tells you that
> R uses the weights by minimizing sum(w*e^2) where w = weights and
> e = ``errors'' or residuals.
>
>
>
I believe case weighting in SPSS effectively replicates the relevant row
(not sure if anything sensible comes out if weights are non-integer). So
lm(...., data=mydata[rep(1:nrow(mydata),w),])
or thereabouts should do it. Might not be too efficient though.
--
O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907