Data is based on ECB estimates of the Euro Area Yield Curve based on the Svensson Model.
library(xts)
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
library(tidyverse)
## Loading tidyverse: ggplot2
## Loading tidyverse: tibble
## Loading tidyverse: tidyr
## Loading tidyverse: readr
## Loading tidyverse: purrr
## Loading tidyverse: dplyr
## Conflicts with tidy packages ----------------------------------------------
## filter(): dplyr, stats
## first(): dplyr, xts
## lag(): dplyr, stats
## last(): dplyr, xts
library(YieldCurve)
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
df <- readr::read_csv(
"data.csv", skip = 5,
col_names = c("date", "b0", "b1", "b2", "b3", "t1", "t2")
)
## Parsed with column specification:
## cols(
## date = col_date(format = ""),
## b0 = col_double(),
## b1 = col_double(),
## b2 = col_double(),
## b3 = col_double(),
## t1 = col_double(),
## t2 = col_double()
## )
dxts <- xts(df[,2:7], order.by = df$date)
maturity = c(0.25,0.5,seq(1,30,by = 1))
rate <- Srates(dxts, maturity)
plot_ly(
type = 'surface',
colorscale = 'Virdis',
z = rate,
y = index(rate),
x = colnames(rate)
) %>%
layout(
title = "Euro-Area Yield Curve",
scene = list(
aspectmode = 'manual',
aspectratio = list(x = 0.5, y = 1, z = 0.5),
camera = list(
eye = list(x = -1, y = 1, z = 0.5)
)
)
)