This is but a 2 by 2 by 2 table, where you are asking for the interaction.
That can be put into a generalized linear model with binomial error, normally with a logit link, but since you are asking for differences in proportions you may use the identity link (since yiour data are well-behaved).
Here is a small R-program that does the two analyses and gives the likelihood-ratio tests (both non-significant) on the two scales (note the trick to generate the identity link on the fly, it is not available by default):
hh <- read.table( "Haidich.txt", header=T )
hh
str(hh)
# Model where events depend on journal and period, that is
m0 <- glm( event ~ jn + factor(per), weight=n, family=binomial(link=log), data=hh )
# Update (and compare to) a model where the difference between years depend onn journal
anova( m0, m1 <- update( m0, . ~ . + jn:factor(per) ), test="Chisq" )
summary(m0)
summary(m1)
# Now do the same on the identity link scale
m0i <- glm( event ~ jn + factor(per), weight=n, family=binomial(link=make.link("identity")), data=hh )
anova( m0i, m1i <- update( m0i, . ~ . + jn:factor(per) ), test="Chisq" )
summary(m0i)
summary(m1i)
This is the result of running the code; the file Haidich.txt looks just as the
printout of the dataframe hh.
Note that you original difference between changes 4.5% minus -1.8% = 6.3% appears as the estimate of the interaction term in the model using identity link, almost at the bottopm of the output.
Best regards,
Bendix
R 2.10.0
---------------------------------------------
Program: Haidich.R
Folder: C:\stat\R\BxC\Examples
Started: tirsdag 01. december 2009, 16:55:52
---------------------------------------------
> hh <- read.table( "Haidich.txt", header=T )
> hh
n event jn per
1 33 1 A 2003
2 50 0 A 2003
3 18 1 A 2006
4 33 0 A 2006
5 22 1 B 2003
6 21 0 B 2003
7 27 1 B 2006
8 24 0 B 2006
> str(hh)
'data.frame': 8 obs. of 4 variables:
$ n : int 33 50 18 33 22 21 27 24
$ event: int 1 0 1 0 1 0 1 0
$ jn : Factor w/ 2 levels "A","B": 1 1 1 1 2 2 2 2
$ per : int 2003 2003 2006 2006 2003 2003 2006 2006
> # Model where events depend on journal and period, that is
> m0 <- glm( event ~ jn + factor(per), weight=n, family=binomial(link=log), data=hh )
> # Update (and compare to) a model where the difference between years dpend onn journal
> anova( m0, m1 <- update( m0, . ~ . + jn:factor(per) ), test="Chisq" )
Analysis of Deviance Table
Model 1: event ~ jn + factor(per)
Model 2: event ~ jn + factor(per) + jn:factor(per)
Resid. Df Resid. Dev Df Deviance P(>|Chi|)
1 5 308.14
2 4 307.89 1 0.25374 0.6145
> summary(m0)
Call:
glm(formula = event ~ jn + factor(per), family = binomial(link = log),
data = hh, weights = n)
Deviance Residuals:
1 2 3 4 5 6 7 8
7.934 -6.975 5.955 -5.554 5.287 -5.630 5.999 -5.881
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.95384 0.12320 -7.742 9.77e-15
jnB 0.31865 0.14989 2.126 0.0335
factor(per)2006 -0.03126 0.14959 -0.209 0.8345
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 312.63 on 7 degrees of freedom
Residual deviance: 308.14 on 5 degrees of freedom
AIC: 314.14
Number of Fisher Scoring iterations: 6
> summary(m1)
Call:
glm(formula = event ~ jn + factor(per) + jn:factor(per), family = binomial(link = log),
data = hh, weights = n)
Deviance Residuals:
1 2 3 4 5 6 7 8
7.802 -7.119 6.123 -5.360 5.430 -5.486 5.860 -6.015
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.9223 0.1351 -6.827 8.7e-12
jnB 0.2522 0.2011 1.254 0.210
factor(per)2006 -0.1191 0.2328 -0.512 0.609
jnB:factor(per)2006 0.1533 0.3063 0.500 0.617
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 312.63 on 7 degrees of freedom
Residual deviance: 307.89 on 4 degrees of freedom
AIC: 315.89
Number of Fisher Scoring iterations: 6
>
> # Now do the same on the identity link scale
> m0i <- glm( event ~ jn + factor(per), weight=n, family=binomial(link=make.link("identity")), data=hh )
> anova( m0i, m1i <- update( m0i, . ~ . + jn:factor(per) ), test="Chisq" )
Analysis of Deviance Table
Model 1: event ~ jn + factor(per)
Model 2: event ~ jn + factor(per) + jn:factor(per)
Resid. Df Resid. Dev Df Deviance P(>|Chi|)
1 5 308.11
2 4 307.89 1 0.21537 0.6426
> summary(m0i)
Call:
glm(formula = event ~ jn + factor(per), family = binomial(link = make.link("identity")),
data = hh, weights = n)
Deviance Residuals:
1 2 3 4 5 6 7 8
7.908 -7.004 5.994 -5.510 5.273 -5.644 6.008 -5.873
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.38773 0.04908 7.901 2.78e-15
jnB 0.14386 0.06723 2.140 0.0324
factor(per)2006 -0.01906 0.06619 -0.288 0.7734
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 312.63 on 7 degrees of freedom
Residual deviance: 308.11 on 5 degrees of freedom
AIC: 314.11
Number of Fisher Scoring iterations: 4
> summary(m1i)
Call:
glm(formula = event ~ jn + factor(per) + jn:factor(per), family = binomial(link = make.link("identity")),
data = hh, weights = n)
Deviance Residuals:
1 2 3 4 5 6 7 8
7.802 -7.119 6.123 -5.360 5.430 -5.486 5.860 -6.015
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.39759 0.05372 7.401 1.35e-13
jnB 0.11404 0.09326 1.223 0.221
factor(per)2006 -0.04465 0.08581 -0.520 0.603
jnB:factor(per)2006 0.06243 0.13439 0.465 0.642
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 312.63 on 7 degrees of freedom
Residual deviance: 307.89 on 4 degrees of freedom
AIC: 315.89
Number of Fisher Scoring iterations: 3
>
---------------------------------------------
Program: Haidich.R
Folder: C:\stat\R\BxC\Examples
Ended: tirsdag 01. december 2009, 16:55:53
Elapsed: 00:00:01
---------------------------------------------