Makro II: Zusätzliches Material

by Markus Mößler


Wohlstand Beschreiben und Erklären


Dieses Dokument enthält ausgewählter Zeitreihen zur Analyse von Wohlstand.


Einführung

Einordnung

Einordnung


Für die Einordnung siehe auch Kapitel 2.2 “Vermessung von Wohlstand”.

  • Mengen:
    • Einkommen \(\left(Y\right)\)
    • Konsum \(\left(C\right)\)
    • Investitionen \(\left(I\right)\)
    • Liquidität \(\left(L\right)\)
    • Nettoexporte \(\left(NX\right)\) und Nettokapitalexporte \(\left(NKE\right)\)
    • Staatsausgaben \(\left(G\right)\)
    • Staatseinnahmen \(\left(T\right)\)
  • Preise:
    • Inflationsrate \(\left(P, \pi\right)\)
    • Zinsen \(\left(i, r\right)\)
    • Wechselkurse \(\left(e, \varepsilon\right)\)

Vorbereitung

Vorbereitung


Vorbereitung des R-Skripts:

  1. Setzen des Arbeitspfades
# setwd("... insert-you-directory-here ...")
  1. Laden der nötigen Pakete zu Datenverarbeitung
library(dplyr)
library(tidyr)
library(ggplot2)
library(kableExtra)
library(scales)
library(zoo)
library(ecm)
  1. Laden der Grafikvorlage
mod.theme.01 <- theme_gray() + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, size = 12),
                                     axis.text.y = element_text(size = 12),
                                     plot.title = element_text(size = 16),
                                     plot.subtitle = element_text(size = 12),
                                     plot.caption = element_text(size = 12),
                                     legend.text = element_text(size = 12))

mod.theme.01$legend.position <- c("bottom")

Die Daten werden von unterschiedlichen öffentlich zugänglichen Datenbanken heruntergeladen.

Die Daten können entweder auf der Website oder über so genannte Programmierschnittstellen (APIs) heruntergeladen werden.

FRED

FRED


Die Daten von der Federal Reserve Bank of St. Louis können mit dem R-Paket fredr heruntergeladen werden.


Um Daten über die FRED-API müssen Sie sich zuerst kostenlos registrieren und einen “API Key” beantragen (siehe).

Diesen “API Key” müssen Sie anschließend mit der R-Funktion fredr_set_key angeben.

# FRED
library(fredr)
# Set your fredr key here
fredr_set_key("... insert-your-personal-key-here ...")

Zur Schattierung der Rezessionen (siehe: NBER) verwenden wir die folgende R-Funktion.

# See: https://rpubs.com/FSl/609471 (and edite by MM)
add_rec_shade <- function(st_date, ed_date, shade_color = "darkgray", zoo.mon = FALSE, zoo.qtr = FALSE) {
  
  recession  <-  fredr(series_id = "USRECD",observation_start = as.Date(st_date),observation_end = as.Date(ed_date))
  
  recession$diff <- recession$value-lagpad(recession$value, k = 1)
  recession <- recession[!is.na(recession$diff),]
  recession.start <- recession[recession$diff == 1,]$date
  recession.end <- recession[recession$diff == (-1),]$date
  
  if(length(recession.start) > length(recession.end)) {
    recession.end <- c(recession.end, Sys.Date())
  }
  if(length(recession.end)>length(recession.start)) {
    recession.start <- c(min(recession$date), recession.start)
  }
  
  recs <- as.data.frame(cbind(recession.start, recession.end))
  recs$recession.start <- as.Date(as.numeric(recs$recession.start), origin = as.Date("1970-01-01"))
  
  if(zoo.mon == TRUE){
    recs$recession.start <- as.yearmon(recs$recession.start, "%b%y")
  }
  if(zoo.qtr == TRUE){
    recs$recession.start <- as.yearqtr(recs$recession.start, "%y-Q%q")
  }
  
  recs$recession.end <- as.Date(recs$recession.end, origin = as.Date("1970-01-01"))
  
  if(zoo.mon == TRUE){
    recs$recession.end <- as.yearmon(recs$recession.end, "%b%y")
  }
  if(zoo.qtr == TRUE){
    recs$recession.end <- as.yearqtr(recs$recession.end, "%y-Q%q")
  }
  
  if(nrow(recs) > 0) {
    rec_shade <- geom_rect(data = recs, inherit.aes = FALSE, 
                           aes(xmin = recession.start, xmax = recession.end, ymin = -Inf, ymax = +Inf), 
                           fill = shade_color, alpha = 0.5)
    
    return(rec_shade)
  }
  
}

