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)
# Plot results
plot(results, xlab="Change in Pr(Immigrant Preferred for Admission to U.S.)",
ylim=c(-.3,.3), breaks=c(-.2, 0, .2), labels=c("-.2","0",".2"), text.size=13)
# Plot results with user-specified order of attributes
plot(results, xlab="Change in Pr(Immigrant Preferred for Admission to U.S.)",
ylim=c(-.3,.3), breaks=c(-.2, 0, .2), labels=c("-.2","0",".2"), text.size=13,
group.order=c("Gender","Education","Job",
"Language Skills","Job Experience",
"Job Plans","Reason for Application",
"Prior Entry","Country of Origin"))
# Run AMCE estimator with an interaction with a respondent-varying characteristic
interaction_results <- amce(Chosen_Immigrant ~ Gender + Education
+ Job + ethnocentrism:Job,
data = immigrationconjoint,na.ignore=TRUE,
design = immigrationdesign, cluster = FALSE,
respondent.varying = "ethnocentrism")
# Plot results with additional plots for quantiles of the respondent-varying characteristic
plot(interaction_results)
# Plot results with user-specified order of attributes
plot(interaction_results, group.order=c("Gender","Education","Job"))
# Do not show output for variables that do not vary with facetted levels
plot(interaction_results,plot.display="unconditional")
# RUN AMCE estimator with an interaction between two factor variables
interaction_results <- amce(Chosen_Immigrant ~ Gender + Education + Job
+ Education:Job, data = immigrationconjoint,
cluster = FALSE, design = immigrationdesign)
# Plot results with different plots for all levels of ACIE
plot(interaction_results,facet.names = "Education")
# Plot results with different plots for only two levels of one interacted variable
facet.levels1 <- list()
facet.levels1[["Education"]] <- c("college degree","graduate degree")
plot(interaction_results,facet.names = "Education",facet.levels = facet.levels1)
# Display only interaction panes
plot(interaction_results,facet.names = "Education",plot.display="interaction")
#Display only non-interaction panes
plot(interaction_results,facet.names = "Education",plot.display="unconditional")
#Change displayed attribute and level names
results <- amce(Chosen_Immigrant ~ Gender + Education + Job, data = immigrationconjoint,
cluster = FALSE, design = immigrationdesign)
levels.test<-list()
levels.test[["Gender"]]<-c("level1","level2")
levels.test[["Education"]]<-c("level1","b","c","d","e","f","g")
levels.test[["Job"]]<-c("a","b","c","d","e","f","g","h","i","j","k")
plot(results, level.names = levels.test, main="test", xlab="test",
ci=0.95, breaks=c(-0.2,-0.1,0,0.1,0.2), attribute.names = c("attribute1","attribute2","attribute3"))
}
Run the code above in your browser using DataLab