[R-lang] Re: Coding

Reinhold Kliegl kliegl@uni-potsdam.de
Sat Jun 19 14:30:32 PDT 2010


... sorry for four levels it is of course:

 > library(MASS)
 > contr.sdif(4)
     2-1  3-2   4-3
1 -0.75 -0.5 -0.25
2  0.25 -0.5 -0.25
3  0.25  0.5 -0.25
4  0.25  0.5  0.75

Reinhold Kliegl
On 19.06.2010, at 22:16, Reinhold Kliegl wrote:

> This is an incorrect contrast specification for successive  
> differences! The correct specification depends on the number of  
> levels. The simplest way to get the correct difference is to use  
> contr.sdif from MASS. In this case:
>
> library(MASS)
> contr.sdif(3)
>
> I realize this is very counterintuitive for many people, but see  
> Venerables & Ripley (2002, section 6.2 ).
>
> Reinhold Kliegl
>
> On 19.06.2010, at 21:15, Maureen Gillespie wrote:
>
>> Hey Peter, Steve, and r-lang,
>>    Not sure if I'm going to be able to answer your questions, but  
>> I'll give it a shot.  I think Steve is right in the sense that  
>> forward difference coding would get you the answers to the  
>> questions about whether one level is significantly different that  
>> the previous level (i.e., if D > E1, rather than is D > the mean of  
>> E1, F1, E2, F2, which is what Helmert tests).  However, forward  
>> difference coding does not produce orthogonal coding variables -  
>> i.e., below, the sum of the dot products of AvB and BvC is != 0,  
>> same goes for BvC and CvD.  So, there will be some degree of  
>> colinearity among coding variables if you use this coding scheme,  
>> so that's an issue for getting estimates you can trust.
>>
>>     AvB    BvC     CvD
>> A   .5        0          0
>> B  -.5       .5          0
>> C   0       -.5          .5
>> D   0        0          -.5
>>
>>








More information about the ling-r-lang-L mailing list