-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathREADME.Rmd
128 lines (99 loc) · 3.46 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# ycevo
<!-- badges: start -->
[](https://github.com/bonsook/ycevo/actions/workflows/R-CMD-check.yaml)
[](https://CRAN.R-project.org/package=ycevo)
[](https://www.gnu.org/licenses/gpl-3.0.en.html)
<!-- [](https://cran.r-project.org/package=ycevo) -->
<!-- badges: end -->
The goal of `ycevo` is to provide means for the non-parametric estimation of the discount function and yield curve of bonds.
If you use any data or code from the `ycevo` package CRAN release in a publication, please use the following citation:
> Bonsoo Koo, and Yangzhuoran Fin Yang (2024). ycevo: Non-Parametric Estimation
of the Yield Curve Evolution. R package version 0.2.1. https://CRAN.R-project.org/package=ycevo.
The package provides code used in Koo, La Vecchia, & Linton (2021). Please use the following citation if you use any result from the paper.
> Koo, B., La Vecchia, D., & Linton, O. (2021). Estimation of a nonparametric model for bond prices from cross-section and time series information. Journal of Econometrics, 220(2), 562-588.
## Development cycle
The package is in active development and it have been experiencing substantial changes.
Since the existing forks have remained inactive for several years, significant modifications have been implemented through rebase. It is advisable for any existing forks to undergo the rebase process.
```
git remote add upstream https://github.com/bonsook/ycevo.git
git fetch upstream
git rebase upstream/master
git push origin master --force
```
## Installation
You can install the __released__ version of ycevo from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("ycevo")
```
You can install the __development__ version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("bonsook/ycevo")
```
## Usage
```{r}
library(ycevo)
library(lubridate)
## Simulate
set.seed(1)
bonds <- ycevo_data()
bonds
```
```{r}
#| eval: false
## Estimate at specified time points
x <- seq(ymd("2023-03-01"), ymd("2023-08-01"), by = "1 month")
res <- ycevo(bonds, x)
## Supports parallel processing and progress bar
# future::plan(future::multisession)
# res <- progressr::with_progress(ycevo(bonds, x))
```
```{r}
#| echo: false
x <- seq(ymd("2023-03-01"), ymd("2023-08-01"), by = "1 month")
future::plan(future::multisession)
res <- ycevo(bonds, x)
```
```{r}
res
```
```{r}
## Predict
augment(res)
## Plot
autoplot(res)
```
```{r}
#| eval: false
## Compare to the true yield curve
curve_true <- list()
for(i in seq_along(x)) {
curve_true[[i]] <- tibble(
tau=1:20,
qdate = x[[i]],
.yield = get_yield_at((x[[i]] - ymd("2023-01-01"))/365, tau),
.discount = exp(-tau * .yield))
}
curve_true <- bind_rows(curve_true)
curve_true <- pivot_longer(
curve_true,
c(.discount, .yield),
names_to = ".est",
values_to = ".value")
autoplot(res) +
geom_line(data = curve_true, linetype = "dashed")
```
## License
This package is free and open source software, licensed under GPL-3