Learn R Programming

Ordered Correlation Forest

R package to implement ordered correlation forest, a machine learning estimator specifically optimized for predictive modeling of ordered non-numeric outcomes.

ocf provides forest-based estimation of the conditional choice probabilities and the covariates’ marginal effects. Under an "honesty" condition, the estimates are consistent and asymptotically normal and standard errors can be obtained by leveraging the weight-based representation of the random forest predictions. Please reference the use as Di Francesco (2025).

To get started, please check the online short tutorial.

Installation

The package can be downloaded from CRAN:

install.packages("ocf")

Alternatively, the current development version of the package can be installed using the devtools package:

devtools::install_github("riccardo-df/ocf") # run install.packages("devtools") if needed.

References

  • Athey, S., Tibshirani, J., & Wager, S. (2019).

Generalized Random Forests. Annals of Statistics, 47(2). [paper]

  • Di Francesco, R. (2025).

Ordered Correlation Forest. Econometric Reviews. [paper]

  • Lechner, M., & Mareckova, J. (2022).

Modified Causal Forest. arXiv preprint arXiv:2209.03744. [paper]

  • Lechner, M., & Okasa, G. (2024).

Random Forest Estimation of the Ordered Choice Model. Empirical Economics. [paper]

  • Peracchi, F. (2014).

Econometric methods for ordered responses: Some recent developments. In Econometric methods and their applications in finance, macro and related fields(pp. 133–165). World Scientific. [paper]

  • Wager, S., & Athey, S. (2018).

Estimation and Inference of Heterogeneous Treatment Effects using Random Forests. Journal of the American Statistical Association, 113(523). [paper]

  • Wright, M. N. & Ziegler, A. (2017).

ranger: A fast implementation of random forests for high dimensional data in C++ and R. Journal of Statistical Software, 77(1). [paper]

Copy Link

Version

Install

install.packages('ocf')

Monthly Downloads

177

Version

1.0.3

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Riccardo Di Francesco

Last Published

February 3rd, 2025

Functions in ocf (1.0.3)

ocf

Ordered Correlation Forest
print.ocf

Print Method for ocf Objects
predict.ocf

Prediction Method for ocf Objects
predict.ocf.forest

Prediction Method for ocf.forest Objects
print.ocf.marginal

Print Method for ocf.marginal Objects
summary.ocf

Summary Method for ocf Objects
predict.oml

Prediction Method for oml Objects
tree_info

Tree Information in Readable Format
ordered_ml

Ordered Machine Learning
summary.ocf.marginal

Summary Method for ocf.marginal Objects
predict_forest_weights

Forest Out-of-Sample Weights
rename_latex

Renaming Variables for LATEX Usage
plot.ocf.marginal

Plot Method for ocf.marginal Objects
predict.mml

Prediction Method for mml Objects
forest_weights_predicted_cpp

Forest Out-of-Sample Honest Weights
check_maxdepth

Check Argument max.depth
class_honest_split

Honest Sample Split
check_honesty_inference

Check Arguments honesty, honesty.fraction and inference
check_samplefraction

Check Argument sample.fraction
check_mtry

Check Argument mtry
check_x_y

Check Arguments x and y
check_ntrees

Check Argument n.trees
check_minnodesize

Check Argument min.node.size
check_alpha

Check Argument alpha
forest_weights_fitted

Forest In-Sample Honest Weights
generate_ordered_data

Generate Ordered Data
marginal_effects

Marginal Effects for Ordered Correlation Forest
multinomial_ml

Multinomial Machine Learning
mean_squared_error

Accuracy Measures for Ordered Probability Predictions
forest_weights_fitted_cpp

Forest In-Sample Honest Weights
honest_fitted_cpp

Honest In-Sample Predictions
honest_fitted

Honest In-Sample Predictions
honest_predictions_cpp

Honest Out-of-Sample Predictions
honest_predictions

Honest Out-of-Sample Predictions