c("coin")
wants <- wants %in% rownames(installed.packages())
has <-if(any(!has)) install.packages(wants[!has])
10
N <- 5
P <- data.frame(id=factor(rep(1:N, each=P)),
cDf <-year=factor(rep(1981:1985, times=N)),
pref=c(1,1,0,1,0, 0,1,0,0,1, 1,0,1,0,0, 1,1,1,1,1, 0,1,0,0,0,
1,0,1,1,1, 0,0,0,0,0, 1,1,1,1,0, 0,1,0,1,1, 1,0,1,0,0))
library(coin)
symmetry_test(pref ~ year | id, teststat="quad", data=cDf)
Asymptotic General Independence Test
data: pref by
year (1981, 1982, 1983, 1984, 1985)
stratified by id
chi-squared = 1.3333, df = 4, p-value = 0.8557
try(detach(package:coin))
try(detach(package:survival))
try(detach(package:splines))
R markdown - markdown - R code - all posts