View source: R/mid_breakdown.R
mid.breakdown | R Documentation |
mid.breakdown()
calculates the contribution of each component function of a fitted MID model to a single prediction.
It breaks down the total prediction into the effects of the intercept, main effects, and interactions.
mid.breakdown(
object,
data = NULL,
row = NULL,
sort = TRUE,
format = c("%s", "%s, %s")
)
object |
a "mid" object. |
data |
a data frame containing one or more observations for which to calculate the MID breakdown. If not provided, data is automatically extracted based on the function call. |
row |
an optional numeric value or character string specifying the row of |
sort |
logical. If |
format |
a character vector of length two to be used as a format string for |
mid.breakdown()
is a method for local interpretability.
For a given observation, it provides a clear answer to the question, "How much did each component of the MID model contribute to the final prediction?"
The function calculates the value of each term in the MID model's additive structure for the specified observation.
The total prediction is the sum of these individual contributions.
The prediction, denoted \mathcal{F}(\mathbf{x})
, is decomposed as:
\mathcal{F}(\mathbf{x}) = f_\phi + \sum_{j} f_{j}(x_j) + \sum_{j<k} f_{jk}(x_j, x_k)
The output data frame itemizes the numerical value of each main effect
(f_{j}(x_j)
) and interaction effect (f_{jk}(x_j, x_k)
),
along with the intercept (f_\phi
). This makes the prediction transparent
and easy to understand.
mid.breakdown()
returns an object of class "mid.breakdown". This is a list with the following components:
breakdown |
a data frame containing the breakdown of the prediction. |
data |
the data frame containing the predictor variable values used for the prediction. |
intercept |
the intercept of the MID model. |
prediction |
the predicted value from the MID model. |
interpret
, plot.mid.breakdown
, ggmid.mid.breakdown
data(airquality, package = "datasets")
mid <- interpret(Ozone ~ .^2, data = airquality, lambda = 1)
# Calculate the breakdown for the first observation in the data
mbd <- mid.breakdown(mid, data = airquality, row = 1)
print(mbd)
# Calculate the breakdown for the third observation in the data
mbd <- mid.breakdown(mid, data = airquality, row = 3)
print(mbd)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.