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,
which_covariates = c(),
eval = "atmean",
bandwitdh = 0.1,
inference = FALSE
)
Arguments
object |
An |
data |
Data set of class |
which_covariates |
Character vector storing the names of the covariates for which marginal effect estimation is desired. If empty (the default), marginal effects are estimated for all covariates. |
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.
The routine assumes that covariates with more than ten unique values are continuous. Otherwise, covariates are assumed to
be discrete.
Value
Object of class ocf.marginal
.
Author(s)
Riccardo Di Francesco
See Also
Examples
## Load data from orf package.
set.seed(1986)
library(orf)
data(odata)
odata <- odata[1:100, ] # Subset to reduce elapsed time.
y <- as.numeric(odata[, 1])
X <- as.matrix(odata[, -1])
## Fit ocf. Use large number of trees.
forests <- ocf(y, X, n.trees = 4000)
## Marginal effects at the mean.
me <- marginal_effects(forests, eval = "atmean")
print(me)
summary(me)
## LATEX.
print(me, latex = TRUE)
## Compute standard errors. This requires honest forests.
honest_forests <- ocf(y, X, n.trees = 4000, honesty = TRUE)
honest_me <- marginal_effects(honest_forests, eval = "atmean", inference = TRUE)
honest_me$standard.errors
honest_me$p.values # These are not corrected for multiple hypotheses testing!
print(honest_me, latex = TRUE)