Skip to contents

Computes marginal means (MMs) or average marginal component effects (AMCEs) with correction for intra-respondent reliability (IRR), using repeated tasks when available. Returns estimates ready for plotting.

Usage

projoint(
  .data,
  .qoi = NULL,
  .by_var = NULL,
  .structure = "choice_level",
  .estimand = "mm",
  .se_method = "analytical",
  .irr = NULL,
  .remove_ties = TRUE,
  .ignore_position = NULL,
  .n_sims = NULL,
  .n_boot = NULL,
  .weights_1 = NULL,
  .clusters_1 = NULL,
  .se_type_1 = NULL,
  .weights_2 = NULL,
  .clusters_2 = NULL,
  .se_type_2 = NULL,
  .auto_cluster = TRUE,
  .seed = NULL
)

Arguments

.data

A projoint_data created by reshape_projoint or make_projoint_data.

.qoi

Optional projoint_qoi specifying custom quantities of interest. If supplied, its structure and estimand override .structure and .estimand.

.by_var

Optional column name (character) for subgroup analysis; must be logical (TRUE/FALSE) or numeric/integer coded as 0/1. Only supported for .structure = "profile_level" (ignored for choice-level).

.structure

Either "profile_level" or "choice_level" (default "choice_level"). If .qoi is supplied, this is overridden by .qoi$structure.

.estimand

Either "mm" (marginal mean) or "amce" (average marginal component effect); default "mm". If .qoi is supplied, this is overridden by .qoi$estimand.

.se_method

Standard-error method: "analytical" (default), "simulation", or "bootstrap".

.irr

Numeric or NULL (default). If NULL, IRR is estimated from repeated tasks; otherwise IRR is fixed to the supplied value.

.remove_ties

Logical; remove ties in choice data before estimation? Default TRUE.

.ignore_position

Logical; for choice-level only. Ignore profile position (left/right)? Default TRUE.

.n_sims

Integer; required when .se_method = "simulation".

.n_boot

Integer; required when .se_method = "bootstrap".

.weights_1, .clusters_1, .se_type_1

Arguments passed to lm_robust for IRR estimation. If .se_type_1 is NULL, estimatr defaults are used (HC2 when unclustered; CR2 when clustered).

.weights_2, .clusters_2, .se_type_2

Arguments passed to lm_robust for MM/AMCE estimation. If .se_type_2 is NULL, estimatr defaults are used (HC2 when unclustered; CR2 when clustered).

.auto_cluster

Logical. If TRUE (default), automatically cluster on an id column when present and no .clusters_* are supplied. Auto-clustering only occurs when the corresponding .se_type_* is NULL.

.seed

Optional integer. If supplied, sets a temporary RNG seed for reproducible simulation/bootstrap inside this call and restores the previous RNG state on exit.

Value

A projoint_results object with estimates and metadata, ready for plotting or further analysis.

Details

Most users provide a projoint_data object. Advanced users may target custom quantities with projoint_qoi.

Valid se_type_* values depend on whether clustering is used:

  • Without clusters: "classical", "HC0", "HC1", "HC2", "HC3"

  • With clusters: "CR0", "CR1", "CR2", "stata", "none"

If NULL, estimatr defaults are used (HC2 when unclustered; CR2 when clustered).