View source: R/PlotForestImp.R
PlotForestImp | R Documentation |
Importance plot of an ensemble forest
PlotForestImp(myfit)
myfit |
A fitted ensemble forest. |
A ggplot2 object and a table of relative importance of each covariate.
data(SimDataLst)
K <- length(SimDataLst)
covars <- grep("^X", names(SimDataLst[[1]]), value=TRUE)
fit_lst <- list()
for (k in 1:K) {
tmpdf <- SimDataLst[[k]]
# use your estimator of interest
fit_lst[[k]] <- grf::causal_forest(X=as.matrix(tmpdf[, covars, with=FALSE]),
Y=tmpdf$Y, W=tmpdf$Z)
}
coord_id <- 1
coord_df <- SimDataLst[[coord_id]]
aug_df <- GenAugData(coord_id, coord_df, fit_lst, covars)
## Treat each site as a distinct factor
myfit <- EnsemForest(coord_id, aug_df, "site", covars, importance="impurity")$myfit
PlotForestImp(myfit)
## Mean encoding as surrogate for site index
myfit <- EnsemForest(coord_id, aug_df, "site", covars, is_encode=TRUE)$myfit
PlotForestImp(myfit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.