Institute for Sociology and Political Science
Norwegian University of Science and Technology

June 12, 2024

Outcome

Code
dat$f_support_restrictions<- as.factor(dat$support_restrictions_plus)
ans_f_support_restrictions <- dat[, .(.N), by = .(f_support_restrictions, country)]
ans_f_support_restrictions[, percent := N / sum(N) * 100 , by = "country"]

with(
  ans_f_support_restrictions,
  plt(
    facet = country,
    x = as.numeric(f_support_restrictions), y = percent, type="h", lwd = 4,         
    grid = TRUE, col = color_plots,
    main = "Prohibiting Firms from Trading High Technology w. China",
    xlab = "Oppose Strongly to Support Strongly",
    frame = FALSE
  )
)

Just oppose-support:

Code
dat$f_support_oppose <- as.factor(dat$support_oppose)
ans_support_oppose <- dat[, .(.N), by = .(f_support_oppose, country)]
ans_support_oppose[, percent := N / sum(N) * 100 , by = "country"]

with(
  ans_support_oppose,
  plt(
    facet = country,
    x = as.numeric(f_support_oppose), y = percent, type="h", lwd = 4,         
    grid = TRUE, col = color_plots,
    main = "Prohibiting Firms from Trading High Technology w. China",
    xlab = "Oppose, Neither, Support",
    frame = FALSE
  )
)

Issue Importance sperately:

Code
dat$f_ans_imp<- as.factor(dat$importance_str)
ans_imp <- dat[, .(.N), by = .(f_ans_imp, country)]
ans_imp[, percent := N / sum(N) * 100 , by = "country"]

with(
  ans_imp,
  plt(
    facet = country,
    x = as.numeric(f_ans_imp), y = percent, type="h", lwd = 4,         
    grid = TRUE, col = color_plots,
    main = "Decision Importance",
    xlab = "Not at all important to Extremely important ",
    frame = FALSE
  )
)

Treatment Effekte insgesamt

Code
# Center categorical co variables ------------------

contrasts(dat$gender) <- c(-1,1)
contrasts(dat$country) <- contr.sum(5)
contrasts(dat$edu_cat) <- cbind(c(-1,1,0),c(-1,0,1))
contrasts(dat$costs) <- contr.Treatment(n = c("small","large"))
contrasts(dat$frame) <- contr.Treatment(n = c("economic","military"))
# Center metric co variables ------------------

met_cov <- c('EU_gen','sat_life','sat_econ_nat','sat_gov','sat_dem',
             'polint_EU','leftright','poltrust','natatt','global','migration','age')

dat[, paste0(met_cov) := lapply( .SD, scale, scale = FALSE, center = TRUE), .SDcols = met_cov]
Code
mod_base <- lm_robust(support_restrictions_plus ~ geo_exp*country, data = dat, se_type = "HC3")

mod_1 <- lm_robust(support_restrictions_plus ~ costs * frame, data = dat, se_type = "HC3")

mod_2 <- lm_robust(support_restrictions_plus ~ costs * frame * (country + gender + edu_cat), data = dat, se_type = "HC3")

Average effects

Code
avg_frame <- avg_comparisons(mod_2,
  variables = "frame")
avg_costs <- avg_comparisons(mod_2,
  variables = "costs")
avg_costframe <- data.table(rbind(avg_frame,avg_costs))
avg_costframe <- avg_costframe[,2:6]
cols <- names(avg_costframe)[2:5]
avg_costframe[,(cols) := round(.SD,3), .SDcols=cols]
tt(avg_costframe)
tinytable_7shwds0fjmp5bnjjwefd
contrast estimate std.error statistic p.value
mean(military) - mean(economic) 0.005 0.004 1.375 0.169
mean(large) - mean(small) -0.018 0.004 -4.536 0.000

Average effects of costs within each frame

Code
avg_costs_w_frame <- data.table(avg_comparisons(mod_2,
  variables = "costs", by = "frame"))
cols <- names(avg_costs_w_frame)[4:7]
avg_costs_w_frame[,(cols) := round(.SD,3), .SDcols=cols]
tt(avg_costs_w_frame[,2:7])
tinytable_2i4tw5lmah2pgaqnbdkl
contrast frame estimate std.error statistic p.value
mean(large) - mean(small) economic -0.017 0.005 -3.122 0.002
mean(large) - mean(small) military -0.018 0.006 -3.292 0.001

Average effects of frame within each country

Code
avg_frame_w_country <- data.table(avg_comparisons(mod_2,
  variables = "frame", by = "country"))
cols <- names(avg_frame_w_country)[4:7]
avg_frame_w_country[,(cols) := round(.SD,3), .SDcols=cols]
tt(avg_frame_w_country[,2:7])
tinytable_1psmuumv4g7ztxexuh6s
contrast country estimate std.error statistic p.value
mean(military) - mean(economic) France 0.003 0.010 0.285 0.776
mean(military) - mean(economic) Germany 0.013 0.008 1.705 0.088
mean(military) - mean(economic) Italy -0.002 0.008 -0.290 0.772
mean(military) - mean(economic) Poland 0.012 0.008 1.422 0.155
mean(military) - mean(economic) Sweden 0.001 0.009 0.097 0.923

Average effects of costs within each country

Code
avg_costs_w_country <- data.table(avg_comparisons(mod_2,
  variables = "costs", by = "country"))
cols <- names(avg_costs_w_country)[4:7]
avg_costs_w_country[,(cols) := round(.SD,3), .SDcols=cols]
tt(avg_costs_w_country[,2:7])
tinytable_hdt2krdwamrnq2q425wi
contrast country estimate std.error statistic p.value
mean(large) - mean(small) France -0.020 0.010 -1.976 0.048
mean(large) - mean(small) Germany -0.022 0.008 -2.772 0.006
mean(large) - mean(small) Italy -0.029 0.008 -3.663 0.000
mean(large) - mean(small) Poland -0.014 0.008 -1.682 0.093
mean(large) - mean(small) Sweden -0.003 0.009 -0.346 0.729

Plots

Costs by country

Code
avg_cost <- data.table(avg_comparisons(mod_2,
  variables = "costs", by = "country"))

with(
  avg_cost,
  plt(
    x = country, y = estimate,
    ymin = conf.low, ymax = conf.high,
    type = "pointrange", 
    pch = 19, col = color_plots,
    grid = TRUE,
    lwd = 3,
    xlab = "",
    main = "Average Treatment Effect of Large vs. Small Costs",
    frame = FALSE
  )
)
abline(h = 0, lty = 3)

Framing by country

Code
avg_frame <- data.table(avg_comparisons(mod_2,
  variables = "frame", by = "country"))

with(
  avg_frame,
  plt(
    x = country, y = estimate,
    ymin = conf.low, ymax = conf.high,
    type = "pointrange", 
    pch = 19, col = color_plots,
    grid = TRUE,
    lwd = 3,
    xlab = "",
    main = "Average Treatment Effect of Military vs. Economic Framing",
    frame = FALSE
  )
)
abline(h = 0, lty = 3)

Group Means by country

Germany

Code
pred_overall<- data.table(avg_predictions(mod_base,
  variables = c("geo_exp","country")))
setorder(pred_overall, cols = "geo_exp") 

with(
  pred_overall[country=="Germany"],
  plt(
    x = geo_exp, y = estimate,
    ymin = conf.low, ymax = conf.high,
    type = "pointrange", 
    pch = 19, col = color_plots,
    grid = TRUE,
    lwd = 3,
    xlab = "",
    main = "Average Group Means Germany",
    frame = FALSE
  )
)

France

Code
with(
  pred_overall[country=="France"],
  plt(
    x = geo_exp, y = estimate,
    ymin = conf.low, ymax = conf.high,
    type = "pointrange", 
    pch = 19, col = color_plots,
    grid = TRUE,
    lwd = 3,
    xlab = "",
    main = "Average Group Means France",
    frame = FALSE
  )
)

Italy

Code
with(
  pred_overall[country=="Italy"],
  plt(
    x = geo_exp, y = estimate,
    ymin = conf.low, ymax = conf.high,
    pch = 19, col = color_plots,
    type = "pointrange", 
    grid = TRUE,
    lwd = 3,
    xlab = "",
    main = "Average Group Means Italy",
    frame = FALSE
  )
)

Poland

Code
with(
  pred_overall[country=="Poland"],
  plt(
    x = geo_exp, y = estimate,
    ymin = conf.low, ymax = conf.high,
    pch = 19, col = color_plots,
    type = "pointrange", 
    grid = TRUE,
    lwd = 3,
    xlab = "",
    main = "Average Group Means Poland",
    frame = FALSE
  )
)

Sweden

Code
with(
  pred_overall[country=="Sweden"],
  plt(
    x = geo_exp, y = estimate,
    ymin = conf.low, ymax = conf.high,
    type = "pointrange", 
    pch = 19, col = color_plots,
    grid = TRUE,
    lwd = 3,
    xlab = "",
    main = "Average Group Means Sweden",
    frame = FALSE
  )
)

Plotting Trade Preferences by country

China

Code
dat$f_trade_China <- as.factor(dat$trade_China)
ans_trade_China <- dat[, .(.N), by = .(f_trade_China, country)]
ans_trade_China[, percent := N / sum(N) * 100 , by = "country"]

with(
  ans_trade_China,
  plt(
    facet = country,
    x = as.numeric(f_trade_China), y = percent, type="h", lwd = 4,         
    grid = TRUE, col = color_plots,
    main = "Should [country] increase or reduce trade with China?",
    xlab = "Reduce Significantly to Increase Significantly",
    frame = FALSE
  )
)

India

Code
dat$f_trade_India <- as.factor(dat$trade_India)
ans_trade_India <- dat[, .(.N), by = .(f_trade_India, country)]
ans_trade_India[, percent := N / sum(N) * 100 , by = "country"]

