Skip to content

Commit

Permalink
Merge pull request #5 from TanguyBarthelemy/develop
Browse files Browse the repository at this point in the history
add LICENSE file and update README and description file
  • Loading branch information
clemasso authored Apr 8, 2024
2 parents de4bbaa + e6592c4 commit 5cab40a
Show file tree
Hide file tree
Showing 17 changed files with 298 additions and 98 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
^rjd3nowcasting\.Rproj$
^\.Rproj\.user$
^\.github$
^LICENSE$
^README\.Rmd$
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ Imports:
rjd3toolkit (>= 3.2.1)
Remotes:
github::rjdemetra/rjd3toolkit
SystemRequirements: Java JRE 17 or higher
SystemRequirements: Java (>= 17)
License: EUPL
Encoding: UTF-8
Collate:
'estimation.R'
'news.R'
'results.R'
'zzz.R'
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
112 changes: 112 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
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%",
fig.align = "center",
fig.dim = c(7,4) * 1.4
)
```

# rjd3nowcasting

<!-- badges: start -->
<!-- badges: end -->

## Overview

Nowcasting is often defined as the prediction of the present, the very near future and the very recent past.

rjd3nowcasting provides helps to operationalize the process of nowcasting. This first version can be used to specify and estimate dynamic factor models.
A later version is expected to include the concept of "news" similar to the [Nowcasting plugin](https://github.com/nbbrd/jdemetra-nowcasting/tree/master)
of the Graphical User Interface of JDemetra+ v2.

## Installation

To get the current stable version (from the latest release):

```{r, echo = TRUE, eval = FALSE}
# install.packages("remotes")
remotes::install_github("rjdemetra/rjd3toolkit@*release")
remotes::install_github("rjdemetra/rjd3nowcasting@*release")
```

To get the current development version from GitHub:

```{r, echo = TRUE, eval = FALSE}
# install.packages("remotes")
remotes::install_github("rjdemetra/rjd3nowcasting")
```


## Usage

```{r, echo = TRUE, eval = TRUE}
library("rjd3nowcasting")
```


### Input

```{r, echo = TRUE, eval = TRUE}
set.seed(100)
data <- ts(
data = matrix(rnorm(500), 100, 5),
frequency = 12,
start = c(2010, 1)
)
data[100, 1] <- data[99:100, 2] <- data[(1:100)[-seq(3, 100, 3)], 5] <- NA
```


### Model

```{r, echo = TRUE, eval = TRUE}
dfm_model <- model(
nfactors = 2,
nlags = 2,
factors_type = c("M", "M", "YoY", "M", "Q"),
factors_loading = matrix(data = TRUE, 5, 2),
var_init = "Unconditional"
)
```


### Estimation

```{r, echo = TRUE, eval = TRUE}
rslt_ml <- estimate_ml(dfm_model, data)
# or rslt_em<-estimate_em(dfm_model, data)
# or rslt_pca<-estimate_pca(dfm_model, data)
```


### Results

```{r, echo = TRUE, eval = TRUE}
fcst <- get_forecasts(rslt_ml, nf = 2, forecasts_only = TRUE)
params <- get_parameters(rslt_ml)
factors <- get_factors(rslt_ml)
# ...
print(rslt_ml)
summary(rslt_ml)
plot(rslt_ml)
```


## Contributing

Any contribution is welcome and should be done through pull requests and/or issues.


## Licensing

The code of this project is licensed under the [European Union Public Licence (EUPL)](https://joinup.ec.europa.eu/page/eupl-text-11-12).
101 changes: 83 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

# rjd3nowcasting

<!-- badges: start -->
<!-- badges: end -->

## Overview

Nowcasting is often defined as the prediction of the present, the very near future and the very recent past.
Nowcasting is often defined as the prediction of the present, the very
near future and the very recent past.

rjd3nowcasting provides helps to operationalize the process of nowcasting. This first version can be used to specify and estimate dynamic factor models.
A later version is expected to include the concept of "news" similar to the [Nowcasting plugin](https://github.com/nbbrd/jdemetra-nowcasting/tree/master)
of the Graphical User Interface of JDemetra+ v2.
rjd3nowcasting provides helps to operationalize the process of
nowcasting. This first version can be used to specify and estimate
dynamic factor models. A later version is expected to include the
concept of “news” similar to the [Nowcasting
plugin](https://github.com/nbbrd/jdemetra-nowcasting/tree/master) of the
Graphical User Interface of JDemetra+ v2.

## Installation

Expand All @@ -25,38 +37,91 @@ remotes::install_github("rjdemetra/rjd3nowcasting")

## Usage

``` r
library("rjd3nowcasting")
```

### Input

``` r
set.seed(100)
data<-ts(matrix(rnorm(500), 100, 5), frequency = 12, start = c(2010,1))
data[100,1]<-data[99:100,2]<-data[(1:100)[-seq(3,100,3)],5]<-NA
data <- ts(
data = matrix(rnorm(500), 100, 5),
frequency = 12,
start = c(2010, 1)
)
data[100, 1] <- data[99:100, 2] <- data[(1:100)[-seq(3, 100, 3)], 5] <- NA
```

### Model

``` r
dfm_model <- rjd3nowcasting::model(nfactors=2,
nlags=2,
factors_type = c("M", "M", "YoY", "M", "Q"),
factors_loading = matrix(data=TRUE, 5, 2),
var_init = "Unconditional")
dfm_model <- model(
nfactors = 2,
nlags = 2,
factors_type = c("M", "M", "YoY", "M", "Q"),
factors_loading = matrix(data = TRUE, 5, 2),
var_init = "Unconditional"
)
```

### Estimation

``` r
rslt_ml<-rjd3nowcasting::estimate_ml(dfm_model, data)
# or rslt_em<-rjd3nowcasting::estimate_em(dfm_model, data)
# or rslt_pca<-rjd3nowcasting::estimate_pca(dfm_model, data)
rslt_ml <- estimate_ml(dfm_model, data)
# or rslt_em<-estimate_em(dfm_model, data)
# or rslt_pca<-estimate_pca(dfm_model, data)
```

### Results

``` r
fcst<-rjd3nowcasting::get_forecasts(rslt_ml,nf = 2,forecasts_only = TRUE)
params<-rjd3nowcasting::get_parameters(rslt_ml)
factors<-rjd3nowcasting::get_factors(rslt_ml)
#...
fcst <- get_forecasts(rslt_ml, nf = 2, forecasts_only = TRUE)
params <- get_parameters(rslt_ml)
factors <- get_factors(rslt_ml)
# ...