Eurostat and ECB

Eurostat and ECB


Die Daten von Eurostat und der EcB können mit dem R-Paket eurostat und ecb heruntergeladen werden.

Links:

# eurostat
library(eurostat)
# ecb statistical data warehouse
library(ecb)

Mengen

USA

Reales BIP (Niveau)

# Meta data
met.dat <- fredr_series_search_text("GDPC1")

# Data
ser.dat <- fredr_series_observations(series_id = met.dat$id[1],
                                     observation_start = as.Date("1947-01-01"),
                                     units = "lin")

# Transform date to yearmon class
ser.dat$date.zoo <- as.yearqtr(ser.dat$date, "%y-Q%q")

# Construct plot
plot <- ggplot(data = ser.dat, mapping = aes(x=date.zoo, y = value, color = series_id)) +
  add_rec_shade(min(ser.dat$date), max(ser.dat$date), zoo.mon = FALSE, zoo.qtr = TRUE) +
  geom_line(color = "black", size = 1) +
  scale_x_yearqtr(breaks = seq(from = min(ser.dat$date.zoo), to = max(ser.dat$date.zoo), by = 8),
                  minor_breaks = seq(from = min(ser.dat$date.zoo), to = max(ser.dat$date.zoo), by = 4),
                  format = "%Y-Q%q",
                  expand = c(0, 0)) +
  scale_y_continuous(labels = comma_format(big.mark = ".", decimal.mark = ",")) +
  labs(title = "Reales Bruttoinlandsprodukt (saisonbereinigt)",
       subtitle = paste0(c("(Letzter Beobachtungswert: "), as.yearqtr(as.Date(met.dat$observation_end)), c(")")),
       caption = "Quelle: U.S. Bureau of Economic Analysis", 
       x = "", y = "Verkettete 2012 US Dollar in Milliarden") +
  mod.theme.01

# Return plot
plot

Date Period Value
2021-07-01 2021 Q3 21.483,08
2021-10-01 2021 Q4 21.847,60
2022-01-01 2022 Q1 21.738,87
2022-04-01 2022 Q2 21.708,16
2022-07-01 2022 Q3 21.851,13
2022-10-01 2022 Q4 21.989,98
2023-01-01 2023 Q1 22.112,33
2023-04-01 2023 Q2 22.225,35
2023-07-01 2023 Q3 22.490,69
2023-10-01 2023 Q4 22.672,86

Reales BIP (Veränderung)

# Meta data
met.dat <- fredr_series_search_text("GDPC1")

# Data
ser.dat <- fredr_series_observations(series_id = met.dat$id[1],
                                     observation_start = as.Date("1947-01-01"),
                                     units = "pc1")

# Transform date to yearmon class
ser.dat$date.zoo <- as.yearqtr(ser.dat$date, "%y-Q%q")

