I want to calculate a 95% CIs for the cell proportions in a 4*8 contingency table, however, I am not sure what is the best way to do this? Any good advice? I would prefer to do it in SPSS or R.
As always there are many possibilities. Here is a solution for cell counts with R and the function glm (generalized linear model), used to fit a log-linear model, i.e. a Poisson model with a log link (default value for family = poisson). In this example I have fitted a (saturated) model with interactions.
> ## dummy data
> set.seed(123)
> dfr dfr$y dfr
x1 x2 y
1 a A 9
2 b A 11
3 c A 18
4 d A 14
5 a B 21
6 b B 30
7 c B 25
8 d B 17
9 a C 21
10 b C 38
11 c C 35
12 d C 36
13 a D 41
14 b D 38
15 c D 51
16 d D 49
17 a E 50
18 b E 46
19 c E 45
20 d E 51
21 a F 55
22 b F 70
23 c F 61
24 d F 54
25 a G 61
26 b G 69
27 c G 70
28 d G 72
29 a H 88
30 b H 80
31 c H 86
32 d H 111
> ## contingency table
> (xtab
> ## log-linear model with glm
> fm1 summary(fm1)
Call:
glm(formula = y ~ x1 * x2, family = poisson, data = dfr)
Yes actually this would depend on the sampling method used in the crosstabulation.
Here Renaud naturally presupposes (mentioning other possibilities) that it is poisson sampling. But there are other sampling schemes like product multinomial or hypergeometric sampling valid for such a crosstabulation. Since the question's owner did not specify it, the answer would be dependent to poisson sampling.
Sure! Also the study design should be considered, with possible overdispersion (with respect to Poisson, binomilal, etc.) arising from sampling clusters of individuals (families, herds, etc.).
If you mean percentage of the grand total, simply divide the results (predictions) by the grand total N. Alternatively, you can use an offset term in the Poisson model (= log(N)) and predict for new data with N=1.