with(
  ans_trade_India,
  plt(
    facet = country,
    x = as.numeric(f_trade_India), y = percent, type="h", lwd = 4,         
    grid = TRUE, col = color_plots,
    main = "Should [country] increase or reduce trade with India?",
    xlab = "Reduce Significantly to Increase Significantly",
    frame = FALSE
  )
)

Brazil

Code
dat$f_trade_Brazil<- as.factor(dat$trade_Brazil)
ans_trade_Brazil <- dat[, .(.N), by = .(f_trade_Brazil, country)]
ans_trade_Brazil[, percent := N / sum(N) * 100 , by = "country"]

with(
  ans_trade_Brazil,
  plt(
    facet = country,
    x = as.numeric(f_trade_Brazil), y = percent, type="h", lwd = 4,         
    grid = TRUE, col = color_plots,
    main = "Should [country] increase or reduce trade with Brazil?",
    xlab = "Reduce Significantly to Increase Significantly",
    frame = FALSE
  )
)

Russia

Code
dat$f_trade_Russia <- as.factor(dat$trade_Russia)
ans_trade_Russia <- dat[, .(.N), by = .(f_trade_Russia, country)]
ans_trade_Russia[, percent := N / sum(N) * 100 , by = "country"]

with(
  ans_trade_Russia,
  plt(
    facet = country,
    x = as.numeric(f_trade_Russia), y = percent, type="h", lwd = 4,         
    grid = TRUE, col = color_plots,
    main = "Should [country] increase or reduce trade with Russia?",
    xlab = "Reduce Significantly to Increase Significantly",
    frame = FALSE
  )
)

USA

Code
dat$f_trade_US<- as.factor(dat$trade_US)
ans_trade_US<- dat[, .(.N), by = .(f_trade_US, country)]
ans_trade_US[, percent := N / sum(N) * 100 , by = "country"]

with(
  ans_trade_US,
  plt(
    facet = country,
    x = as.numeric(f_trade_US), y = percent, type="h", lwd = 4,         
    grid = TRUE, col = color_plots,
    main = "Should [country] increase or reduce trade with the US?",
    xlab = "Reduce Significantly to Increase Significantly",
    frame = FALSE
  )
)

EU

Code
dat$f_trade_EU<- as.factor(dat$trade_EU)
ans_trade_EU<- dat[, .(.N), by = .(f_trade_EU, country)]
ans_trade_EU[, percent := N / sum(N) * 100 , by = "country"]

with(
  ans_trade_EU,
  plt(
    facet = country,
    x = as.numeric(f_trade_EU), y = percent, type="h", lwd = 4,         
    grid = TRUE, col = color_plots,
    main = "Should [country] increase or reduce trade with EU?",
    xlab = "Reduce Significantly to Increase Significantly",
    frame = FALSE
  )
)

Economic Globalisation Attitude

Code
with(
  dat,
  plt(
    density(global, na.rm = TRUE),
    facet = country,
    grid = TRUE, col = color_plots, fill = color_plots,
    main = "Globalisation Scale",
    xlab = "Opposition to Support",
    frame = FALSE
  )
)

Power Perceptions

Code
dat$f_power_perc <- as.factor(dat$power_perc)
ans_power_perc <- dat[, .(.N), by = .(f_power_perc, country)]
ans_power_perc[, percent := N / sum(N) * 100 , by = "country"]

with(
  ans_power_perc,
  plt(
    facet = country,
    x = as.numeric(f_power_perc), y = percent, type="h", lwd = 4,         
    grid = TRUE, col = color_plots, xlim = c(1,10),
    main = "Determining [country’s] overall power",
    xlab = "Military power to Economic power",
    frame = FALSE
  )
)

Issue Importance Trade

Code
dat$f_trade_issue<- as.factor(dat$issue_trade)
ans_trade_issue<- dat[, .(.N), by = .(f_trade_issue, country)]
ans_trade_issue[, percent := N / sum(N) * 100 , by = "country"]

with(
  ans_trade_issue,
  plt(
    facet = country,
    x = as.numeric(f_trade_issue), y = percent, type="h", lwd = 4,         
    grid = TRUE, col = color_plots, 
    main = "Issue Importance: Trade",
    xlab = "Not important at all to Very important",
    frame = FALSE
  )
)

Satisfaction with National economy

Code
dat$f_sat_econ_nat<- as.factor(dat$sat_econ_nat)
ans_econ_nat<- dat[, .(.N), by = .(f_sat_econ_nat, country)]
ans_econ_nat[, percent := N / sum(N) * 100 , by = "country"]

with(
  ans_econ_nat,
  plt(
    facet = country,
    x = as.numeric(f_sat_econ_nat), y = percent, type="h", lwd = 4,         
    grid = TRUE, col = color_plots,
    main = "Satisfaction: National Economy",
    xlab = "Very dissatisfied to Very satisfied",
    frame = FALSE
  )
)