# Construct plot
plot <- ggplot(data = ser.dat, mapping = aes(x=date.zoo, y = value, color = series_id)) +
  add_rec_shade(min(ser.dat$date), max(ser.dat$date), zoo.mon = FALSE, zoo.qtr = TRUE) +
  geom_line(color = "black", size = 1) +
  scale_y_continuous(labels = comma_format(big.mark = ".", decimal.mark = ",")) +
  scale_x_yearqtr(breaks = seq(from = min(ser.dat$date.zoo), to = max(ser.dat$date.zoo), by = 8),
                  minor_breaks = seq(from = min(ser.dat$date.zoo), to = max(ser.dat$date.zoo), by = 4),
                  format = "%Y-Q%q",
                  expand = c(0, 0)) +
  labs(title = "Reales Bruttoinlandsprodukt (jährliche Veränderungsrate)",
       subtitle = paste0(c("(Letzter Beobachtungswert: "), as.yearqtr(as.Date(met.dat$observation_end)), c(")")),
       caption = "Quelle: U.S. Bureau of Economic Analysis", 
       x = "", y = "%-Verä. verk. 2012 USD (jähr.)") +
  mod.theme.01

# Return plot
plot

Date Period Value
2021-07-01 2021 Q3 4,73532
2021-10-01 2021 Q4 5,42109
2022-01-01 2022 Q1 3,56508
2022-04-01 2022 Q2 1,87060
2022-07-01 2022 Q3 1,71321
2022-10-01 2022 Q4 0,65169
2023-01-01 2023 Q1 1,71793
2023-04-01 2023 Q2 2,38247
2023-07-01 2023 Q3 2,92689
2023-10-01 2023 Q4 3,10541

Eurozone

Reales BIP (Niveau)

source("https://raw.githubusercontent.com/mmoessler/macro-dashboard/main/r-scripts/r_eurostat_helper_functions.R")

# Url
url <- "https://ec.europa.eu/eurostat/api/dissemination/statistics/1.0/data/namq_10_gdp?format=JSON&geo=DE&geo=FR&geo=EA19&freq=Q&unit=CLV15_MEUR&na_item=B1G&s_adj=SCA"

# Data
ser.dat <- get_eurostat_fun(url = url)

# Transform date to date class
ser.dat$date.dat <- as.Date(as.yearqtr(as.character(ser.dat$time), "%Y-Q%q"))
# Transform date to yearmon class
ser.dat$date.zoo <- as.yearqtr(ser.dat$date.dat, "%Y Q%q")

# Subset data
ser.dat <- subset(ser.dat, date.dat %in% seq(as.Date("2000-01-01"), Sys.Date(), "quarter"))

# Construct plot
plot <- ggplot(data = ser.dat, mapping = aes(x = date.zoo, y = values/1000, color = geo)) +
  geom_line(size = 1) +
  scale_y_continuous(labels = comma_format(big.mark = ".", decimal.mark = ",")) +
  scale_x_yearqtr(breaks = seq(from = min(ser.dat$date.zoo), to = max(ser.dat$date.zoo), by = 2),
                  minor_breaks = seq(from = min(ser.dat$date.zoo), to = max(ser.dat$date.zoo), by = 1),
                  format = "%Y Q%q",
                  expand = c(0, 0)) +
  scale_color_discrete(name = "", labels = c("DEU", "EA19", "FRA")) +
  labs(title = "Reales Bruttoinlandsprodukt (BIP)",
       subtitle = paste0(c("(Letzter Beobachtungswert: "), as.yearqtr(as.Date(met.dat$observation_end)), c(")")),
       caption = "Quelle: Eurostat", 
       x = "", y = "Verkettete 2005 EUR in Milliarden") +
  mod.theme.01

# Return plot
plot

Period GER FRA EA19
87 2021 Q3 726,7793 524,1721 2.568,597
88 2021 Q4 725,5545 527,4312 2.578,956
89 2022 Q1 729,6544 527,6798 2.594,607
90 2022 Q2 731,7641 529,8134 2.621,096
91 2022 Q3 736,7999 533,0157 2.637,215
92 2022 Q4 732,2404 533,3354 2.634,430
93 2023 Q1 734,4181 533,9048 2.638,960
94 2023 Q2 733,2612 537,8380 2.640,002
95 2023 Q3 734,1459 537,7102 2.638,356
96 2023 Q4 NA 537,7196 NA

Preise

Waren und Diensleistungen

USA

USA


Konsumentenpreisindex

# Meta data
met.dat <- fredr_series_search_text("CPIAUCSL")

# Data
ser.dat <- fredr_series_observations(series_id = met.dat$id[1],
                                     observation_start = as.Date("1999-12-31"),
                                     units = "pc1")

# Construct plot
plot <- ggplot(data = ser.dat, mapping = aes(x = date, y = value)) +
  add_rec_shade(min(ser.dat$date), max(ser.dat$date), zoo.mon = FALSE, zoo.qtr = FALSE) +
  geom_line(size = 1) +
  scale_x_date(date_breaks = "1 years",
               date_minor_breaks = "1 years",
               date_labels = "%Y",
               expand = c(0, 0)) +
  scale_y_continuous(breaks = seq(-5, 15, 1),
                     labels = comma) + 
  labs(title = "Konsumentenpreiseindex (Jährliche Veränderungsrate)",
       subtitle = paste0(c("(Letzter Beobachtungswert: "), as.yearmon(met.dat$observation_end[1]), c(")")),
       caption = "Quelle: U.S. Bureau of Labor Statistics", 
       x = "", y = "Prozentual Veränderung (YoY)") +
  mod.theme.01

# Return plot
plot

Datum Wert
2023-03-01 4,99
2023-04-01 4,96
2023-05-01 4,13
2023-06-01 3,09
2023-07-01 3,30
2023-08-01 3,71
2023-09-01 3,69
2023-10-01 3,23
2023-11-01 3,12
2023-12-01 3,30

Eurozone

Deutschland


Konsumentenpreisindex

source("https://raw.githubusercontent.com/mmoessler/macro-dashboard/main/r-scripts/r_eurostat_helper_functions.R")

# Url
url <- "https://ec.europa.eu/eurostat/api/dissemination/statistics/1.0/data/prc_hicp_manr?format=JSON&geo=DE&geo=FR&geo=EA19&freq=M&unit=RCH_A&coicop=CP00"

# Data
ser.dat <- get_eurostat_fun(url = url)

# Transform date to date class
ser.dat$date.dat <- as.Date(as.yearmon(ser.dat$time))
# Transform date to yearmon class
ser.dat$date.zoo <- as.yearmon(ser.dat$date.dat, "%b%y")

# Subset data
ser.dat <- subset(ser.dat, date.dat %in% seq(as.Date("2010-01-01"), Sys.Date(), by = "month"))

# Construct plot
plot <- ggplot(data = ser.dat, mapping = aes(x = date.zoo, y = values, color = geo)) +
  geom_line(size = 1) +
  scale_x_yearmon(breaks = seq(from = min(ser.dat$date.zoo), to = max(ser.dat$date.zoo), by = 1),
                  minor_breaks = seq(from = min(ser.dat$date.zoo), to = max(ser.dat$date.zoo), by = 1),
                  format = "%b %Y",
                  expand = c(0, 0)) +
  scale_y_continuous(breaks = seq(-5, 15, 1),
                     labels=comma) +
  scale_color_discrete(name = "", labels = c("GER","FRA","EA19")) +
  labs(title = "HVPI (jährliche Veränderungrate)",
       subtitle = paste0(c("(Letzter Beobachtungswert: "), as.yearmon(as.Date(ser.dat$date.dat[length(ser.dat$time)])), c(")")),
       caption = "Quelle: Eurostat", 
       x = "", y = "Prozent") +
  mod.theme.01

# Return plot
plot

Period GER FRA EA19
Apr 2023 7,6 6,9 6,9
May 2023 6,3 6,0 6,1
Jun 2023 6,8 5,3 5,5
Jul 2023 6,5 5,1 5,3
Aug 2023 6,4 5,7 5,2
Sep 2023 4,3 5,7 4,3
Oct 2023 3,0 4,5 2,9
Nov 2023 2,3 3,9 2,4
Dec 2023 3,8 4,1 2,9
Jan 2024 3,1 3,4 NA

