Created
September 28, 2013 00:56
-
-
Save kylebgorman/6737200 to your computer and use it in GitHub Desktop.
Define the search space for the matching procedure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# compute means | |
mu <- mean(covariate) | |
mu.group <- tapply(covariate, condition, mean) | |
# locate observations driving the correlation | |
correlate <- ((covariate < mu.group) == (mu.group < mu)) | |
# compute order, filtering out non-correlates | |
ord <- order(covariate) | |
ord <- ord[correlate[ord]] | |
# split on condition and reverse for those above | |
search.space <- split(ord, condition[ord]) | |
for (name in names(search.space)) { | |
if (covariate[search.space[[name]][1]] > mu) | |
search.space[[name]] <- rev(search.space[[name]]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment