- Notifications
You must be signed in to change notification settings - Fork1
okasag/orf
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Welcome to the repository of theR packageorf for random forest estimation ofthe ordered choice models.
TheR packageorf is an implementation of the Ordered Forest estimatoras developed in Lechner & Okasa (2019). The Ordered Forest flexibly estimatesthe conditional probabilities of models with ordered categorical outcomes(so-called ordered choice models). Additionally to common machine learningalgorithms theorf package provides functions for estimating marginal effectsas well as statistical inference thereof and thus provides similar output as instandard econometric models for ordered choice. The core forest algorithm relieson the fastC++ forest implementation from theranger package (Wright & Ziegler, 2017).
In order to install the latestCRAN released version use:
install.packages("orf",dependencies= c("Imports","Suggests"))
to make sure all the needed packages are installed as well. Note that if you installthe package directly from the source aC++ compiler is required. For WindowsusersRtools collection is required too.
The examples below demonstrate the basic functionality of theorf package.
## Ordered Forestrequire(orf)# load example datadata(odata)# specify response and covariatesY<- as.numeric(odata[,1])X<- as.matrix(odata[,-1])# estimate Ordered Forest with default settingsorf_fit<- orf(X,Y,num.trees=1000,mtry=2,min.node.size=5,replace=FALSE,sample.fraction=0.5,honesty=TRUE,honesty.fraction=0.5,inference=FALSE,importance=FALSE)# print output of the Ordered Forest estimationprint(orf_fit)# show summary of the Ordered Forest estimationsummary(orf_fit,latex=FALSE)# plot the estimated probability distributionsplot(orf_fit)# predict with the estimated Ordered Forestpredict(orf_fit,newdata=NULL,type="probs",inference=FALSE)# estimate marginal effects of the Ordered Forestmargins(orf_fit,newdata=NULL,eval="mean",window=0.1,inference=FALSE)
For a more detailed examples see the package vignette.
- Lechner, M., & Okasa, G. (2019). Random Forest Estimation of the Ordered Choice Model. arXiv preprint arXiv:1907.02436.https://arxiv.org/abs/1907.02436
- Wright, M. N. & Ziegler, A. (2017). ranger: A fast implementation of random forests for high dimensional data in C++ and R. J Stat Softw 77:1-17.https://doi.org/10.18637/jss.v077.i01
About
orf: R package
Resources
Uh oh!
There was an error while loading.Please reload this page.