margeff_moderators {FactorHet} | R Documentation |
Compute association between moderators and group membership
Description
This function computes the impact of changing a moderator on the group membership probabilities.
Usage
margeff_moderators(
object,
newdata = NULL,
vcov = TRUE,
se.method = NULL,
quant_continuous = c(0.25, 0.75),
abs_diff = FALSE
)
Arguments
object |
An object from |
newdata |
An optional argument that provides the data over which to
average the distribution of the other moderators. The default is
|
vcov |
A logical value indicating whether the standard errors should be
computed. The default is |
se.method |
An optional argument as to the type of standard errors used.
The default is |
quant_continuous |
A numeric vector consisting of two values between 0
and 1. For continuous moderators, it sets two quantiles of the moderator's
distribution to show the difference between. The default |
abs_diff |
A logical value as to whether the difference or absolute
difference in the change in |
Details
This function computes the change in \pi_k(X_i)
for the change
in one of the moderators in X_i
. The change is averaged across the
distribution of the other moderators found in newdata
(or, by
default, the estimation data). It thus can be thought of as the "marginal
effect" of changing one moderator on the probability of group memberships,
holding all other moderators constant. It returns a data.frame of the
estimated effects as well as a plot to visualize the changes in
\pi_k(X_i)
. Goplerud et al. (2025) provides more discussion of this
method.
Value
Returns a named list with the underlying data ("data"
) and the
plot ("plot"
).
Examples
# Estimate model with arbitrary choice of lambda
data(immigration)
set.seed(15)
# Estimate model with arbitrary choice of lambda
fit <- FactorHet(Chosen_Immigrant ~ Plans + Ed + Country,
design = immigration, lambda = 1e-2,
moderator = ~ party_ID,
K = 2, group = ~ CaseID,
control = FactorHet_control(init = 'mclust'),
task = ~ contest_no, choice_order = ~ choice_id)
margeff_moderators(fit)