Skip to main content

Ex. 7 – Count data (Poisson regression)

Order-restricted hypothesis testing in a generalized linear model: the effect of El Niño on the number of hurricanes.

The research question

restriktor also works for generalized linear models fitted with glm(), such as logistic regression for binary outcomes or Poisson regression for counts. Here we use the Hurricanes dataset: the number of hurricanes per year from 1950 to 1995, together with the El Niño phase of that year (1 = cold, 2 = neutral, 3 = warm). The data are taken from Silvapulle and Sen (2005).

A warm phase (El Niño) is known to suppress hurricane activity in the Atlantic, and a cold phase (La Niña) to enhance it. The expectation is therefore:

\[ H_1: \lambda_{Cold} \geq \lambda_{Neutral} \geq \lambda_{Warm}, \]

where \(\lambda\) is the expected number of hurricanes per year.

Step 1 – prepare the data

ElNino is stored as a number, so we first turn it into a factor with meaningful labels:

library(restriktor)

Hurricanes$ElNino <- factor(Hurricanes$ElNino, levels = 1:3,
                            labels = c("Cold", "Neutral", "Warm"))
aggregate(Hurricanes ~ ElNino, data = Hurricanes,
          FUN = function(x) c(mean = mean(x), n = length(x)))
   ElNino Hurricanes.mean Hurricanes.n
1    Cold        6.800000    15.000000
2 Neutral        6.250000    16.000000
3    Warm        4.066667    15.000000

Step 2 – fit a Poisson regression

Counts are modelled with a Poisson regression (log link). Without the intercept, each coefficient is the log of the expected count in a phase:

fit.pois <- glm(Hurricanes ~ -1 + ElNino, family = poisson, data = Hurricanes)
coef(fit.pois)
   ElNinoCold ElNinoNeutral    ElNinoWarm 
     1.916923      1.832581      1.402824 
exp(coef(fit.pois))   # expected number of hurricanes per year
   ElNinoCold ElNinoNeutral    ElNinoWarm 
     6.800000      6.250000      4.066667 

Since the log is an increasing function, the ordering of the log-means is the same as the ordering of the means. We can therefore impose the restrictions directly on the coefficients.

Step 3 – test the hypothesis

H1 <- ' ElNinoCold > ElNinoNeutral > ElNinoWarm '

out <- iht(fit.pois, constraints = H1)
out

Restriktor: restricted hypothesis tests: 


Constraint matrix:
   ElNinoCold ElNinoNeutral ElNinoWarm    op rhs active
1:          1            -1          0    >=   0     no
2:          0             1         -1    >=   0     no


Overview of all available hypothesis tests:

Global test: H0: all parameters are restricted to be equal (==)
         vs. HA: at least one inequality restriction is strictly true (>)
       Test statistic: 10.9408,   p-value: 0.002314

Type A test: H0: all restrictions are equalities (==) 
         vs. HA: at least one inequality restriction is strictly true (>)
       Test statistic: 10.9408,   p-value: 0.002314

Type B test: H0: all restrictions hold in the population
         vs. HA: at least one restriction is violated
       Test statistic: 0.0000,   p-value: 1

Joint Type A and Type B test (Wolak, 1989, Theorem 1):
         joint tail probability under H0: Rb = r (least favorable null)
       Pr[Type B >= 0.0000, Type A >= 10.9408]:   p-value: 0.002314

Type C test: H0: at least one restriction is false or active (==) 
         vs. HA: all restrictions are strictly true (>)
       Test statistic: 0.5993,   p-value: 0.276

Note: Type C test is based on a t-distribution (one-sided), 
      all other tests are based on a mixture of F-distributions.

Step 4 – interpret the results

  • Type B is not rejected (\(\bar{F}\) = 0.00, p = 1.000): the data are in line with the expected ordering.
  • Type A is rejected (\(\bar{F}\) = 10.94, p = .002).

Conclusion: the data support the expectation that the number of hurricanes decreases from cold to neutral to warm El Niño phases.

Type C is not significant (\(t\) = 0.60, p = .276). The difference between the cold and neutral phases is small (6.80 versus 6.25 hurricanes per year), so we cannot conclude that both steps are strictly positive.

Model selection with the GORIC

goric() supports generalized linear models as well:

out.goric <- goric(fit.pois, hypotheses = list(H1 = H1),
                   comparison = "complement")
out.goric$result
       model    loglik penalty    goric loglik.weights penalty.weights
1         H1 -95.55329  1.8559 194.8184       0.544778       0.6874446
2 complement -95.73288  2.6441 196.7540       0.455222       0.3125554
  goric.weights
1     0.7246793
2     0.2753207

\(H_1\) is 2.63 times more supported than its complement. This is in line with the test result, and it also shows that the support is modest, because the cold and neutral phases hardly differ.

Overdispersion

A Poisson model assumes that the variance equals the mean. If the counts vary more than that (overdispersion), the standard errors are too small and the p-values too optimistic. A simple check is to compare the residual deviance with its degrees of freedom:

c(deviance = deviance(fit.pois), df = df.residual(fit.pois))
deviance       df 
28.41527 43.00000 

Here, the ratio is 0.66, so there is no sign of overdispersion.

Logistic regression

A logistic regression works in exactly the same way. For example, with a binary outcome passed and a factor Group:

fit.logit <- glm(passed ~ -1 + Group, family = binomial, data = myData)
iht(fit.logit, constraints = ' GroupLow < GroupMedium < GroupHigh ')

The restrictions are then about the log-odds of passing in each group.