Learn R Programming

grmtree (version 0.1.0)

varimp: Calculate Variable Importance for GRM Forest

Description

Computes permutation importance scores for variables in a GRM forest using out-of-bag samples. Importance is measured by the decrease in log-likelihood when a variable's values are permuted.

Usage

varimp(forest, method = "permutation", verbose = FALSE, seed = NULL)

Value

A named numeric vector of importance scores with class varimp. Higher values indicate more important variables.

Arguments

forest

A grmforest object created by grmforest().

method

Importance calculation method (currently only "permutation").

verbose

Logical indicating whether to show progress messages.

seed

Random seed for reproducibility.

See Also

grmtree fits a Graded Response Model Tree, grmforest for GRM Forests, grmforest.control creates a control object for grmforest, plot.varimp creates a bar plot of variable importance scores

Examples

Run this code
# \donttest{
library(grmtree)
library(hlt)
data("asti", package = "hlt")
asti$resp <- data.matrix(asti[, 1:4])

## Fit the GRM Forest
forest <- grmforest(resp ~ gender + group, data = asti,
control = grmforest.control(n_tree = 5))
  importance <- varimp(forest)

## Print and plot the variable importance scores
print(importance)
plot(importance)
# }

Run the code above in your browser using DataLab