MyNixOS website logo
Description

Estimate Heterogeneous Effects in Factorial Experiments Using Grouping and Sparsity.

Estimates heterogeneous effects in factorial (and conjoint) models. The methodology employs a Bayesian finite mixture of regularized logistic regressions, where moderators can affect each observation's probability of group membership and a sparsity-inducing prior fuses together levels of each factor while respecting ANOVA-style sum-to-zero constraints. Goplerud, Imai, and Pashley (2024) <doi:10.48550/ARXIV.2201.01357> provide further details.

FactorHet R-CMD-check codecov

This package estimates heterogeneous effects in factorial and conjoint experiments. Its details are fully described in Goplerud, Imai, and Pashley (2025): "Estimating Heterogeneous Causal Effects of High-Dimensional Treatments: Application to Conjoint Analysis".

The core method is a Bayesian regularized finite mixture-of-experts where moderators can affect an individual's probability of cluster membership and a sparsity-inducing prior fuses together levels of each factor in each cluster while respecting ANOVA-style sum-to-zero constraints described in Egami and Imai (2019). The posterior mode is found using an AECM algorithm with a number of techniques to accelerate convergence. Approximate quantification of uncertainty is provided by examining the Hessian of the log-posterior. Additional details are explained in the paper and (briefly) in the package documentation.

It can be installed from CRAN or the most-to-update version can be installed using devtools. Note, macOS users may need to ensure that XQuartz is installed; please see information from CRAN (here) for more details.

# CRAN
install.packages("FactorHet")
# Up-to-Date GitHub Version
library(devtools)
devtools::install_github('mgoplerud/FactorHet')

There are two key functions for estimating the model: In most cases, one will prefer to use the FactorHet_mbo function to jointly (i) estimate the amount of regularization by minimizing a criterion such as the BIC using model-based optimization and (ii) estimate the final model. However, if one has a specific value of lambda of interest, one can fit the model for a fixed amount of regularization using FactorHet. A simple example is shown below:

fit_FH <- FactorHet_mbo(
  formula = y ~ factor_1 + factor_2 + factor_1 : factor_2, 
  design = design,
  moderator = ~ moderator_1 + moderator_2)

In the case of repeated observations, the individual is specified via group and the task identifier is specified via task. In the case of a conjoint experiment, the profile identifier (i.e. "left" or "right") is specified via choice_order. An example is shown below:

fit_FH <- FactorHet_mbo(
  formula = y ~ factor_1 + factor_2 + factor_1 : factor_2, 
  design = design, moderator = ~ moderator_1 + moderator_2, 
  group = ~ id, task = ~ task, choice_order = ~ choice_left)

Finally, after fitting the model, there are functions to calculate the Average Marginal Effect (AME) and related concepts (e.g. ACE, AMIE). A simple example is shown below:

AME(fit_FH)

The effects of moderators on cluster membership can be analyzed using two key functions; first, posterior_by_moderators shows the estimated distribution of (posterior) cluster membership probabilities by covariates. Second, margeff_moderators shows the change in the prior cluster membership as one moderator changes, averaging across all other moderators. This is similar to a marginal effect in a multinomial logistic regression. Example code is shown below:

posterior_by_moderators(fit_FH)
margeff_moderators(fit_FH)

Some function names (e.g., AME and margeff_moderators) have been changed for clarity from an older verison of those package. Those functions should still run but will throw a warning and should be updated in existing code.

Metadata

Version

1.0.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows