Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
visualize_models.R 4.99 KiB
# Compare Model coefficients Scenario A

mxl_wtp_c <- as.data.frame(mxl_wtp_case_a$estimate)
mxl_wtp_c$se <- mxl_wtp_case_a$robse
mxl_wtp_c <- rownames_to_column(mxl_wtp_c, "Coefficent")
alpha = 0.1 # Set confidence level
mxl_wtp_c$ME <- qnorm(1-alpha/2)*mxl_wtp_c$se
mxl_wtp_c$Model <- "without NR"
mxl_wtp_c <- mxl_wtp_c %>% rename("Estimate" = `mxl_wtp_case_a$estimate`)
mxl_wtp_c_NR <- as.data.frame(mxl_wtp_case_a_NR$estimate)
mxl_wtp_c_NR$se <- mxl_wtp_case_a_NR$robse
mxl_wtp_c_NR <- rownames_to_column(mxl_wtp_c_NR, "Coefficent")
alpha = 0.1 # Set confidence level
mxl_wtp_c_NR$ME <- qnorm(1-alpha/2)*mxl_wtp_c_NR$se
mxl_wtp_c_NR$Model <- "with NR"
mxl_wtp_c_NR <- mxl_wtp_c_NR %>% rename("Estimate" = `mxl_wtp_case_a_NR$estimate`)

mxl_wtp_c <- rbind(mxl_wtp_c, mxl_wtp_c_NR)
wtp_nat_c <- mxl_wtp_c %>%
  filter(Coefficent %in% c("mu_nat_T"))
wtp_wd_c <- mxl_wtp_c %>%
  filter(Coefficent %in% c("mu_wd_T"))

wtp_nat_a<-ggplot(data=wtp_nat_c, aes(x=Coefficent, y=Estimate, fill=Model)) +
  geom_bar(stat="identity",  position='dodge', width = 0.9) +
  geom_errorbar(aes(x=Coefficent, ymin=Estimate-ME, ymax=Estimate+ME), width=0.3, position=position_dodge(0.8)) +
  ylab("WTP in Euro per month") +
  xlab("Coefficient") +
  scale_x_discrete(guide = guide_axis(angle = 45))

wtp_wd_a<-ggplot(data=wtp_wd_c, aes(x=Coefficent, y=Estimate, fill=Model)) +
  geom_bar(stat="identity",  position='dodge', width = 0.9) +
  geom_errorbar(aes(x=Coefficent, ymin=Estimate-ME, ymax=Estimate+ME), width=0.3, position=position_dodge(0.8)) +
  ylab("WTP in Euro per month") +
  xlab("Coefficient") +
  scale_x_discrete(guide = guide_axis(angle = 45))

# Compare Model coefficients Scenario B

mxl_wtp_c <- as.data.frame(mxl_wtp_case_b$estimate)
mxl_wtp_c$se <- mxl_wtp_case_b$robse
mxl_wtp_c <- rownames_to_column(mxl_wtp_c, "Coefficent")
alpha = 0.1 # Set confidence level
mxl_wtp_c$ME <- qnorm(1-alpha/2)*mxl_wtp_c$se
mxl_wtp_c$Model <- "without NR"
mxl_wtp_c <- mxl_wtp_c %>% rename("Estimate" = `mxl_wtp_case_b$estimate`)
mxl_wtp_c_NR <- as.data.frame(mxl_wtp_case_b_NR$estimate)
mxl_wtp_c_NR$se <- mxl_wtp_case_b_NR$robse
mxl_wtp_c_NR <- rownames_to_column(mxl_wtp_c_NR, "Coefficent")
alpha = 0.1 # Set confidence level
mxl_wtp_c_NR$ME <- qnorm(1-alpha/2)*mxl_wtp_c_NR$se
mxl_wtp_c_NR$Model <- "with NR"
mxl_wtp_c_NR <- mxl_wtp_c_NR %>% rename("Estimate" = `mxl_wtp_case_b_NR$estimate`)

mxl_wtp_c <- rbind(mxl_wtp_c, mxl_wtp_c_NR)
wtp_nat_c <- mxl_wtp_c %>%
  filter(Coefficent %in% c("mu_nat_T"))
