This R code contains two functions, one do two-way cross-validation and one to produce ridit scores.