-
Notifications
You must be signed in to change notification settings - Fork 3
/
README.Rmd
113 lines (92 loc) · 3.85 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
---
output:
html_document:
variant: markdown_github
keep_md: true
md_document:
variant: markdown_github
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo=FALSE}
library(knitr)
opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
fig.align = "center",
fig.retina = 2,
out.width = "75%",
dpi = 96
)
knit_hooks$set(pngquant = hook_pngquant)
```
# imputeFin
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/imputeFin)](https://CRAN.R-project.org/package=imputeFin)
[![CRAN Downloads](https://cranlogs.r-pkg.org/badges/imputeFin)](https://CRAN.R-project.org/package=imputeFin)
[![CRAN Downloads Total](https://cranlogs.r-pkg.org/badges/grand-total/imputeFin?color=brightgreen)](https://CRAN.R-project.org/package=imputeFin)
Missing values often occur in financial data due to a variety
of reasons (errors in the collection process or in the processing stage,
lack of asset liquidity, lack of reporting of funds, etc.). However,
most data analysis methods expect complete data and cannot be employed
with missing values. One convenient way to deal with this issue without
having to redesign the data analysis method is to impute the missing
values. This package provides an efficient way to impute the missing
values based on modeling the time series with a random walk or an
autoregressive (AR) model, convenient to model log-prices and log-volumes
in financial data. In the current version, the imputation is
univariate-based (so no asset correlation is used). In addition,
outliers can be detected and removed.
The package is based on the papers:
J. Liu, S. Kumar, and D. P. Palomar (2019). Parameter Estimation of
Heavy-Tailed AR Model With Missing Data Via Stochastic EM. _IEEE Trans. on
Signal Processing_, vol. 67, no. 8, pp. 2159-2172.
https://doi.org/10.1109/TSP.2019.2899816
R. Zhou, J. Liu, S. Kumar, and D. P. Palomar (2020). Student’s t VAR Modeling
with Missing Data via Stochastic EM and Gibbs Sampling. _IEEE Trans. on
Signal Processing_, vol. 68, pp. 6198-6211
https://doi.org/10.1109/TSP.2020.3033378
## Installation
The package can be installed from [CRAN](https://CRAN.R-project.org/package=imputeFin) or [GitHub](https://github.com/dppalomar/imputeFin):
```{r, eval=FALSE}
# install stable version from CRAN
install.packages("imputeFin")
# install development version from GitHub
devtools::install_github("dppalomar/imputeFin")
```
To get help:
```{r, eval=FALSE}
library(imputeFin)
help(package = "imputeFin")
?impute_AR1_Gaussian
vignette("ImputeFinancialTimeSeries", package = "imputeFin")
RShowDoc("ImputeFinancialTimeSeries", package = "imputeFin")
```
To cite package `imputeFin` or the base reference in publications:
```{r, eval=FALSE}
citation("imputeFin")
```
## Quick Start
Let's load some time series data with missing values for illustration purposes:
```{r, message=FALSE}
library(imputeFin)
data(ts_AR1_t)
names(ts_AR1_t)
```
We can then impute one of the time series and plot it:
```{r, echo=FALSE}
set.seed(42)
```
```{r, warning=FALSE, fig.width=9, fig.height=5, out.width = "80%"}
y_missing <- ts_AR1_t$y_missing[, 3, drop = FALSE]
y_missing[100] <- 2*y_missing[100] # create an outlier
plot_imputed(y_missing, title = "Original time series with missing values and one outlier")
y_imputed <- impute_AR1_t(y_missing, remove_outliers = TRUE)
plot_imputed(y_imputed)
```
## Documentation
For more detailed information, please check the
[vignette](https://CRAN.R-project.org/package=imputeFin/vignettes/ImputeFinancialTimeSeries.html).
## Links
Package: [CRAN](https://CRAN.R-project.org/package=imputeFin) and [GitHub](https://github.com/dppalomar/imputeFin).
README file: [GitHub-readme](https://github.com/dppalomar/imputeFin/blob/master/README.md).
Vignette: [CRAN-vignette](https://CRAN.R-project.org/package=imputeFin/vignettes/ImputeFinancialTimeSeries.html).