---
title: "Income and Trust: Analysis Notebook"
output: html_document
---
```{r setup, include=FALSE}
library(tidyverse)
library(ggthemes)
library(scales)
```
```{r read-data}
# wd temp
setwd("C:/Users/bekes/Documents/GitHub/")
path ="da-w-ai/data/VWS/"
df <- read_csv(paste0(path, "WVS_GDP_merged_data.csv"))
df <- df %>%
mutate(baseline_trust = 2 - Q57,
alt_trust = 4 - rowMeans(select(., Q59:Q63), na.rm=TRUE) + 1,
log_gdppc = log(GDP_USD_PPP_per_capita))
```
```{r scatter, fig.width=6, fig.height=4, echo=FALSE}
ggplot(df, aes(x = log_gdppc, y = baseline_trust, colour = baseline_trust)) +
geom_point(alpha = 0.8, size = 2) +
scale_colour_viridis_c() +
geom_smooth(method = "lm", se = FALSE, colour = "black", linetype = "dashed") +
theme_economist() +
labs(x = "log GDP per capita (PPP, USD)",
y = "Share trusting (baseline)")
```
```{r ols}
summary(lm(baseline_trust ~ log_gdppc, data = df))
summary(lm(alt_trust ~ log_gdppc, data = df))
```