Solved – Understanding Cochran-Armitage Trend Test in R

rtest-for-trendtime series

I'm trying to understand how to interpret the Cochran-Armitrage test in R. This is my data

cochrane_rady_table_copy <- structure(c(1400, 21, 1900, 22, 2000, 35, 2200, 37, 2300, 59, 
2700, 146, 3000, 158, 3200, 154), .Dim = c(2L, 8L), .Dimnames = structure(list(
    c("Patients with insurance", "Patients without insurance"
    ), c("1991", "1992", "1993", "1994", "1995", "1996", "1997", 
    "1998")), .Names = c("", "")), class = "table")

I'm trying to tell if the number of people with insurance increased across the years of data I have.

I run the test with this

if (!require('DescTools')) {install.packages('DescTools'); library('DescTools')}
CochranArmitageTest(cochrane_rady_table_copy, alternative = c("increasing"))

The output is

data:  cochrane_rady_table_copy
Z = -11.237, dim = 8, p-value < 2.2e-16
alternative hypothesis: increasing

Is the interpretation here that the proportion of people with insurance is increasing compared to those without insurance? I'm new to this analysis so I'm a little unsure.

Best Answer

P-values are a measure of the strength of evidence against a particular null hypothesis. You have specified that the null hypothesis is that the trend is either zero or decreasing posed against the alternate hypothesis of an increasing trend.

Looking at the data, that doesn't seem quite right:

cochrane_rady_table_copy[1,]/
      (cochrane_rady_table_copy[2,]+cochrane_rady_table_copy[1,])
      1991      1992      1993      1994      1995      1996      1997      1998 
 0.9852217 0.9885536 0.9828010 0.9834600 0.9749894 0.9486999 0.9499683 0.9540847 

The trend of patient proportion having insurance is decidedly downward. So let's see what happens with a two-sided test:

CochranArmitageTest(cochrane_rady_table_copy)

    Cochran-Armitage test for trend

data:  cochrane_rady_table_copy
Z = -11.237, dim = 8, p-value < 2.2e-16
alternative hypothesis: two.sided

The Z-statistic doesn't change, so I originally guessed that the the DescTools function isn't actually taking the alternate into account and that one needed to interpret on the basis of looking at the direction of trend combined with the strength of evidence against the two-sided null. I then checked that guess against the code and the Z-statistic is supposed to be the same, but the calculations of the p-value are different for various alternatives. So maybe the authors of DescTools got the p-value calculations reversed? (Using two-sided tests is more statistically principled IMO when there is no theoretic argument that a trend must be in one direction or the other.)