[R] Contingency Table Analysis - specific cell to specific cell comparisons
David Winsemius
dwinsemius at comcast.net
Wed Jul 21 14:24:35 CEST 2010
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