Bari Tala
Bari Tala

Reputation: 57

How to apply Cochran-Armitage trend test in R

I'm working on a publication examining rising authorship of minorities for certain articles. There is a clear increasing trend, but I wanted to apply some statistical rigor. My data frame is simple: Years, and % minority authorship. However, Cochran-Armitage input dataframe doesn't make sense in my context. Am I using the right test?

I have perfected the dataframe and prepared it by producing the number of years on the x-axis, and the % minority authorship on the y-axis. essentially 1 row, and 10 columns (each column representing one year). However, cochran-armitage cannot accept 1 row dataframes

my dataframe exists as so

year 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 race 11.1 12.1 14.2 15.2 19.2 20.5 21.8 27.9 30.1 31.1

Upvotes: 0

Views: 2415

Answers (1)

bob1
bob1

Reputation: 408

The Cochrane Armitage is likely to be the wrong test, it is for association between a variable with 2 categories and an ordinal variable with K categories. You have two variables each with one category.

I think a simple linear regression would work. In fact, when you run one on the data you provided (you are missing the % for 2018, so I removed that row), this is what you get:

> summary(y_p)

Call:
lm(formula = year ~ percent, data = y_p)

Residuals:
 Min       1Q   Median       3Q      Max 
-0.77079 -0.38560 -0.03582  0.35535  0.90139 

Coefficients:
         Estimate Std. Error t value Pr(>|t|)    
(Intercept) 2.004e+03  5.428e-01 3692.52  < 2e-16 ***
percent     4.045e-01  2.526e-02   16.01 2.32e-07 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.5586 on 8 degrees of freedom
Multiple R-squared:  0.9697,    Adjusted R-squared:  0.966 
F-statistic: 256.4 on 1 and 8 DF,  p-value: 2.319e-07

This looks fairly significant to me, but you would need to check the residuals etc to be sure.

Upvotes: 1

Related Questions