FactorHet
Science Score: 23.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
✓Academic publication links
Links to: arxiv.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (16.0%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: mgoplerud
- Language: R
- Default Branch: main
- Size: 485 KB
Statistics
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
FactorHet

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.
Owner
- Login: mgoplerud
- Kind: user
- Repositories: 2
- Profile: https://github.com/mgoplerud
GitHub Events
Total
- Watch event: 1
- Push event: 12
- Pull request event: 2
- Create event: 1
Last Year
- Watch event: 1
- Push event: 12
- Pull request event: 2
- Create event: 1
Packages
- Total packages: 1
-
Total downloads:
- cran 482 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 1
- Total maintainers: 1
cran.r-project.org: FactorHet
Estimate Heterogeneous Effects in Factorial Experiments Using Grouping and Sparsity
- Homepage: https://github.com/mgoplerud/FactorHet
- Documentation: http://cran.r-project.org/web/packages/FactorHet/FactorHet.pdf
- License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
-
Latest release: 1.0.0
published over 1 year ago
Rankings
Maintainers (1)
Dependencies
- actions/cache v2 composite
- actions/checkout v2 composite
- actions/upload-artifact main composite
- r-lib/actions/setup-pandoc master composite
- r-lib/actions/setup-r master composite
- actions/checkout v2 composite
- r-lib/actions/setup-r v1 composite
- r-lib/actions/setup-r-dependencies v1 composite
- R >= 3.4.0 depends
- Matrix * imports
- ParamHelpers * imports
- Rcpp >= 1.0.1 imports
- RcppEigen >= 0.3.3.4.0 imports
- dplyr * imports
- ggplot2 * imports
- methods * imports
- mlr * imports
- mlrMBO * imports
- reshape2 * imports
- rlang * imports
- smoof * imports
- tictoc * imports
- FNN * suggests
- RSpectra * suggests
- mclust * suggests
- testthat * suggests
- tgp * suggests