Finding relationship of dichotomous variable to ordinal variable (in R) As stated above - I'm trying to find a relationship of dichotomous outcome variable (TRUE or FALSE) to an ordinal variable (1,2,3,4,5,6,7,8,9) (in R). The ordinal variable indicates increasing amounts of urbanization. I want to see if there is a positive relationship between urbanization and the outcome variable. Any help would be very much appreciated.
 A: The simplest approach would be to treat the integers $\{ 1, \ldots , 9 \}$ as the categories themselves and do a two sample test to see if the mean for one distribution is larger than the mean for the other (a $t$ test perhaps if you have large samples).
A nonparametric alternative would be to perform a rank sum test to see if the categories in the "true" sample (I'll assume that this is the sample containing larger values) tend to be larger than those in the false sample.  To do this you would combine both samples (keeping track of which sample each observation came from), sort them and then assign the ranks in the sorted sample to each observation.  When you have ties use the average rank instead.
After this sum the ranks of the observations in the true sample and use this as your test statistic.  For large samples this rank sum will have an approximate normal distribution, but if you aren't comfortable using such an approximation you can empirically estimate the null distribution using a permutation idea.  Here is some R code that would do this:
# true sample here
sample1 = c(2, 7, 4, 8, 5, 6, 2, 2, 5, 7)
# false sample here
sample2 = c(7, 1, 5, 3, 9, 8, 1, 1, 1, 8)

# combine into a data frame and calculate the ranks
data = data.frame(value = c(sample1, sample2),
                  rank = rank(c(sample1, sample2)),
                  sample = c(rep('true', length(sample1), rep('false', length(sample2)))

# calculate the test statistic
test_statistic = sum(data[data$sample == 'true', 'rank'])

# empirically estimate the null distribution of the test statistic,
# here we're conditioning on the values in sample1 and sample2
# and randomly permuting their assignment to the different groups
m = 10000
null_sample = NULL

for (i in 1:m) {
    null_sample[i] = sum(data[sample(1:(length(sample1) + length(sample2)),
                                     size=length(sample1), replace=FALSE),
                              'rank'])
}

# estimate the p-value for test_statistic and the null that
# sample1 came from a distribution with larger values than sample2
mean(test_statistic > null_sample)