Liquidität

USA

USA


FED Funds Zielband (oberes Limit)

# Meta data
met.dat <- fredr_series_search_text("DFEDTARU")

# Data
ser.dat <- fredr_series_observations(series_id=met.dat$id[1],
                                     observation_start=as.Date("1999-12-31"),
                                     units="lin")

# Construct plot
plot <- ggplot(data = ser.dat, mapping = aes(x = date, y = value)) +
  add_rec_shade(min(ser.dat$date), max(ser.dat$date), zoo.mon = FALSE, zoo.qtr = FALSE) +
  geom_line(size = 1) +
  scale_y_continuous(name = "Percent", labels = comma) +
  scale_x_date(date_breaks = "1 years",
               date_minor_breaks = "1 years",
               date_labels = "%Y",
               expand = c(0, 0)) +
  scale_y_continuous(breaks = seq(0, 10, 0.5)) + 
  labs(title = "FED Funds Zielband (oberes Limit)",
       subtitle = paste0(c("(Letzter Beobachtungswert: "), met.dat$observation_end, c(")")),
       caption = "Quelle: FED", 
       x = "", y = "Prozent") +
  mod.theme.01

# Return plot
plot

Datum Wert
2024-01-29 5,5
2024-01-30 5,5
2024-01-31 5,5
2024-02-01 5,5
2024-02-02 5,5
2024-02-03 5,5
2024-02-04 5,5
2024-02-05 5,5
2024-02-06 5,5
2024-02-07 5,5

Eurozone

Eurozone

Spitzenrefinanzierungsfazilität

# Df with date sequence for merging 
date.df <- data.frame(date=seq(as.Date("1999-01-01"), Sys.Date(), by = "day")) 

# Load marginal lending facility
key <- "FM.B.U2.EUR.4F.KR.MLFR.LEV"
dat.01 <- get_data(key)
dat.01$date <- as.Date(dat.01$obstime)
colnames(dat.01)[9] <- c("mlf_00")

# Merge dates and observations
dat.02 <- merge(date.df, dat.01, by = "date", all.x = TRUE)

# Fill in NAs
dat.02$mlf <- dat.02$mlf_00
for (ii in 2:nrow(dat.02)) {
  if (is.na(dat.02$mlf_00[ii])) {
    dat.02$mlf[ii] <- dat.02$mlf[ii-1]
  } else {
    dat.02$mlf[ii] <- dat.02$mlf_00[ii]
  }
}

# Transform date to yearmon class
dat.02$date.zoo <- as.yearmon(dat.02$date, "%b%y")

dat <- dat.02

# Construct plot
plot <- ggplot(data = dat, mapping = aes(x = date.zoo, y = mlf)) +
  geom_line(color = "black", size = 1) +
  scale_y_continuous(breaks = seq(0, 10, 0.5),
                     labels = comma_format(big.mark = ".", decimal.mark = ",")) +
  scale_x_yearmon(breaks = seq(from = min(dat$date.zoo), to = max(dat$date.zoo), by = 1),
                  minor_breaks = seq(from = min(dat$date.zoo), to = max(dat$date.zoo), by = 1),
                  format = "%b %y",
                  expand = c(0, 0)) +
  labs(title = "ECB Spitzenrefinanzierungsfazilität",
       subtitle = paste0(c("(Letzter Beobachtungswert: "), as.Date(dat$date[length(dat$date)]), c(")")),
       caption = "Quelle: EZB",
       x = "", y = "Prozent") +
  mod.theme.01

# Return plot
plot

Datum Wert
2024-01-30 4,75
2024-01-31 4,75
2024-02-01 4,75
2024-02-02 4,75
2024-02-03 4,75
2024-02-04 4,75
2024-02-05 4,75
2024-02-06 4,75
2024-02-07 4,75
2024-02-08 4,75

