if (FALSE) {
# Immigration Choice Conjoint Experiment Data from Hainmueller et. al. (2014).
data("immigrationconjoint")
data("immigrationdesign")
# Run AMCE estimator using all attributes in the design
results <- amce(Chosen_Immigrant ~ Gender + Education + `Language Skills` +
`Country of Origin` + Job + `Job Experience` + `Job Plans` +
`Reason for Application` + `Prior Entry`, data=immigrationconjoint,
cluster=TRUE, respondent.id="CaseID", design=immigrationdesign)
# Print summary
summary(results)
# Run AMCE estimator using all attributes in the design with interactions
interaction_results <- amce(Chosen_Immigrant ~ Gender + Education + `Language Skills` +
`Country of Origin` + Job + `Job Experience` + `Job Plans` +
`Reason for Application` + `Prior Entry` + Education:`Language Skills` +
Job: `Job Experience` + `Job Plans`:`Reason for Application`,
data=immigrationconjoint, cluster=TRUE, respondent.id="CaseID",
design=immigrationdesign)
# Print summary
summary(interaction_results)
# create weights in data
weights <- runif(nrow(immigrationconjoint))
immigrationconjoint$weights <- weights
# Run AMCE estimator using weights
results <- amce(Chosen_Immigrant ~ Gender + Education + `Language Skills` +
`Country of Origin` + Job + `Job Experience` + `Job Plans` +
`Reason for Application` + `Prior Entry`, data=immigrationconjoint,
cluster=TRUE, respondent.id="CaseID", design=immigrationdesign,
weights = "weights")
# Print summary
summary(results)
# Include a respondent-varying interaction
results <- amce(Chosen_Immigrant ~ Gender + Education + Job +
ethnocentrism:Job + Education:Job,
data=immigrationconjoint, na.ignore = TRUE,
cluster=FALSE,design=immigrationdesign,
respondent.varying = "ethnocentrism")
# Print summary
summary(results)
# Change the baseline for "Education"
baselines <- list()
baselines$Education <- "graduate degree"
results <- amce(Chosen_Immigrant ~ Gender + Education + Job +
Education:Job, data=immigrationconjoint,
cluster=FALSE,design=immigrationdesign,
baselines=baselines)
# Print summary
summary(results)
}
Run the code above in your browser using DataLab