[R] R vs SPSS contrasts
Gabor Grothendieck
ggrothendieck at gmail.com
Sun Oct 12 20:03:53 CEST 2008
I found this link:
http://webs.edinboro.edu/EDocs/SPSS/SPSS%20Regression%20Models%2013.0.pdf
which indicates that the contrast in SPSS that is used
depends not only on the contrast selected but also on the
reference category selected and the two can be chosen
independently. Thus one could have simple/first, simple/last,
deviation/first, deviation/last, etc. An R contr.SPSS function
would have to specify both the deviation type and the
first/last in order to handle all SPSS variations.
On Sun, Oct 12, 2008 at 1:48 PM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote:
> The formula should be (diag(n) - 1/n)[, -n]
>
> On Sun, Oct 12, 2008 at 1:36 PM, Gabor Grothendieck
> <ggrothendieck at gmail.com> wrote:
>> Looks like the contrast matrix for indicator is contr.SAS(n),
>> for deviation is contr.sum(n) and for simple is:
>>
>> (diag(n) - 1/n)[, -1]
>>
>> That works at least for the n = 3 example in the link.
>> Perhaps the others could be checked against SPSS
>> for a variety of values of n to be sure.
>>
>> On Sun, Oct 12, 2008 at 12:32 PM, Chuck Cleland <ccleland at optonline.net> wrote:
>>> On 10/11/2008 3:31 PM, Ted Harding wrote:
>>>> Hi Folks,
>>>>
>>>> I'm comparing some output from R with output from SPSS.
>>>> The coefficients of the independent variables (which are
>>>> all factors, each at 2 levels) are identical.
>>>>
>>>> However, R's Intercept (using default contr.treatment)
>>>> differs from SPSS's 'constant'. It seems that the contrasts
>>>> were set in SPSS using
>>>>
>>>> /CONTRAST (varname)=Simple(1)
>>>>
>>>> I can get R's Intercept to match SPSS's 'constant' if I use
>>>> contr.sum in R.
>>>>
>>>> Can someone please confirm that that is a correct match for
>>>> the SPSS "Simple(1)", with identical effect?
>>>>
>>>> And is there a convenient on-line reference where I can look
>>>> up what SPSS's "/CONTRAST" statements exactly mean?
>>>> I've done a lot of googling, withbout coming up with anything
>>>> satisfactory.
>>>>
>>>> With thanks,
>>>> Ted.
>>>
>>> Hi Ted:
>>> Here are two links with the same content giving a brief description of
>>> SPSS simple contrasts:
>>>
>>> http://www.ats.ucla.edu/stat/spss/library/contrast.htm
>>> http://support.spss.com/productsext/spss/documentation/statistics/articles/contrast.htm
>>>
>>> These pages explain how simple contrasts differ from indicator
>>> (contr.treatment) and deviation (contr.sum) contrasts. For a factor
>>> with 3 levels, I believe you can reproduce SPSS simple contrasts (with
>>> the first category as reference) like this:
>>>
>>>> C(warpbreaks$tension, contr=matrix(c(-1/3,2/3,-1/3,-1/3,-1/3,2/3),
>>> ncol=2))
>>> ...
>>> attr(,"contrasts")
>>> [,1] [,2]
>>> L -0.3333333 -0.3333333
>>> M 0.6666667 -0.3333333
>>> H -0.3333333 0.6666667
>>> Levels: L M H
>>>
>>> For a factor with 2 levels, like this:
>>>
>>>> C(warpbreaks$wool, contr=matrix(c(-1/2,1/2), ncol=1))
>>> ...
>>> attr(,"contrasts")
>>> [,1]
>>> A -0.5
>>> B 0.5
>>> Levels: A B
>>>
>>> Your description of the effect of SPSS simple contrasts - intercept
>>> coefficient of contr.sum and non-intercept coefficients of
>>> contr.treatment - sounds accurate to me.
>>>
>>> hope this helps,
>>>
>>> Chuck
>>>
>>>> --------------------------------------------------------------------
>>>> E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
>>>> Fax-to-email: +44 (0)870 094 0861
>>>> Date: 11-Oct-08 Time: 20:31:53
>>>> ------------------------------ XFMail ------------------------------
>>>>
>>>> ______________________________________________
>>>> 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. (www.ndri.org)
>>> 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.
>>>
>>
>
More information about the R-help
mailing list