print(rslt_ml)
#> Measurement:
#> Sample mean Sample Stdev Coeff. of normalized factor F1
#> Series 1 0.01480 1.01376 0.11234
#> Series 2 0.01656 0.79045 -0.07066
#> Series 3 0.01279 1.03407 0.00171
#> Series 4 -0.08325 1.07544 -0.00624
#> Series 5 -0.21205 1.06909 -0.00302
#> Coeff. of normalized factor F2 Idiosyncratic variance
#> Series 1 0.55341 0.41091
#> Series 2 -0.06925 0.93488
#> Series 3 0.04849 0.98831
#> Series 4 0.03340 0.99792
#> Series 5 -0.33934 0.00000
#>
#> State:
#> VAR coefficients:
#> F1[-1] F2[-1] F1[-2] F2[-2]
#> F1 1.44836 -0.97181 -0.76117 1.23216
#> F2 -0.02442 -0.59011 -0.02834 -0.09459
#>
#> Innovative variance:
#> F1 F2
#> F1 1 -1
#> F2 -1 1
summary(rslt_ml)
#> Nowcasted values (only):
#> Series 1 Series 2 Series 3 Series 4 Series 5
#> Mar 2018 NA 0.3198988965 NA NA NA
#> Apr 2018 0.1827459 0.0001724063 NA NA -2.427725
plot(rslt_ml)
```

<img src="man/figures/README-unnamed-chunk-8-1.png" width="100%" style="display: block; margin: auto;" />

## Contributing

Any contribution is welcome and should be done through pull requests
and/or issues.

## Licensing

The code of this project is licensed under the [European Union Public
Licence (EUPL)](https://joinup.ec.europa.eu/page/eupl-text-11-12).
18 changes: 10 additions & 8 deletions man/estimate_em.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions man/estimate_ml.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions man/estimate_pca.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added man/figures/README-unnamed-chunk-7-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added man/figures/README-unnamed-chunk-8-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 10 additions & 8 deletions man/get_factors.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions man/get_forecasts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5cab40a

Please sign in to comment.