library("DescTools")
tmp <- textConnection("
′一覓
1 覓 38
2 覓 43
3 覓 33
1 6
2 7
3 15")
df <- read.table(tmp, header=TRUE)
close.connection(tmp)
head(df)
t1 <- xtabs( ~ + ′一覓, data=df)
summary(t1)
CochranArmitageTest(t1, "increasing")
#CochranArmitageTest(t1)
#CochranArmitageTest(t1, "decreasing")
蟆郁骸
> summary(t1)
Call: xtabs(formula = ~ + ′一覓, data = df)
Number of cases in table: 142
Number of factors: 2
Test for independence of all factors:
Chisq = 6.093, df = 2, p-value = 0.04752
> CochranArmitageTest(t1, "increasing")
Cochran-Armitage test for trend
data: t1
Z = -2.153, dim = 3, p-value = 0.01566
alternative hypothesis: increasing