Hauptrefinanzierungssatz

# Df with date sequence for merging 
date.df <- data.frame(date=seq(as.Date("1999-01-01"), as.Date("2023-02-28"), by = "day")) 
date.df <- data.frame(date=seq(as.Date("1999-01-01"), Sys.Date(), by = "day")) 

# Load main refinancing operation (new)
key <- "FM.B.U2.EUR.4F.KR.MRR_FR.LEV"
dat.01 <- get_data(key)
dat.01$date <- as.Date(dat.01$obstime)
colnames(dat.01)[9] <- c("mro_00")

# Load main refinancing operation (minimum bid rate - old)
key <- "FM.B.U2.EUR.4F.KR.MRR_MBR.LEV"
dat.02 <- get_data(key)
dat.02$date <- as.Date(dat.02$obstime)
colnames(dat.02)[9] <- c("mro_00")

# Merge main refinancing operation (new)

# Merge dates and observations
dat.03 <- merge(date.df, dat.01, by = "date", all.x = TRUE)

# Fill in NAs
dat.03$mro <- dat.03$mro_00
for (ii in 2:nrow(dat.03)) {
  if (is.na(dat.03$mro_00[ii])) {
    dat.03$mro[ii] <- dat.03$mro[ii-1]
  } else {
    dat.03$mro[ii] <- dat.03$mro_00[ii]
  }
}

# Transform date to yearmon class
dat.03$date.zoo <- as.yearmon(dat.03$date, "%b%y")

# Merge main refinancing operation (old)

# Merge dates and observations
dat.04 <- merge(date.df, dat.02, by = "date", all.x = TRUE)

# Fill in NAs
dat.04$mro <- dat.04$mro_00
for (ii in 2:nrow(dat.04)) {
  if (is.na(dat.04$mro_00[ii])) {
    dat.04$mro[ii] <- dat.04$mro[ii-1]
  } else {
    dat.04$mro[ii] <- dat.04$mro_00[ii]
  }
}

# Transform date to yearmon class
dat.04$date.zoo <- as.yearmon(dat.04$date, "%b%y")

# Mege new and old

ii <- which(dat.03$date <= as.Date("2000-06-28"))
jj <- which(dat.04$date > as.Date("2000-06-28") & dat.04$date <= as.Date("2008-10-15"))
kk <- which(dat.03$date > as.Date("2008-10-15"))

dat <- rbind(dat.03[ii,], dat.04[jj,], dat.03[kk,]) 

# Construct plot
plot <- ggplot(data = dat, mapping = aes(x = date.zoo, y = mro)) +
  geom_line(color = "black", size = 1) +
  scale_y_continuous(breaks = seq(0, 10, 0.5),
                     labels = comma_format(big.mark = ".", decimal.mark = ",")) +
  scale_x_yearmon(breaks = seq(from = min(dat$date.zoo), to = max(dat$date.zoo), by = 1),
                  minor_breaks = seq(from = min(dat$date.zoo), to = max(dat$date.zoo), by = 1),
                  format = "%b %y",
                  expand = c(0, 0)) +
  labs(title = "ECB Hauptfinanzierungsfazilität",
       subtitle = paste0(c("(Letzter Beobachtungswert: "), as.Date(dat$date[length(dat$date)]), c(")")),
       caption = "Quelle: EZB",
       x = "", y = "Prozent") +
  mod.theme.01

# Return plot
plot

Datum Wert
2024-01-30 4,5
2024-01-31 4,5
2024-02-01 4,5
2024-02-02 4,5
2024-02-03 4,5
2024-02-04 4,5
2024-02-05 4,5
2024-02-06 4,5
2024-02-07 4,5
2024-02-08 4,5

Festverzinsliche Wertpapiere

Risiko

Risiko

# Data
id.lis <- list(usa = "IRLTLT01USM156N", ger = "IRLTLT01DEM156N", ita = "IRLTLT01ITM156N")

