Description Usage Arguments Details Value Examples
This computes marginal effects for a small change in a chosen continuous explanatory variable as difference of semiparametric conditional probabilities.
1 2 3 4 5 6 7 8 | MarginalEffects(
fit,
variable,
delta,
p.cutoffs = NULL,
h = NULL,
trimming = FALSE
)
|
fit |
a fitted 'semiBRM' object. |
variable |
an integer indicating the position of the explanatory variable of interest or
character of its name. For example, to compute marginal effects of the first
explanatory variable, |
delta |
the size of perturbation over which difference of semiparametric conditional
probabilities are computed. Popular choice of |
p.cutoffs |
a numeric vector of probabilities (e.g. |
h |
a numeric of bandwidth size in the Nadaraya-Watson estimator. If not given, it will use
the Silverman's rule of thumb bandwidth, |
trimming |
a logical indicating whether to trim semiparametric conditional probabilities near
boundaries into zeros. If |
This function is designed to analyze marginal effects of a chosen explanatory variable
over its change by delta
, where marginal effects are defined as difference between the two
semiparametric conditional probabilities evaluated with and without perturbation delta
to
the variable of interest. Notice that this is designed for a continuous variable in x
.
If p.cutoffs = NULL
, then it will return average marginal effects over data points. If
a numeric vector of probabilities is given for p.cutoffs
, it will calculate quantile
marginal effects accordingly to the grouping by quantile values at p.cutoffs
. For example,
if p.cutoffs = c(1/4, 2/4, 3/4)
, it will return quartile marginal effects over the four
quartile groups.
a vector or matrix of marginal effects and standard errors.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # data generating process
N <- 1000L
X1 <- rnorm(N)
X2 <- (X1 + 2*rnorm(N))/sqrt(5) + 1
X3 <- rnorm(N)^2/sqrt(2)
X <- cbind(X1, X2, X3)
beta <- c(2, 2, -1, -1)
V <- as.vector(cbind(X, 1)%*%beta)
Y <- ifelse(V >= rnorm(N), 1L, 0L)
# parameter estimation
qmle <- semiBRM(x = X, y = Y, control = list(iterlim=50))
# average marginal effects of X1
av_me <- MarginalEffects(qmle, variable = "X1", delta = sd(X1))
# quantile marginal effects of X1
q_me <- MarginalEffects(qmle, variable = "X1", delta = sd(X1), p.cutoffs = c(1/3, 2/3))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.