[R] Contingency Table Analysis - specific cell to specific cell comparisons

Tsunhin John Wong thjwong at gmail.com
Thu Jul 22 11:26:41 CEST 2010


Dear David and the list,

Thanks for your comment.
Unfortunately, I don't have an instructor on R.
And I usually don't deal with contingency table analysis.

I have consulted more than two books on R already, but I found no good answer.
Could you point me to some references about log linear modeling / GLM
with Poisson with R that mention techniques of specific cell-to-cell
comparisons and interpretation of the results?

Any other suggestion is greatly appreciated.
Thanks in advance.

Best regards,

John


On Wed, Jul 21, 2010 at 2:24 PM, David Winsemius <dwinsemius at comcast.net> wrote:
>
> On Jul 21, 2010, at 8:07 AM, Tsunhin John Wong wrote:
>
>> Dear R users,
>>
>> I have a question of how to do some specific cell to cell comparisons
>> on a R x C contingency table.
>> The table is a 3 x 5 table with frequency / count data.
>>
>>> langcons.table <- table(lang, cons)
>>> langcons.table[cbind(lang,cons)] <- freq
>>> langcons.table
>>
>>  Adj Int Oth Pas Tra
>> C  69 221  17   3 198
>> E  56 214  33  31 174
>> J  36 291   8   9 164
>>
>> I know how to do an independent model test using Poisson in glm
>>>
>>> glm.out1 <- glm(freq~lang+cons, family=poisson, data=langcons.data)
>>> summary(glm.out1)
>>
>> And then fit the saturated model
>>>
>>> glm.out2 <- glm(freq~lang*cons, family=poisson, data=langcons.data)
>>> summary(glm.out2)
>>
>> However, the results are difficult to interpret:
>> C and Adj are used to as a baseline.
>> And I can only see main effects and interactions and *always according
>> to the baseline*.
>> Coefficients:
>>                        Estimate Std. Error z value Pr(>|z|)
>> (Intercept)
>> lang1
>> lang2
>> cons1
>> cons2
>> cons3
>> cons4
>> lang1:cons1
>> lang2:cons1
>> lang1:cons2
>> lang2:cons2
>> lang1:cons3
>> lang2:cons3
>> lang1:cons4
>> lang2:cons4
>>
>> If anyone know, please suggest me some way to do specific cell to cell
>> comparison on such a contingency table.
>
> Even if you are daunted by the task of plugging the covariates into the
> formula, exp(intercept+sum(beta_N*var_n)), you can always use the predict
> function to create an estimate for all (or a specific set) of the
> covariates. They come out on the log(rate) scale so would need to be
> exponentiated. Consult your instructor for further help.
>
>
>> Say, to compare pairs of cells:
>> along a column: 3 vs 31, 9 vs 31, 3 vs 9
>> along a row: 36 vs 9
>> or even across column and row: 36 vs 31, and 36 vs 3
>
>
> David Winsemius, MD
> West Hartford, CT
>
>



More information about the R-help mailing list