ser.lis <- lapply(id.lis,
                  fredr,
                  observation_start = as.Date("2000-01-01"),
                  observation_end = Sys.Date(),
                  units = "lin")

# Combine series
ser.dat <- rbind(ser.lis$usa, ser.lis$ger, ser.lis$ita)

# Construct plot
plot <- ggplot(data = ser.dat, mapping = aes(x = date, y = value, color = series_id)) +
  geom_line(size = 1) +
  scale_y_continuous(breaks = seq(-2, 10, 1)) +
  scale_x_date(date_breaks = "1 years",
               date_minor_breaks = "1 years",
               date_labels = "%Y",
               expand = c(0, 0)) +
  scale_color_discrete(name = "", labels = c("DEU", "ITA", "USA")) +
  labs(title = "Rendite Staatsanleihen (10 Jahre)",
       subtitle = paste0(c("(Letzter Beobachtungswert: "), met.dat$observation_end, c(")")),
       caption = "Quelle: OECD", 
       x = "", y = "Prozent") +
  mod.theme.01

# Return plot
plot

Datum DEU ITA USA
2023-03-01 2,38 4,27 3,66
2023-04-01 2,36 4,24 3,46
2023-05-01 2,34 4,23 3,57
2023-06-01 2,38 4,31 3,75
2023-07-01 2,46 4,07 3,90
2023-08-01 2,55 4,16 4,17
2023-09-01 2,66 4,22 4,38
2023-10-01 2,82 4,51 4,80
2023-11-01 2,60 4,88 4,50
2023-12-01 2,10 4,43 4,02

Laufzeiten

Laufzeiten

# Data
id.lis <- list(y01 = "DGS1", y05 = "DGS5", y10 = "DGS10")

ser.lis <- lapply(id.lis,
                  fredr,
                  observation_start = as.Date("2000-01-01"),
                  observation_end = Sys.Date(),
                  units = "lin")

# Combine series
ser.dat <- rbind(ser.lis$y01, ser.lis$y05, ser.lis$y10)

# Construct plot
plot <- ggplot(data = ser.dat, mapping = aes(x = date, y = value, color = series_id)) +
  geom_line(size = 1) +
  scale_y_continuous(name = "Prozent", labels = comma) +
  scale_x_date(date_breaks = "1 years",
               date_minor_breaks = "1 years",
               date_labels = "%Y",
               expand = c(0, 0)) +
  scale_color_discrete(name = "", labels = c("1 Jahr", "10 Jahr", "5 Jahr")) +
  labs(title = "US Staatsanleihen (feste Laufzeit)",
       caption = "Quelle: Board of Governors of the Federal Reserve System (US)", 
       subtitle = paste0(c("(Letzter Beobachtungswert: "), met.dat$observation_end, c(")")),
       x = "", y = "Percent") +
  mod.theme.01

# Return plot
plot

Datum 1 Jahr 5 Jahre 10 Jahre
2024-01-24 4,83 4,06 4,18
2024-01-25 4,76 4,01 4,14
2024-01-26 4,78 4,04 4,15
2024-01-29 4,76 3,97 4,08
2024-01-30 4,80 4,00 4,06
2024-01-31 4,73 3,91 3,99
2024-02-01 4,68 3,80 3,87
2024-02-02 4,81 3,99 4,03
2024-02-05 4,87 4,13 4,17
2024-02-06 4,82 4,03 4,09

Wechsekurse

EUR-USD

EUR-USD

# Meta data
met.dat <- fredr_series_search_text("DEXUSEU")

# Data
ser.dat <- fredr_series_observations(series_id = met.dat$id[1],
                                     observation_start = as.Date("1999-12-31"),
                                     units = "lin")

