Skip to content

Commit

Permalink
Update 2024-11-14
Browse files Browse the repository at this point in the history
  • Loading branch information
skriptum committed Nov 14, 2024
1 parent 43abdb8 commit dadec98
Show file tree
Hide file tree
Showing 14 changed files with 298 additions and 33 deletions.
112 changes: 91 additions & 21 deletions vwl6/VL_Sozialismus/hausarbeit/Code.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,30 @@ bop <- bop %>%



### Migration
### Migration & Budget

```{r}
migration <- read_csv("data/migration.csv")
```
```{r}
investment <- read_csv("data/investment.csv")
```
### Wage
```{r}
wage <- read_csv("data/wage.csv")
```

Calculate real wage
```{r}
wage$real <- wage$wage / wage$col #cost of living = col
wage$real_growth <- wage$real - lag(wage$real)
```

calc 3year moving average

```{r}
wage$moving_avg <- zoo::rollmean(wage$real_growth, 5, fill = NA, align = "right")
```

## Explorative Plotting

Expand Down Expand Up @@ -194,6 +212,7 @@ ggplot(aes(x = year, y = G_revenue_percent), data=facts) +
y = "Percentage of GDP")
```


### Trade

Plot Total Imports and Exports and the deficit between them
Expand Down Expand Up @@ -258,9 +277,11 @@ comb <- comp_data %>%
mutate(gdp_dollar = rgdpnapc * pop*100) %>%
left_join(trade, by = "year") %>%
left_join(debt, by = "year") %>%
left_join(facts %>% select(year, GNP_pp_dollar), by = "year") %>%
left_join(facts %>% select(year, GNP_pp_dollar, GNP_factor_dinar), by = "year") %>%
left_join(bop %>% select(year, trade_balance, current_balance, remit), by = "year") %>%
left_join(migration, by="year")
left_join(migration, by="year") %>%
left_join(investment, by="year") %>%
left_join(wage %>% select(year, real_growth, moving_avg), by="year")
```

```{r}
Expand Down Expand Up @@ -298,14 +319,14 @@ ggsave("images/GDP_per_capita.png", width = 7, height = 4, dpi = 500)
Plot the growth rate of gdp

```{r}
# growth rate = (gdp(t) - gdp(t-1)) / gdp(t-1)
comp_data %>%
group_by(country) %>%
mutate(growth_rate = (rgdpnapc - lag(rgdpnapc)) / lag(rgdpnapc)) %>%
mutate(moving_avg = rollmean(growth_rate, 3, fill = NA, align = "right")) %>%
ggplot(aes(x = year, y = moving_avg, color = country, shape = country)) +
geom_line(size=0.4)
geom_point()
# # growth rate = (gdp(t) - gdp(t-1)) / gdp(t-1)
# comp_data %>%
# group_by(country) %>%
# mutate(growth_rate = (rgdpnapc - lag(rgdpnapc)) / lag(rgdpnapc)) %>%
# mutate(moving_avg = rollmean(growth_rate, 3, fill = NA, align = "right")) %>%
# ggplot(aes(x = year, y = moving_avg, color = country, shape = country)) +
# geom_line(size=0.4)
# geom_point()
```
### Figure: Energy Imports

Expand All @@ -321,7 +342,8 @@ imports_gdp_plot
imports_total_plot <- comb %>%
ggplot(aes(x = year)) +
geom_line(aes(y=IMPORTS_Mineral_fuels/IMPORTS_Total*100), color="blue") +
geom_point(aes(y=IMPORTS_Mineral_fuels/IMPORTS_Total*100), shape=5, color="blue")
geom_point(aes(y=IMPORTS_Mineral_fuels/IMPORTS_Total*100), shape=5, color="blue") +
ylim(0,30)
imports_total_plot
```