wtp_wd_c <- mxl_wtp_c %>%
  filter(Coefficent %in% c("mu_wd_T"))

wtp_nat_b<-ggplot(data=wtp_nat_c, aes(x=Coefficent, y=Estimate, fill=Model)) +
  geom_bar(stat="identity",  position='dodge', width = 0.9) +
  geom_errorbar(aes(x=Coefficent, ymin=Estimate-ME, ymax=Estimate+ME), width=0.3, position=position_dodge(0.8)) +
  ylab("WTP in Euro per month") +
  xlab("Coefficient") +
  scale_x_discrete(guide = guide_axis(angle = 45))

wtp_wd_b<-ggplot(data=wtp_wd_c, aes(x=Coefficent, y=Estimate, fill=Model)) +
  geom_bar(stat="identity",  position='dodge', width = 0.9) +
  geom_errorbar(aes(x=Coefficent, ymin=Estimate-ME, ymax=Estimate+ME), width=0.3, position=position_dodge(0.8)) +
  ylab("WTP in Euro per month") +
  xlab("Coefficient") +
  scale_x_discrete(guide = guide_axis(angle = 45))


# Compare Model coefficients Scenario C

mxl_wtp_c <- as.data.frame(mxl_wtp_case_c$estimate)
mxl_wtp_c$se <- mxl_wtp_case_c$robse
mxl_wtp_c <- rownames_to_column(mxl_wtp_c, "Coefficent")
alpha = 0.1 # Set confidence level
mxl_wtp_c$ME <- qnorm(1-alpha/2)*mxl_wtp_c$se
mxl_wtp_c$Model <- "without NR"
mxl_wtp_c <- mxl_wtp_c %>% rename("Estimate" = `mxl_wtp_case_c$estimate`)
mxl_wtp_c_NR <- as.data.frame(mxl_wtp_case_c_NR$estimate)
mxl_wtp_c_NR$se <- mxl_wtp_case_c_NR$robse
mxl_wtp_c_NR <- rownames_to_column(mxl_wtp_c_NR, "Coefficent")
alpha = 0.1 # Set confidence level
mxl_wtp_c_NR$ME <- qnorm(1-alpha/2)*mxl_wtp_c_NR$se
mxl_wtp_c_NR$Model <- "with NR"
mxl_wtp_c_NR <- mxl_wtp_c_NR %>% rename("Estimate" = `mxl_wtp_case_c_NR$estimate`)

mxl_wtp_c <- rbind(mxl_wtp_c, mxl_wtp_c_NR)
wtp_nat_c <- mxl_wtp_c %>%
  filter(Coefficent %in% c("mu_nat_vid1", "mu_nat_vid2" ,"mu_nat_info_nv1", "mu_nat_info_nv2","mu_nat_no_info"))
wtp_wd_c <- mxl_wtp_c %>%
  filter(Coefficent %in% c("mu_walking_vid1", "mu_walking_vid2" ,"mu_walking_info_nv1", "mu_walking_info_nv2","mu_walking_no_info" ))


wtp_nat_c<-ggplot(data=wtp_nat_c, aes(x=Coefficent, y=Estimate, fill=Model)) +
  geom_bar(stat="identity",  position='dodge', width = 0.9) +
  geom_errorbar(aes(x=Coefficent, ymin=Estimate-ME, ymax=Estimate+ME), width=0.3, position=position_dodge(0.8)) +
  ylab("WTP in Euro per month") +
  xlab("Coefficient") +
  scale_x_discrete(guide = guide_axis(angle = 45))

wtp_wd_c<-ggplot(data=wtp_wd_c, aes(x=Coefficent, y=Estimate, fill=Model)) +
  geom_bar(stat="identity",  position='dodge', width = 0.9) +
  geom_errorbar(aes(x=Coefficent, ymin=Estimate-ME, ymax=Estimate+ME), width=0.3, position=position_dodge(0.8)) +
  ylab("WTP in Euro per month") +
  xlab("Coefficient") +
  scale_x_discrete(guide = guide_axis(angle = 45))