f <- function(x){sum(x[lower.tri(x)])}
# First a toy example:
a <- matrix(0,5,5)
diag(a) <- NA
a[cbind(c(2:5,1),1:5)] <- 3
# Thus 'a' has 12 social climbers and 3 fallers. Chance?
aylmer.test(a , alternative=f)
# No!
# Now the real dataset:
data(glass)
aylmer.test(glass , alternative=f, simulate.p.value=TRUE , B=100)
# p-value of about 0.975 means that most boards have f(random.board) >
# f(observed.board). In this case, f() is the number of climbers. The
# test shows that the number of climbers is less than expected: those
# who do climb, climb further than the fallers fall.
# See how one needs to be careful about one-sided and two-sided tests.
Run the code above in your browser using DataCamp Workspace