mid.importance: Calculate MID Importance

View source: R/mid_importance.R

mid.importanceR Documentation

Calculate MID Importance

Description

mid.importance() calculates the MID importance of a fitted MID model. This is a measure of feature importance that quantifies the average contribution of each component function across a dataset.

Usage

mid.importance(object, data = NULL, weights = NULL, sort = TRUE, measure = 1L)

Arguments

object

a "mid" object.

data

a data frame containing the observations to calculate the importance. If NULL, the fitted.matrix from the "mid" object is used.

weights

an optional numeric vector of sample weights.

sort

logical. If TRUE, the output data frame is sorted by importance in descending order.

measure

an integer specifying the measure of importance. Possible alternatives are 1 for the mean absolute effect, 2 for the root mean square effect, and 3 for the median absolute effect.

Details

The MID importance of a component function (e.g., a main effect or an interaction) is defined as the mean absolute effect on the predictions within the given data. Terms with higher importance have a larger average impact on the model's overall predictions.

Value

mid.importance() returns an object of class "mid.importance". This is a list containing the following components:

importance

a data frame with the calculated importance values, sorted by default.

predictions

the matrix of the fitted or predicted MID values.

measure

a character string describing the type of the importance measure used.

See Also

interpret, plot.mid.importance, ggmid.mid.importance

Examples

data(airquality, package = "datasets")
mid <- interpret(Ozone ~ .^2, data = airquality, lambda = 1)

# Calculate MID importance using median absolute contribution
imp <- mid.importance(mid)
print(imp)

# Calculate MID importance using root mean square contribution
imp <- mid.importance(mid, measure = 2)
print(imp)

midr documentation built on Sept. 11, 2025, 1:07 a.m.