model_pAMCE: Estimating the population AMCE using a model-based approach

Description Usage Arguments Value References Examples

View source: R/model_pAMCE.R

Description

model_pAMCE implements the model-based approach to estimate the pAMCE. See de la Cuesta, Egami, and Imai (2019+) for details. More examples are available at the GitHub page of factorEx.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
model_pAMCE(
  formula,
  formula_three = NULL,
  data,
  reg = TRUE,
  ord_fac,
  pair = FALSE,
  pair_id = NULL,
  cross_int = FALSE,
  cluster_id = NULL,
  target_dist,
  target_type,
  difference = FALSE,
  cv_type = "cv.1Std",
  nfolds = 5,
  boot = 100,
  seed = 1234,
  numCores = NULL
)

Arguments

formula

Formula

formula_three

Formula for three-way interactions (optional)

data

Data

reg

TRUE (regularization) or FALSE (no regularization). Default is TRUE

ord_fac

Whether we assume each factor is ordered. When not specified, we assume all of them are ordered

pair

Whether we use a paired-choice conjoint design

pair_id

Unique identifiers for pairs in the paired-choice conjoint design (optional)

cross_int

Include interactions across profiles. Default is FALSE.

cluster_id

Unique identifiers for computing cluster standard errors (optional).

target_dist

Target profile distributions to be used. This argument should be 'list'

target_type

Types of target profile distributions. 'marginal' or 'target_data'. See Examples for details.

difference

Whether we compute the differences between the multiple pAMCEs. Default is FALSE.

cv_type

(optimal only when 'reg = TRUE“) 'cv.1Std“ (stronger regularization; default) or 'cv.min' (weaker regularization).

nfolds

Number of cross validation folds. Default is 5.

boot

The number of bootstrap samples.

seed

Seed for bootstrap.

numCores

Number of cores to be used for parallel computing. If not specified, detect the number of available cores internally.

Value

model_pAMCE returns an object of pAMCE class.

References

de la Cuesta, Egami, and Imai. (2019+). Improving the External Validity of Conjoint Analysis: The Essential Role of Profile Distribution. (Working Paper). Available at https://scholar.princeton.edu/sites/default/files/negami/files/conjoint_profile.pdf.

Egami and Imai. (2019). Causal Interaction in Factorial Experiments: Application to Conjoint Analysis. Journal of the American Statistical Association, Vol.114, No.526 (June), pp. 529–540. Available at https://scholar.princeton.edu/sites/default/files/negami/files/causalint.pdf.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  # Small example
  target_dist_marginal <- OnoBurden$target_dist_marginal
  OnoBurden_data <- OnoBurden$OnoBurden_data
  OnoBurden_data_small <- OnoBurden_data[1:300, ]
  target_dist_marginal_small <- target_dist_marginal[c("gender", "race")]

  # model-based estimation without regularization
  out_model_s <-
      model_pAMCE(formula = Y ~ gender + race,
           data = OnoBurden_data_small, reg = FALSE,
           pair_id = OnoBurden_data_small$pair_id,
           cluster_id = OnoBurden_data_small$id,
           target_dist  = target_dist_marginal_small,
           target_type = "marginal")


  # Example
  data("OnoBurden")
  OnoBurden_data <- OnoBurden$OnoBurden_data
  OnoBurden_data_cong <- OnoBurden_data[OnoBurden_data$office == "Congress", ]
  target_dist_marginal <- OnoBurden$target_dist_marginal

  # model-based estimation with regularization
  out_model <-
    model_pAMCE(formula = Y ~ gender + age + family + race + experience + party + pos_security,
                 data = OnoBurden_data_cong,
                 pair_id = OnoBurden_data_cong$pair_id,
                 cluster_id = OnoBurden_data_cong$id,
                 target_dist  = target_dist_marginal, target_type = "marginal")
 summary(out_model, factor_name = c("gender"))

 # decompose the difference in the pAMCEs
 decompose_pAMCE(out_model, effect_name = c("gender", "Female"))

factorEx documentation built on July 2, 2020, 12:25 a.m.