Expand Down Expand Up @@ -392,20 +414,21 @@ remit_total_plot
remit_rel_plot <- comb %>%
ggplot(aes(x = year)) +
geom_line(aes(y=remit/gdp_dollar*100), color="blue") +#relative to GDP
geom_point(aes(y=remit/gdp_dollar*100), color="blue", shape=5)
geom_point(aes(y=remit/gdp_dollar*100), color="blue", shape=5) +
ylim(0,8)
remit_rel_plot
```

sinking share of worker remittances, absolutely numbers down as well as relative

```{r}
remit_total_plot +
#remit_rel_plot +
#remit_total_plot +
remit_rel_plot +
scale_color_brewer(palette = "Set1")+
labs(
x = "Year",
y = "Remittances (Million $) ",
# y = "% of GDP"
# y = "Remittances (Million $) ",
y = "% of GDP"
) +
theme_tufte() +
theme(
Expand All @@ -415,8 +438,8 @@ remit_total_plot +
) +
xlim(c(1960,1990))
ggsave("images/remit_total.png", width = 4, height = 3, dpi = 500)
# ggsave("images/remit_rel.png", width = 4, height = 3, dpi = 500)
# ggsave("images/remit_total.png", width = 4, height = 3, dpi = 500)
ggsave("images/remit_rel.png", width = 4, height = 3, dpi = 500)
```


Expand Down Expand Up @@ -444,7 +467,7 @@ comb %>%
) +
xlim(c(1960,1986)) +
scale_y_continuous(n.breaks=7)
ggsave("images/debt.png", width=7, height=4, dpi=500)
ggsave("images/debt.png", width=7, height=3, dpi=500)
```


Expand Down Expand Up @@ -474,4 +497,51 @@ bop %>%
scale_y_continuous(n.breaks=6) +
geom_hline(yintercept=0, color="grey")
ggsave("images/trade_balance.png", width = 7, height = 4, dpi = 500)
```
```

### Figure: Inv and GDP

```{r}
ggplot(aes(x=year, y=(inv_otal / social_product)*100), data=investment) +
geom_line() +
geom_point(shape=5) +
theme_tufte() +
labs(title = "Gross fixed Investment and Social Product",
x = "Year",
y = "% of SP"
) +
theme(
legend.position = "bottom",
legend.title = element_blank(),
panel.border = element_rect(fill = NA, color = "black")
) +
xlim(1969,1987)
ggsave("images/inv_sp.png", height=3, width=7, dpi=500)
```
```{r}
ggplot(aes(x=year, y=(inv_social/inv_otal)), data=investment) +
geom_line()
```

### Figure: Real Wage Growth

Plot the real wage growth and the 5-year moving average of the real wage growth

```{r}
ggplot(aes(x = year), data=wage) +
geom_point(aes(y= real_growth, color="")) +
geom_line(aes(y= moving_avg, color="5-year mov. avg")) +
geom_point(aes(y= moving_avg), shape=5, color = "red") +
labs(title = "",
x = "Year",
y = "Growth") +
geom_hline(yintercept=0, color="grey") +
theme_tufte() +
theme(
legend.position = "bottom",
legend.title = element_blank(),
panel.border = element_rect(fill = NA, color = "black"),
) +
scale_y_continuous(labels = scales::percent_format(scale = 100))
ggsave("images/real_wage.png", width = 7, height = 4, dpi = 500)
```
23 changes: 23 additions & 0 deletions vwl6/VL_Sozialismus/hausarbeit/data/investment.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
year,inv_otal,inv_private,inv_social,social_product,
1967,30620,5795,24825,
1968,35698,6589,29109,111972,
1969,42266,7423,34843,131960,
1970,53103,9657,43446,157207,
1971,65623,13064,52559,204476
1972,75079,16281,58798,245395,
1973,86732,22304,64428,306326,
1974,119254,28375,90879,407220
1975,163200,30900,132300,502995
1976,207300,36300,171000,592560,
1977,268000,45700,222300,734304,
1978,357300,53600,303700,901815
1979,447600,71000,376600,1165417
1980,545600,88500,457100,1553089,
1981,685000,121600,563400,2208250
1982,854800,166100,688700,2924834,
1983,1029500,209800,819700,4064289,
1984,1458400,292400,1166000,6325843,
1985,2608800,466800,2142000,11284700,
1986,5047000,950900,4096100,22054700
1987,9914600,1890000,8024600,49264700
1988,27192800,6923900,20268900,148560700
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions vwl6/VL_Sozialismus/hausarbeit/data/wage.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
year,col,wage
1967,88,79,
1968,93,87,
1969,100,100,
1970,111,118,
1971,128,145,
1972,149,169,
1973,178,196,
1974,216,250,
1975,268,309,
1976,299,424,
1977,345,424,
1978,394,513,
1979,474,617,
1980,617,744,
1981,870,995,
1982,1149,1267,
1983,1613,1602,
1984,2500,2304,
1985,4287,4107,
1986,8107,8553,
1987,17680,17619,
1988,52687,47924,
1989,712328,808478
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit dadec98

Please sign in to comment.