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 FactorHet or FactorHet_mbo.

newdata

An optional argument that provides the data over which to average the distribution of the other moderators. The default is NULL which uses the estimation data.

vcov

A logical value indicating whether the standard errors should be computed. The default is TRUE.

se.method

An optional argument as to the type of standard errors used. The default is NULL uses estimated standard errors. vcov.FactorHet provides more information.

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 c(0.25, 0.75) compares the effect of changing the moderator from its 25th percentile to its 75th percentile.

abs_diff

A logical value as to whether the difference or absolute difference in the change in \pi_k(X_i) should be shown. The default is FALSE which returns the standard "marginal effect" of changing the moderators with a standard error computed via the delta method. The value TRUE draws 10,000 samples from the asymptotic distribution of the moderators and computes the average the absolute values of the marginal effects for each observation in newdata using those samples. This is considerably slower than the default setting. The appendix of Goplerud et al. (2025) illustrates one use of this argument.

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)

[Package FactorHet version 1.0.0 Index]