marginal_effects {ocf} | R Documentation |
Marginal Effects for Ordered Correlation Forest
Description
Nonparametric estimation of marginal effects using an ocf
object.
Usage
marginal_effects(
object,
data = NULL,
these_covariates = NULL,
eval = "atmean",
bandwitdh = 0.1,
inference = FALSE
)
Arguments
object |
An |
data |
Data set of class |
these_covariates |
Named list with covariates' names as keys and strings denoting covariates' types as entries. Strings must be either |
eval |
Evaluation point for marginal effects. Either |
bandwitdh |
How many standard deviations |
inference |
Whether to extract weights and compute standard errors. The weights extraction considerably slows down the program. |
Details
marginal_effects
can estimate mean marginal effects, marginal effects at the mean, or marginal effects at the
median, according to the eval
argument.
If these_covariates
is NULL
(the default), the routine assumes that covariates with with at most ten unique values are categorical and treats the remaining covariates as continuous.
Value
Object of class ocf.marginal
.
Author(s)
Riccardo Di Francesco
References
Di Francesco, R. (2025). Ordered Correlation Forest. Econometric Reviews, 1–17. doi:10.1080/07474938.2024.2429596.
See Also
Examples
## Generate synthetic data.
set.seed(1986)
data <- generate_ordered_data(100)
sample <- data$sample
Y <- sample$Y
X <- sample[, -1]
## Fit ocf.
forests <- ocf(Y, X)
## Marginal effects at the mean.
me <- marginal_effects(forests, eval = "atmean")
print(me)
print(me, latex = TRUE)
plot(me)
## Compute standard errors. This requires honest forests.
honest_forests <- ocf(Y, X, honesty = TRUE)
honest_me <- marginal_effects(honest_forests, eval = "atmean", inference = TRUE)
print(honest_me, latex = TRUE)
plot(honest_me)
## Subset covariates and select covariates' types.
my_covariates <- list("x1" = "continuous", "x2" = "discrete", "x4" = "discrete")
honest_me <- marginal_effects(honest_forests, eval = "atmean", inference = TRUE,
these_covariates = my_covariates)
print(honest_me)
plot(honest_me)