# Construct plot
plot <- ggplot(data = ser.dat, mapping = aes(x = date, y = value)) +
  add_rec_shade(min(ser.dat$date), max(ser.dat$date), zoo.mon = FALSE, zoo.qtr = FALSE) +
  geom_line(size = 1) +
  scale_x_date(date_breaks = "1 years",
               date_minor_breaks = "1 years",
               date_labels = "%Y",
               expand = c(0, 0)) +
  scale_y_continuous(breaks = seq(0, 2, 0.1),
                     labels = comma) + 
  labs(title = "EUR-USD Kurs",
       subtitle = paste0(c("(Letzter Beobachtungswert: "), met.dat$observation_end, c(")")),
       caption = "Quelle: Board of Governors of the Federal Reserve System (US)", 
       x = "", y = "USD für einen EUR") +
  mod.theme.01

# Return plot
plot

Datum Wert
2024-01-22 1,09
2024-01-23 1,08
2024-01-24 1,09
2024-01-25 1,08
2024-01-26 1,09
2024-01-29 1,08
2024-01-30 1,08
2024-01-31 1,09
2024-02-01 1,09
2024-02-02 1,08

USD-JPY

USD-JPY

# Meta data
met.dat <- fredr_series_search_text("DEXJPUS")

# Data
ser.dat <- fredr_series_observations(series_id = met.dat$id[1],
                                     observation_start = as.Date("1999-12-31"),
                                     units = "lin")

# Construct plot
plot <- ggplot(data = ser.dat, mapping = aes(x = date, y = value)) +
  add_rec_shade(min(ser.dat$date), max(ser.dat$date), zoo.mon = FALSE, zoo.qtr = FALSE) +
  geom_line(size = 1) +
  scale_x_date(date_breaks = "1 years",
               date_minor_breaks = "1 years",
               date_labels = "%Y",
               expand = c(0, 0)) +
  scale_y_continuous(breaks = seq(0, 200, 5),
                     labels = comma) + 
  labs(title = "USD-JPY Kurs",
       subtitle = paste0(c("(Letzter Beobachtungswert: "), met.dat$observation_end, c(")")),
       caption = "Quelle: Board of Governors of the Federal Reserve System (US)", 
       x = "", y = "JPY für einen USD") +
  mod.theme.01

# Return plot
plot

Datum Wert
2024-01-22 147,95
2024-01-23 148,55
2024-01-24 147,31
2024-01-25 147,69
2024-01-26 147,94
2024-01-29 147,65
2024-01-30 147,71
2024-01-31 146,26
2024-02-01 146,18
2024-02-02 148,54

UKP-USD

UKP-USD

# Meta data
met.dat <- fredr_series_search_text("DEXUSUK")

# Data
ser.dat <- fredr_series_observations(series_id = met.dat$id[1],
                                     observation_start = as.Date("1999-12-31"),
                                     units = "lin")

# Construct plot
plot <- ggplot(data = ser.dat, mapping = aes(x = date, y = value)) +
  add_rec_shade(min(ser.dat$date), max(ser.dat$date), zoo.mon = FALSE, zoo.qtr = FALSE) +
  geom_line(size = 1) +
  scale_x_date(date_breaks = "1 years",
               date_minor_breaks = "1 years",
               date_labels = "%Y",
               expand = c(0, 0)) +
  scale_y_continuous(breaks = seq(0, 3, 0.05),
                     labels = comma) + 
  labs(title = "UKP-USD Kurs",
       subtitle = paste0(c("(Letzter Beobachtungswert: "), met.dat$observation_end, c(")")),
       caption = "Quelle: Board of Governors of the Federal Reserve System (US)", 
       x = "", y = "USD für einen UKP") +
  mod.theme.01

# Return plot
plot

Datum Wert
2024-01-22 1,27
2024-01-23 1,27
2024-01-24 1,28
2024-01-25 1,27
2024-01-26 1,27
2024-01-29 1,27
2024-01-30 1,27
2024-01-31 1,27
2024-02-01 1,27
2024-02-02 1,26


Zurück zur Startdatei