├── .Rbuildignore ├── .github ├── .gitignore └── workflows │ ├── R-CMD-check.yaml │ ├── pkgdown.yaml │ └── test-coverage.yaml ├── .gitignore ├── DESCRIPTION ├── LICENSE ├── LICENSE.md ├── NAMESPACE ├── NEWS.md ├── R ├── bflSmooth.R ├── data.R ├── disaggR.R ├── in.R ├── methods.R ├── plot.R ├── praislm.R ├── reView.R ├── s4register.R ├── threeRuleSmooth.R ├── twoStepsBenchmark.R └── utils.R ├── README.Rmd ├── README.md ├── _pkgdown.yml ├── codecov.yml ├── data ├── construction.RData ├── consumption_catering.RData ├── turnover.RData └── turnover_catering.RData ├── disaggR.Rproj ├── inst └── rmd │ ├── report.Rmd │ ├── report.css │ └── report_nocompare.Rmd ├── man ├── bflSmooth.Rd ├── bflSmooth_matrices_factory.Rd ├── construction.Rd ├── consumption_catering.Rd ├── default_col_pal.Rd ├── default_lty_pal.Rd ├── default_margins.Rd ├── default_theme_ggplot.Rd ├── disaggR-class.Rd ├── disaggR-package.Rd ├── distance.Rd ├── extend_tsp.Rd ├── figures │ ├── README-fi-1.png │ ├── README-unnamed-chunk-3-1.png │ ├── README-unnamed-chunk-3-2.png │ ├── README-unnamed-chunk-4-1.png │ ├── README-unnamed-chunk-4-2.png │ ├── README-unnamed-chunk-5-1.png │ ├── README-unnamed-chunk-5-2.png │ ├── README-unnamed-chunk-6-1.png │ ├── README-unnamed-chunk-6-2.png │ └── shiny-screen.jpg ├── hfserie_extrap.Rd ├── in_disaggr.Rd ├── in_revisions.Rd ├── in_sample.Rd ├── in_scatter.Rd ├── model.list.Rd ├── outliers.Rd ├── plot.tscomparison.Rd ├── prais.Rd ├── rePort.Rd ├── reUseBenchmark.Rd ├── reView.Rd ├── residuals_extrap.Rd ├── rho.Rd ├── se.Rd ├── smoothed.part.Rd ├── smoothed.rate.Rd ├── threeRuleSmooth.Rd ├── turnover.Rd ├── turnover_catering.Rd └── twoStepsBenchmark.Rd ├── tests ├── testthat.R └── testthat │ ├── _snaps │ ├── in.md │ ├── methods.md │ ├── methods │ │ ├── monthplot-threerulesmooth.svg │ │ └── monthplot-twostepsbenchmark.svg │ ├── plot │ │ ├── gg-benchmark-2008-4-2012-7-gt44.svg │ │ ├── gg-benchmark-2008-4-2012-7-lt43.svg │ │ ├── gg-benchmark-lab-bar-gt44.svg │ │ ├── gg-benchmark-lab-bar-lt43.svg │ │ ├── gg-benchmark-lab-foo-bar-gt44.svg │ │ ├── gg-benchmark-lab-foo-bar-lt43.svg │ │ ├── gg-benchmark-lab-foo-gt44.svg │ │ ├── gg-benchmark-lab-foo-lt43.svg │ │ ├── gg-benchmark-nowin-gt44.svg │ │ ├── gg-benchmark-nowin-lt43.svg │ │ ├── gg-benchmark-showlegendf-gt44.svg │ │ ├── gg-benchmark-showlegendf-lt43.svg │ │ ├── gg-ctb-showlegendf-gt44.svg │ │ ├── gg-ctb-showlegendf-lt43.svg │ │ ├── gg-indicator-changes-2008-4-2012-7-gt44.svg │ │ ├── gg-indicator-changes-2008-4-2012-7-lt43.svg │ │ ├── gg-indicator-changes-2008-4-2012-7-smooth-gt44.svg │ │ ├── gg-indicator-changes-2008-4-2012-7-smooth-lt43.svg │ │ ├── gg-indicator-changes-nowin-gt44.svg │ │ ├── gg-indicator-changes-nowin-lt43.svg │ │ ├── gg-indicator-changes-nowin-smooth-gt44.svg │ │ ├── gg-indicator-changes-nowin-smooth-lt43.svg │ │ ├── gg-indicator-contributions-2008-4-2012-7-gt44.svg │ │ ├── gg-indicator-contributions-2008-4-2012-7-lt43.svg │ │ ├── gg-indicator-contributions-2008-4-2012-7-smooth-gt44.svg │ │ ├── gg-indicator-contributions-2008-4-2012-7-smooth-lt43.svg │ │ ├── gg-indicator-contributions-nowin-gt44.svg │ │ ├── gg-indicator-contributions-nowin-lt43.svg │ │ ├── gg-indicator-contributions-nowin-smooth-gt44.svg │ │ ├── gg-indicator-contributions-nowin-smooth-lt43.svg │ │ ├── gg-indicator-levels-2008-4-2012-7-gt44.svg │ │ ├── gg-indicator-levels-2008-4-2012-7-lt43.svg │ │ ├── gg-indicator-levels-2008-4-2012-7-smooth-gt44.svg │ │ ├── gg-indicator-levels-2008-4-2012-7-smooth-lt43.svg │ │ ├── gg-indicator-levels-nowin-gt44.svg │ │ ├── gg-indicator-levels-nowin-lt43.svg │ │ ├── gg-indicator-levels-nowin-smooth-gt44.svg │ │ ├── gg-indicator-levels-nowin-smooth-lt43.svg │ │ ├── gg-indicator-levels-rebased-2008-4-2012-7-gt44.svg │ │ ├── gg-indicator-levels-rebased-2008-4-2012-7-lt43.svg │ │ ├── gg-indicator-levels-rebased-2008-4-2012-7-smooth-gt44.svg │ │ ├── gg-indicator-levels-rebased-2008-4-2012-7-smooth-lt43.svg │ │ ├── gg-indicator-levels-rebased-nowin-gt44.svg │ │ ├── gg-indicator-levels-rebased-nowin-lt43.svg │ │ ├── gg-indicator-levels-rebased-nowin-smooth-gt44.svg │ │ ├── gg-indicator-levels-rebased-nowin-smooth-lt43.svg │ │ ├── gg-indicator-showlegendf-gt44.svg │ │ ├── gg-indicator-showlegendf-lt43.svg │ │ ├── gg-inrevisions-changes-2008-4-2012-7-gt44.svg │ │ ├── gg-inrevisions-changes-2008-4-2012-7-lt43.svg │ │ ├── gg-inrevisions-changes-2008-4-2012-7-smooth-gt44.svg │ │ ├── gg-inrevisions-changes-2008-4-2012-7-smooth-lt43.svg │ │ ├── gg-inrevisions-changes-nowin-gt44.svg │ │ ├── gg-inrevisions-changes-nowin-lt43.svg │ │ ├── gg-inrevisions-changes-nowin-smooth-gt44.svg │ │ ├── gg-inrevisions-changes-nowin-smooth-lt43.svg │ │ ├── gg-inrevisions-contributions-2008-4-2012-7-gt44.svg │ │ ├── gg-inrevisions-contributions-2008-4-2012-7-lt43.svg │ │ ├── gg-inrevisions-contributions-2008-4-2012-7-smooth-gt44.svg │ │ ├── gg-inrevisions-contributions-2008-4-2012-7-smooth-lt43.svg │ │ ├── gg-inrevisions-contributions-nowin-gt44.svg │ │ ├── gg-inrevisions-contributions-nowin-lt43.svg │ │ ├── gg-inrevisions-contributions-nowin-smooth-gt44.svg │ │ ├── gg-inrevisions-contributions-nowin-smooth-lt43.svg │ │ ├── gg-inrevisions-levels-2008-4-2012-7-gt44.svg │ │ ├── gg-inrevisions-levels-2008-4-2012-7-lt43.svg │ │ ├── gg-inrevisions-levels-2008-4-2012-7-smooth-gt44.svg │ │ ├── gg-inrevisions-levels-2008-4-2012-7-smooth-lt43.svg │ │ ├── gg-inrevisions-levels-nowin-gt44.svg │ │ ├── gg-inrevisions-levels-nowin-lt43.svg │ │ ├── gg-inrevisions-levels-nowin-smooth-gt44.svg │ │ ├── gg-inrevisions-levels-nowin-smooth-lt43.svg │ │ ├── gg-inrevisions-levels-rebased-2008-4-2012-7-gt44.svg │ │ ├── gg-inrevisions-levels-rebased-2008-4-2012-7-lt43.svg │ │ ├── gg-inrevisions-levels-rebased-2008-4-2012-7-smooth-gt44.svg │ │ ├── gg-inrevisions-levels-rebased-2008-4-2012-7-smooth-lt43.svg │ │ ├── gg-inrevisions-levels-rebased-nowin-gt44.svg │ │ ├── gg-inrevisions-levels-rebased-nowin-lt43.svg │ │ ├── gg-inrevisions-levels-rebased-nowin-smooth-gt44.svg │ │ ├── gg-inrevisions-levels-rebased-nowin-smooth-lt43.svg │ │ ├── gg-inrevisions-showlegendf-gt44.svg │ │ ├── gg-inrevisions-showlegendf-lt43.svg │ │ ├── gg-insample-changes-2008-2012-gt44.svg │ │ ├── gg-insample-changes-2008-2012-lt43.svg │ │ ├── gg-insample-changes-nowin-gt44.svg │ │ ├── gg-insample-changes-nowin-lt43.svg │ │ ├── gg-insample-levels-2008-2012-gt44.svg │ │ ├── gg-insample-levels-2008-2012-lt43.svg │ │ ├── gg-insample-levels-nowin-gt44.svg │ │ ├── gg-insample-levels-nowin-lt43.svg │ │ ├── gg-insample-showlegendf-gt44.svg │ │ ├── gg-insample-showlegendf-lt43.svg │ │ ├── gg-main-ctb-smooth-gt44.svg │ │ ├── gg-main-ctb-smooth-lt43.svg │ │ ├── gg-main-inrev-smooth-gt44.svg │ │ ├── gg-main-inrev-smooth-lt43.svg │ │ ├── gg-main-insample-gt44.svg │ │ ├── gg-main-insample-lt43.svg │ │ ├── gg-main-scatter-smooth-gt44.svg │ │ ├── gg-main-scatter-smooth-lt43.svg │ │ ├── gg-mts-ctb-gt44.svg │ │ ├── gg-mts-ctb-lt43.svg │ │ ├── gg-mts-indic-gt44.svg │ │ ├── gg-mts-indic-lt43.svg │ │ ├── gg-mts-ins-gt44.svg │ │ ├── gg-mts-ins-lt43.svg │ │ ├── gg-mts-rev-gt44.svg │ │ ├── gg-mts-rev-lt43.svg │ │ ├── gg-nowin-smooth-gt44.svg │ │ ├── gg-nowin-smooth-lt43.svg │ │ ├── gg-plot-main-ctb-gt44.svg │ │ ├── gg-plot-main-ctb-lt43.svg │ │ ├── gg-plot-main-inrev-gt44.svg │ │ ├── gg-plot-main-inrev-lt43.svg │ │ ├── gg-plot-main-scatter-gt44.svg │ │ ├── gg-plot-main-scatter-lt43.svg │ │ ├── gg-plot-scatter-2008-2012-gt44.svg │ │ ├── gg-plot-scatter-2008-2012-lt43.svg │ │ ├── gg-plot-scatter-coeff-2008-2012-gt44.svg │ │ ├── gg-plot-scatter-coeff-2008-2012-lt43.svg │ │ ├── gg-scatter-2008-2012-smooth-gt44.svg │ │ ├── gg-scatter-2008-2012-smooth-lt43.svg │ │ ├── gg-scatter-showlegendf-gt44.svg │ │ ├── gg-scatter-showlegendf-lt43.svg │ │ ├── gg-smooth-2008-4-2012-7-smooth-gt44.svg │ │ ├── gg-smooth-2008-4-2012-7-smooth-lt43.svg │ │ ├── ggplot-indicator-changes-outlier-gt44.svg │ │ ├── ggplot-indicator-changes-outlier-lt43.svg │ │ ├── ggplot-indicator-contributions-outlier-gt44.svg │ │ ├── ggplot-indicator-contributions-outlier-lt43.svg │ │ ├── ggplot-indicator-levels-outlier-gt44.svg │ │ ├── ggplot-indicator-levels-outlier-lt43.svg │ │ ├── ggplot-indicator-levels-rebased-outlier-gt44.svg │ │ ├── ggplot-indicator-levels-rebased-outlier-lt43.svg │ │ ├── no-labels-outside-plot-margins-gt44.svg │ │ ├── no-labels-outside-plot-margins-lt43.svg │ │ ├── plot-benchmark-2008-4-2012-7-gt44.svg │ │ ├── plot-benchmark-2008-4-2012-7-lt43.svg │ │ ├── plot-benchmark-lab-bar-gt44.svg │ │ ├── plot-benchmark-lab-bar-lt43.svg │ │ ├── plot-benchmark-lab-foo-bar-gt44.svg │ │ ├── plot-benchmark-lab-foo-bar-lt43.svg │ │ ├── plot-benchmark-lab-foo-gt44.svg │ │ ├── plot-benchmark-lab-foo-lt43.svg │ │ ├── plot-benchmark-nowin-gt44.svg │ │ ├── plot-benchmark-nowin-lt43.svg │ │ ├── plot-benchmark-showlegendf-gt44.svg │ │ ├── plot-benchmark-showlegendf-lt43.svg │ │ ├── plot-ctb-showlegendf-gt44.svg │ │ ├── plot-ctb-showlegendf-lt43.svg │ │ ├── plot-indicator-changes-2008-4-2012-7-gt44.svg │ │ ├── plot-indicator-changes-2008-4-2012-7-lt43.svg │ │ ├── plot-indicator-changes-2008-4-2012-7-smooth-gt44.svg │ │ ├── plot-indicator-changes-2008-4-2012-7-smooth-lt43.svg │ │ ├── plot-indicator-changes-nowin-gt44.svg │ │ ├── plot-indicator-changes-nowin-lt43.svg │ │ ├── plot-indicator-changes-nowin-smooth-gt44.svg │ │ ├── plot-indicator-changes-nowin-smooth-lt43.svg │ │ ├── plot-indicator-changes-outlier-gt44.svg │ │ ├── plot-indicator-changes-outlier-lt43.svg │ │ ├── plot-indicator-contributions-2008-4-2012-7-gt44.svg │ │ ├── plot-indicator-contributions-2008-4-2012-7-lt43.svg │ │ ├── plot-indicator-contributions-2008-4-2012-7-smooth-gt44.svg │ │ ├── plot-indicator-contributions-2008-4-2012-7-smooth-lt43.svg │ │ ├── plot-indicator-contributions-nowin-gt44.svg │ │ ├── plot-indicator-contributions-nowin-lt43.svg │ │ ├── plot-indicator-contributions-nowin-smooth-gt44.svg │ │ ├── plot-indicator-contributions-nowin-smooth-lt43.svg │ │ ├── plot-indicator-contributions-outlier-gt44.svg │ │ ├── plot-indicator-contributions-outlier-lt43.svg │ │ ├── plot-indicator-levels-2008-4-2012-7-gt44.svg │ │ ├── plot-indicator-levels-2008-4-2012-7-lt43.svg │ │ ├── plot-indicator-levels-2008-4-2012-7-smooth-gt44.svg │ │ ├── plot-indicator-levels-2008-4-2012-7-smooth-lt43.svg │ │ ├── plot-indicator-levels-nowin-gt44.svg │ │ ├── plot-indicator-levels-nowin-lt43.svg │ │ ├── plot-indicator-levels-nowin-smooth-gt44.svg │ │ ├── plot-indicator-levels-nowin-smooth-lt43.svg │ │ ├── plot-indicator-levels-outlier-gt44.svg │ │ ├── plot-indicator-levels-outlier-lt43.svg │ │ ├── plot-indicator-levels-rebased-2008-4-2012-7-gt44.svg │ │ ├── plot-indicator-levels-rebased-2008-4-2012-7-lt43.svg │ │ ├── plot-indicator-levels-rebased-2008-4-2012-7-smooth-gt44.svg │ │ ├── plot-indicator-levels-rebased-2008-4-2012-7-smooth-lt43.svg │ │ ├── plot-indicator-levels-rebased-nowin-gt44.svg │ │ ├── plot-indicator-levels-rebased-nowin-lt43.svg │ │ ├── plot-indicator-levels-rebased-nowin-smooth-gt44.svg │ │ ├── plot-indicator-levels-rebased-nowin-smooth-lt43.svg │ │ ├── plot-indicator-levels-rebased-outlier-gt44.svg │ │ ├── plot-indicator-levels-rebased-outlier-lt43.svg │ │ ├── plot-indicator-showlegendf-gt44.svg │ │ ├── plot-indicator-showlegendf-lt43.svg │ │ ├── plot-indisaggr-par-benchmark-ctb-gt44.svg │ │ ├── plot-indisaggr-par-benchmark-ctb-lt43.svg │ │ ├── plot-indisaggr-par-benchmark-gt44.svg │ │ ├── plot-indisaggr-par-benchmark-lt43.svg │ │ ├── plot-inrevisions-changes-2008-4-2012-7-gt44.svg │ │ ├── plot-inrevisions-changes-2008-4-2012-7-lt43.svg │ │ ├── plot-inrevisions-changes-2008-4-2012-7-smooth-gt44.svg │ │ ├── plot-inrevisions-changes-2008-4-2012-7-smooth-lt43.svg │ │ ├── plot-inrevisions-changes-nowin-gt44.svg │ │ ├── plot-inrevisions-changes-nowin-lt43.svg │ │ ├── plot-inrevisions-changes-nowin-smooth-gt44.svg │ │ ├── plot-inrevisions-changes-nowin-smooth-lt43.svg │ │ ├── plot-inrevisions-contributions-2008-4-2012-7-gt44.svg │ │ ├── plot-inrevisions-contributions-2008-4-2012-7-lt43.svg │ │ ├── plot-inrevisions-contributions-2008-4-2012-7-smooth-gt44.svg │ │ ├── plot-inrevisions-contributions-2008-4-2012-7-smooth-lt43.svg │ │ ├── plot-inrevisions-contributions-nowin-gt44.svg │ │ ├── plot-inrevisions-contributions-nowin-lt43.svg │ │ ├── plot-inrevisions-contributions-nowin-smooth-gt44.svg │ │ ├── plot-inrevisions-contributions-nowin-smooth-lt43.svg │ │ ├── plot-inrevisions-levels-2008-4-2012-7-gt44.svg │ │ ├── plot-inrevisions-levels-2008-4-2012-7-lt43.svg │ │ ├── plot-inrevisions-levels-2008-4-2012-7-smooth-gt44.svg │ │ ├── plot-inrevisions-levels-2008-4-2012-7-smooth-lt43.svg │ │ ├── plot-inrevisions-levels-nowin-gt44.svg │ │ ├── plot-inrevisions-levels-nowin-lt43.svg │ │ ├── plot-inrevisions-levels-nowin-smooth-gt44.svg │ │ ├── plot-inrevisions-levels-nowin-smooth-lt43.svg │ │ ├── plot-inrevisions-levels-rebased-2008-4-2012-7-gt44.svg │ │ ├── plot-inrevisions-levels-rebased-2008-4-2012-7-lt43.svg │ │ ├── plot-inrevisions-levels-rebased-2008-4-2012-7-smooth-gt44.svg │ │ ├── plot-inrevisions-levels-rebased-2008-4-2012-7-smooth-lt43.svg │ │ ├── plot-inrevisions-levels-rebased-nowin-gt44.svg │ │ ├── plot-inrevisions-levels-rebased-nowin-lt43.svg │ │ ├── plot-inrevisions-levels-rebased-nowin-smooth-gt44.svg │ │ ├── plot-inrevisions-levels-rebased-nowin-smooth-lt43.svg │ │ ├── plot-inrevisions-showlegendf-gt44.svg │ │ ├── plot-inrevisions-showlegendf-lt43.svg │ │ ├── plot-insample-changes-2008-2012-gt44.svg │ │ ├── plot-insample-changes-2008-2012-lt43.svg │ │ ├── plot-insample-changes-nowin-gt44.svg │ │ ├── plot-insample-changes-nowin-lt43.svg │ │ ├── plot-insample-levels-2008-2012-gt44.svg │ │ ├── plot-insample-levels-2008-2012-lt43.svg │ │ ├── plot-insample-levels-nowin-gt44.svg │ │ ├── plot-insample-levels-nowin-lt43.svg │ │ ├── plot-insample-par-benchmark-gt44.svg │ │ ├── plot-insample-par-benchmark-lt43.svg │ │ ├── plot-insample-showlegendf-gt44.svg │ │ ├── plot-insample-showlegendf-lt43.svg │ │ ├── plot-inscatter-par-benchmark-gt44.svg │ │ ├── plot-inscatter-par-benchmark-lt43.svg │ │ ├── plot-main-ctb-gt44.svg │ │ ├── plot-main-ctb-lt43.svg │ │ ├── plot-main-ctb-smooth-gt44.svg │ │ ├── plot-main-ctb-smooth-lt43.svg │ │ ├── plot-main-inrev-gt44.svg │ │ ├── plot-main-inrev-lt43.svg │ │ ├── plot-main-inrev-smooth-gt44.svg │ │ ├── plot-main-inrev-smooth-lt43.svg │ │ ├── plot-main-insample-gt44.svg │ │ ├── plot-main-insample-lt43.svg │ │ ├── plot-main-scatter-gt44.svg │ │ ├── plot-main-scatter-lt43.svg │ │ ├── plot-main-scatter-smooth-gt44.svg │ │ ├── plot-main-scatter-smooth-lt43.svg │ │ ├── plot-mts-ctb-gt44.svg │ │ ├── plot-mts-ctb-lt43.svg │ │ ├── plot-mts-ind-gt44.svg │ │ ├── plot-mts-ind-lt43.svg │ │ ├── plot-mts-ins-gt44.svg │ │ ├── plot-mts-ins-lt43.svg │ │ ├── plot-mts-rev-gt44.svg │ │ ├── plot-mts-rev-lt43.svg │ │ ├── plot-nowin-smooth-gt44.svg │ │ ├── plot-nowin-smooth-lt43.svg │ │ ├── plot-par-benchmark-gt44.svg │ │ ├── plot-par-benchmark-lt43.svg │ │ ├── plot-par-benchmark-outside-gt44.svg │ │ ├── plot-par-benchmark-outside-lt43.svg │ │ ├── plot-scatter-2008-2012-gt44.svg │ │ ├── plot-scatter-2008-2012-lt43.svg │ │ ├── plot-scatter-2008-2012-smooth-gt44.svg │ │ ├── plot-scatter-2008-2012-smooth-lt43.svg │ │ ├── plot-scatter-coeff-2008-2012-gt44.svg │ │ ├── plot-scatter-coeff-2008-2012-lt43.svg │ │ ├── plot-scatter-showlegendf-gt44.svg │ │ ├── plot-scatter-showlegendf-lt43.svg │ │ ├── plot-smooth-2008-4-2012-7-smooth-gt44.svg │ │ └── plot-smooth-2008-4-2012-7-smooth-lt43.svg │ ├── threeRuleSmooth.md │ └── twoStepsBenchmark.md │ ├── shiny-outliers │ └── app.R │ ├── shiny-outlierssetcoef │ └── app.R │ ├── shiny-setcoefconst │ └── app.R │ ├── shiny-withoutset │ └── app.R │ ├── test-bflSmooth.R │ ├── test-in.R │ ├── test-methods.R │ ├── test-plot.R │ ├── test-praislm.R │ ├── test-reView.R │ ├── test-threeRuleSmooth.R │ └── test-twoStepsBenchmark.R └── vignettes ├── .gitignore ├── disaggr.Rmd └── disaggr_outlier.Rmd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^\.travis\.yml$ 4 | ^\.github$ 5 | ^README\.Rmd$ 6 | ^LICENSE\.md$ 7 | ^doc$ 8 | ^Meta$ 9 | ^_pkgdown\.yml$ 10 | ^docs$ 11 | ^pkgdown$ 12 | ^codecov\.yml$ 13 | ^cran-comments\.md$ 14 | -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | # For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. 2 | # https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - citest 8 | schedule: 9 | - cron: '0 0 3 * *' 10 | workflow_dispatch: 11 | 12 | name: R-CMD-check 13 | 14 | jobs: 15 | R-CMD-check: 16 | runs-on: ${{ matrix.config.os }} 17 | 18 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 19 | 20 | strategy: 21 | fail-fast: false 22 | matrix: 23 | config: 24 | - {os: windows-latest, r: 'release'} 25 | - {os: macOS-latest, r: 'release'} 26 | - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} 27 | - {os: ubuntu-latest, r: 'release'} 28 | - {os: ubuntu-latest, r: '3.6'} 29 | - {os: ubuntu-latest, r: 'oldrel'} 30 | 31 | env: 32 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 33 | R_KEEP_PKG_SOURCE: yes 34 | 35 | steps: 36 | - uses: actions/checkout@v4 37 | 38 | - uses: r-lib/actions/setup-pandoc@v2 39 | 40 | - uses: r-lib/actions/setup-r@v2 41 | with: 42 | r-version: ${{ matrix.config.r }} 43 | http-user-agent: ${{ matrix.config.http-user-agent }} 44 | use-public-rspm: true 45 | 46 | - name: Blas not openblas 47 | if: runner.os == 'Linux' 48 | run: | 49 | sudo apt-get install libblas-dev liblapack-dev 50 | sudo update-alternatives --set libblas.so.3-x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/blas/libblas.so.3 51 | sudo update-alternatives --set liblapack.so.3-x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3 52 | 53 | - uses: r-lib/actions/setup-r-dependencies@v2 54 | with: 55 | extra-packages: any::rcmdcheck 56 | needs: check 57 | 58 | - name: Session Info complète 59 | run: | 60 | sessioninfo::session_info(info = "all", pkgs = "installed", include_base = TRUE) 61 | shell: Rscript {0} 62 | working-directory: ${{ inputs.working-directory }} 63 | 64 | - uses: r-lib/actions/check-r-package@v2 65 | with: 66 | upload-snapshots: true 67 | -------------------------------------------------------------------------------- /.github/workflows/pkgdown.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | release: 7 | types: [published] 8 | workflow_dispatch: 9 | 10 | name: pkgdown 11 | 12 | jobs: 13 | pkgdown: 14 | runs-on: ubuntu-latest 15 | # Only restrict concurrency for non-PR jobs 16 | concurrency: 17 | group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} 18 | env: 19 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 20 | steps: 21 | - uses: actions/checkout@v4 22 | 23 | - uses: r-lib/actions/setup-pandoc@v2 24 | 25 | - uses: r-lib/actions/setup-r@v2 26 | with: 27 | use-public-rspm: true 28 | 29 | - uses: r-lib/actions/setup-r-dependencies@v2 30 | with: 31 | extra-packages: any::pkgdown, local::. 32 | needs: website 33 | 34 | - name: Build site 35 | run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) 36 | shell: Rscript {0} 37 | 38 | - name: Deploy to GitHub pages 🚀 39 | if: github.event_name != 'pull_request' 40 | uses: JamesIves/github-pages-deploy-action@v4 41 | with: 42 | clean: false 43 | branch: gh-pages 44 | folder: docs 45 | -------------------------------------------------------------------------------- /.github/workflows/test-coverage.yaml: -------------------------------------------------------------------------------- 1 | # For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. 2 | # https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - citest 8 | workflow_dispatch: 9 | 10 | name: test-coverage 11 | 12 | jobs: 13 | test-coverage: 14 | runs-on: ubuntu-latest 15 | env: 16 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 17 | 18 | steps: 19 | - uses: actions/checkout@v4 20 | 21 | - uses: r-lib/actions/setup-r@v2 22 | with: 23 | use-public-rspm: true 24 | 25 | - name: Blas not openblas 26 | if: runner.os == 'Linux' 27 | run: | 28 | sudo apt-get install libblas-dev liblapack-dev 29 | sudo update-alternatives --set libblas.so.3-x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/blas/libblas.so.3 30 | sudo update-alternatives --set liblapack.so.3-x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3 31 | 32 | - uses: r-lib/actions/setup-r-dependencies@v2 33 | with: 34 | extra-packages: any::covr 35 | needs: coverage 36 | 37 | - name: Test coverage 38 | run: covr::codecov(quiet = FALSE) 39 | shell: Rscript {0} 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | inst/doc 6 | /doc/ 7 | /Meta/ 8 | docs 9 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: disaggR 2 | Type: Package 3 | Title: Two-Steps Benchmarks for Time Series Disaggregation 4 | Version: 1.0.5.3 5 | Authors@R: 6 | c(person(given = "Arnaud", 7 | family = "Feldmann", 8 | role = "aut", 9 | email = "arnaud.feldmann@gmail.com", 10 | comment = c(ORCID = "0000-0003-0109-7505","Author and maintener of the package until the version 1.0.1")), 11 | person(given = "Pauline", 12 | family = "Meinzel", 13 | role = "cre", 14 | email = "pauline.meinzel@insee.fr"), 15 | person(given = "Thomas", 16 | family = "Laurent", 17 | role = "ctb", 18 | comment = "Maintener of the package from 1.0.2 to 1.0.5.2"), 19 | person(given = "Franck", 20 | family = "Arnaud", 21 | role = "ctb", 22 | comment = "barplot base graphics method for the mts class"), 23 | person(given = "Institut national de la statistique et des études économiques", 24 | role = "cph", 25 | email = "comptes-trimestriels@insee.fr", 26 | comment = "https://www.insee.fr/")) 27 | Description: The twoStepsBenchmark() and threeRuleSmooth() functions allow you to 28 | disaggregate a low-frequency time series with higher frequency time series, 29 | using the French National Accounts methodology. The aggregated sum of the 30 | resulting time series is strictly equal to the low-frequency time series within the 31 | benchmarking window. Typically, the low-frequency time series is an annual one, 32 | unknown for the last year, and the high frequency one is either quarterly or 33 | monthly. See "Methodology of quarterly national accounts", Insee Méthodes 34 | N°126, by Insee (2012, ISBN:978-2-11-068613-8, ). 35 | Imports: 36 | graphics, 37 | grDevices, 38 | methods, 39 | RColorBrewer (>= 1.1-2), 40 | stats, 41 | utils 42 | License: MIT + file LICENSE 43 | Encoding: UTF-8 44 | Roxygen: list(markdown = TRUE) 45 | RoxygenNote: 7.3.1 46 | Suggests: 47 | knitr, 48 | ggplot2 (>= 3.0.0), 49 | rmarkdown (>= 2.0.0), 50 | shiny (>= 1.5.0), 51 | shinytest2 (>= 0.1.0), 52 | testthat (>= 3.0.0), 53 | vdiffr (>= 1.0.0) 54 | Depends: 55 | R (>= 3.6.0) 56 | BugReports: https://github.com/InseeFr/disaggR/issues 57 | LazyData: yes 58 | Collate: 59 | 'bflSmooth.R' 60 | 'data.R' 61 | 'disaggR.R' 62 | 'utils.R' 63 | 'in.R' 64 | 's4register.R' 65 | 'twoStepsBenchmark.R' 66 | 'methods.R' 67 | 'plot.R' 68 | 'praislm.R' 69 | 'reView.R' 70 | 'threeRuleSmooth.R' 71 | Config/testthat/edition: 3 72 | VignetteBuilder: knitr 73 | URL: https://inseefr.github.io/disaggR/ 74 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2020 2 | COPYRIGHT HOLDER: INSEE (http://www.insee.fr) -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright © 2020 INSEE (http://www.insee.fr). 5 | 6 | Permission is hereby granted, free of charge, to any person 7 | obtaining a copy of this software and associated documentation 8 | files (the “Software”), to deal in the Software without 9 | restriction, including without limitation the rights to use, 10 | copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the 12 | Software is furnished to do so, subject to the following 13 | conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | OTHER DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | S3method(Math,threeRuleSmooth) 4 | S3method(Math,twoStepsBenchmark) 5 | S3method(aggregate,threeRuleSmooth) 6 | S3method(aggregate,twoStepsBenchmark) 7 | S3method(as.list,threeRuleSmooth) 8 | S3method(as.list,twoStepsBenchmark) 9 | S3method(as.ts,threeRuleSmooth) 10 | S3method(as.ts,twoStepsBenchmark) 11 | S3method(coef,praislm) 12 | S3method(coef,twoStepsBenchmark) 13 | S3method(cycle,threeRuleSmooth) 14 | S3method(cycle,twoStepsBenchmark) 15 | S3method(diff,threeRuleSmooth) 16 | S3method(diff,twoStepsBenchmark) 17 | S3method(diffinv,threeRuleSmooth) 18 | S3method(diffinv,twoStepsBenchmark) 19 | S3method(distance,tscomparison) 20 | S3method(fitted,praislm) 21 | S3method(fitted,twoStepsBenchmark) 22 | S3method(ggplot2::autoplot,threeRuleSmooth) 23 | S3method(ggplot2::autoplot,tscomparison) 24 | S3method(ggplot2::autoplot,twoStepsBenchmark) 25 | S3method(ggplotts,data.frame) 26 | S3method(ggplotts,ts) 27 | S3method(in_disaggr,threeRuleSmooth) 28 | S3method(in_disaggr,twoStepsBenchmark) 29 | S3method(in_disaggr_ctb,threeRuleSmooth) 30 | S3method(in_disaggr_ctb,twoStepsBenchmark) 31 | S3method(in_revisions,threeRuleSmooth) 32 | S3method(in_revisions,twoStepsBenchmark) 33 | S3method(in_sample,praislm) 34 | S3method(in_sample,threeRuleSmooth) 35 | S3method(in_sample,twoStepsBenchmark) 36 | S3method(in_scatter,praislm) 37 | S3method(in_scatter,threeRuleSmooth) 38 | S3method(in_scatter,twoStepsBenchmark) 39 | S3method(model.list,praislm) 40 | S3method(model.list,threeRuleSmooth) 41 | S3method(model.list,twoStepsBenchmark) 42 | S3method(monthplot,threeRuleSmooth) 43 | S3method(monthplot,twoStepsBenchmark) 44 | S3method(na.omit,threeRuleSmooth) 45 | S3method(na.omit,twoStepsBenchmark) 46 | S3method(neither_outlier_nor_constant,praislm) 47 | S3method(neither_outlier_nor_constant,threeRuleSmooth) 48 | S3method(neither_outlier_nor_constant,twoStepsBenchmark) 49 | S3method(outliers,praislm) 50 | S3method(outliers,twoStepsBenchmark) 51 | S3method(plot,threeRuleSmooth) 52 | S3method(plot,tscomparison) 53 | S3method(plot,twoStepsBenchmark) 54 | S3method(print,praislm) 55 | S3method(print,reViewOutput) 56 | S3method(print,summary.praislm) 57 | S3method(print,threeRuleSmooth) 58 | S3method(print,tscomparison) 59 | S3method(print,twoStepsBenchmark) 60 | S3method(rePort,character) 61 | S3method(rePort,connection) 62 | S3method(rePort,reViewOutput) 63 | S3method(rePort,twoStepsBenchmark) 64 | S3method(reView,character) 65 | S3method(reView,connection) 66 | S3method(reView,reViewOutput) 67 | S3method(reView,twoStepsBenchmark) 68 | S3method(residuals,praislm) 69 | S3method(residuals,twoStepsBenchmark) 70 | S3method(rho,praislm) 71 | S3method(rho,twoStepsBenchmark) 72 | S3method(se,praislm) 73 | S3method(se,twoStepsBenchmark) 74 | S3method(smoothed.part,twoStepsBenchmark) 75 | S3method(smoothed.rate,threeRuleSmooth) 76 | S3method(summary,praislm) 77 | S3method(summary,twoStepsBenchmark) 78 | S3method(time,threeRuleSmooth) 79 | S3method(time,twoStepsBenchmark) 80 | S3method(vcov,praislm) 81 | S3method(vcov,twoStepsBenchmark) 82 | S3method(window,threeRuleSmooth) 83 | S3method(window,twoStepsBenchmark) 84 | export(annualBenchmark) 85 | export(bflSmooth) 86 | export(default_col_pal) 87 | export(default_lty_pal) 88 | export(default_margins) 89 | export(default_theme_ggplot) 90 | export(distance) 91 | export(in_disaggr) 92 | export(in_revisions) 93 | export(in_sample) 94 | export(in_scatter) 95 | export(model.list) 96 | export(outliers) 97 | export(prais) 98 | export(rePort) 99 | export(reUseBenchmark) 100 | export(reView) 101 | export(residuals_extrap) 102 | export(rho) 103 | export(se) 104 | export(smoothed.part) 105 | export(smoothed.rate) 106 | export(threeRuleSmooth) 107 | export(twoStepsBenchmark) 108 | exportClasses(disaggR) 109 | exportClasses(threeRuleSmooth) 110 | exportClasses(twoStepsBenchmark) 111 | exportMethods(Math2) 112 | exportMethods(Ops) 113 | exportMethods(show) 114 | import(graphics) 115 | import(methods) 116 | import(stats) 117 | importFrom(RColorBrewer,brewer.pal) 118 | importFrom(grDevices,colorRampPalette) 119 | importFrom(grDevices,dev.size) 120 | importFrom(stats,aggregate) 121 | importFrom(stats,as.ts) 122 | importFrom(stats,coef) 123 | importFrom(stats,cycle) 124 | importFrom(stats,diffinv) 125 | importFrom(stats,fitted) 126 | importFrom(stats,lag) 127 | importFrom(stats,monthplot) 128 | importFrom(stats,na.omit) 129 | importFrom(stats,residuals) 130 | importFrom(stats,time) 131 | importFrom(stats,vcov) 132 | importFrom(stats,window) 133 | importFrom(utils,browseURL) 134 | importFrom(utils,packageVersion) 135 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # disaggR 1.0.5.3 2 | * Compatibility with ggplot 3.5.0 : Removed the "scale\_name" argument within scales that is now deprecated, new test snapshots (PR #102). 3 | 4 | # disaggR 1.0.5.2 5 | * Nothing changed besides the maintener. 6 | 7 | # disaggR 1.0.5.1 8 | * Internal change to check package version with character instead of numeric. 9 | * Internal minor change to in\_disaggr (incohesive parameters) 10 | * A more informative error message if one tries to differentiate a time-series with only one observation 11 | * A more informative error message if the rank becomes imperfect after decorrelation 12 | 13 | # disaggR 1.0.5 14 | * Breaking change : The order of the output of the `reViewOutput` object has been reversed. reView and rePort can now take a language object as name arguments and return language objects inside their name attributes (PR #86) 15 | * The `print` method digit argument is now passed to everything below. The default value is `getOption("digits")` for the benchmarks and `max(3L, getOption("digits"))` for the praislm objects. 16 | 17 | # disaggR 1.0.4.1 18 | * Internal change from ggplot2 size argument, which is deprecated for lines, to linewidth (PR #78) 19 | 20 | # disaggR 1.0.4 21 | * Added the arguments `hfserie_name` and `lfserie_name` for rePort, as for reView. (PR #70) 22 | * Added a vignette describing the use of outliers. (PR #74) 23 | * `reView` no longer throws the message "This Font Awesome icon ('info-circle') does not exist". 24 | 25 | # disaggR 1.0.3 26 | * Added the signature `c("disaggR","missing")` for Ops group generic. (PR #54) 27 | * Inner calls to aggregate are now redirected to a faster non-exported function. (PR #55) 28 | * Estimation spans and outliers are now handled in preset models in rePort and reView (PR #57) 29 | * NULL labels are now removed even outside the plot margins (PR #59) 30 | * The `in_scatter` function now substracts the outliers contributions from the low-frequency serie before computing the in_scatter comparison. (PR #63) 31 | * The `in_scatter` has now an additional arguments : `type` (as every in_ function). For now, the only use for the type argument is to allow changes scatterplots for levels models. (PR #63) 32 | * The smoothed.part, for differencied benchmarks, has been set to a new base (its aggregated value is 0 in 2000). That way, `reUseBenchmark` is fixed if used on high-frequency series that have a different start than the previous one. This has no impact on the benchmarked serie. (PR #65) 33 | 34 | # disaggR 1.0.2 35 | * New vignette : Introduction to disaggR. 36 | * The error of `in_disaggR` for wrong `type` arguments has been changed, because it didn't include "contributions". 37 | * `cex.axis`, `xlim`, `ylim`, `cex.lab` and `cex.main` parameters now overwrite their default if used inside `plot(...)` dots. 38 | * By default, in the `plot` and `autoplot` methods, the axis annotations are now automatically set to be smaller if needed. 39 | 40 | # disaggR 1.0.1 41 | * Switched ggplot2, rmarkdown and shiny from imports to suggests. RColorBrewer has replaced scales as an import. disaggR can now be installed with far less dependencies. Hence, the `autoplot` generic is not reexported anymore. ggplot2 has to be attached to allow the use of `autoplot` without the `ggplot2::` prefix, by example with `library(ggplot2)`. 42 | 43 | # disaggR 1.0.0 44 | * added support of outliers. 45 | * In `twoStepsBenchmark`, the set.coeff names used to be replaced by `"hfserie"` if `NCOL(hfserie) == 1L` and `length(set.coeff) == 1L`. This behavior was contradictory with the documentation if `set.coeff=c(constant=1L)`. As for now, set.coeff names will never be replaced. Then, it makes the controls stricter because `set.coeff=c(x.name.herited.from.anywhere=1)` will lead to an error. 46 | * as for the `in` time-series plots, the y window now ignores the infinite values. 47 | 48 | # disaggR 0.2.1 49 | * fixed some issues with ts.eps-delayed tsps. 50 | 51 | # disaggR 0.2.0 52 | * reView : a shiny reviewing application for twoStepsBenchmarks. 53 | * rePort : a rmarkdown html report for twoStepsBenchmark and reView outputs. 54 | * start.domain and end.domain know crops the hfserie *after* having calculated the coefficients. That way, it is possible to evaluate the coefficients on a full hfserie, cropping them for the application. 55 | * `in_sample` now generates a more general class `"tscomparison"`, with a `"in_sample"` func attribute. In previous versions, 56 | the S3 class was named "insample". 57 | * the new functions `in_scatter`, `in_benchmark` and `in_revisions` also produce tscomparisons, with plot and autoplot methods. 58 | * the graphics are prettier thanks to the package scales. 59 | * the plot and autoplot methods now have xlab, ylab, start, end, col, lty, show.legend, main and mar arguments. The autoplot methods have also a theme argument. 60 | * removed the c++ code to improve readability. 61 | * most of the stats methods for time-series now coerce twoStepsBenchmarks or rateSmooths into time-series. 62 | * `reUseBenchmark` now induces a `set.smoothed.part` element in model.list if `reeval.smoothed.part` is 63 | `FALSE`. 64 | * `threeRuleSmooth` makes it easier than bflSmooth to procede to a rate smooth. 65 | 66 | # disaggR 0.1.7 67 | * various optimizations including cache for bflSmooth, which is now much faster, and alternative internal methods for time-series. 68 | * added a weights arg to bflSmooth, that reproduces the *lissage en taux* methodology. 69 | * the praislm and twoStepsBenchmark summaries now print some disclaimer to tell if the regression includes a differenciation. 70 | -------------------------------------------------------------------------------- /R/bflSmooth.R: -------------------------------------------------------------------------------- 1 | stairs_diagonal <- function(A,ratio,weights=1) { 2 | res <- matrix(0,A,ratio*A) 3 | res[matrix(c(rep(1L:A,each=ratio), 4 | seq_len(ncol(res))), 5 | ncol = 2L)] <- weights 6 | res 7 | } 8 | 9 | weights_control <- function(weights,start,hf_length,hf_freq) { 10 | if (is.null(weights)) return() 11 | if (!inherits(weights,"ts")) stop("The weights must be either NULL or a one-dimensional ts with the same window than the expected high-frequency series", call. = FALSE) 12 | if (!is.null(dim(weights)) && dim(weights)[2L] != 1L) stop("The weights series must be one-dimensional", call. = FALSE) 13 | tspw <- tsp(weights) 14 | if (tspw[3L] != hf_freq) stop("The frequency of the weights must be the same than the new frequency", call. = FALSE) 15 | if (abs(tspw[1L] - start) > getOption("ts.eps")) stop("The weights series must have the same start than the expected high-frequency series", call. = FALSE) 16 | if (length(weights) != hf_length) stop("The weights series must have the same end than the expected high-frequency series", call. = FALSE) 17 | return() 18 | } 19 | 20 | bflSmooth_matrices_impl <- function(lf_length,ratio,weights,lfserie.is.rate) { 21 | if (is.null(weights)) weights <- 1 22 | else { 23 | aggregated_weights <- fast_aggregate(weights,frequency(weights)/ratio) 24 | weights <- fast_op_on_x(weights, 25 | ts_expand(aggregated_weights,frequency(weights),divide.by.ratio = FALSE), 26 | `/`) 27 | } 28 | 29 | MT <- t(apply(stairs_diagonal(lf_length,ratio,weights),1,function(x) rev(cumsum(rev(x))))) 30 | m1 <- MT[,1L] 31 | tildem <- MT[,-1L,drop=FALSE] 32 | inversemm <- solve((tcrossprod(tildem))) 33 | cprod1 <- crossprod(m1,inversemm) 34 | cprod2 <- crossprod(tildem,inversemm) 35 | 36 | # A * as.numeric(x) stands for diag(x) %*% A 37 | # t(t(A) * as.numeric(x)) stands for A %*% diag(x) 38 | 39 | if (lfserie.is.rate||identical(weights,1)) { 40 | list(m1=m1, 41 | cprod1=cprod1, 42 | cprod2=cprod2) 43 | } else { 44 | list(m1=m1*as.numeric(aggregated_weights), 45 | cprod1=t(t(cprod1)/as.numeric(aggregated_weights)), 46 | cprod2=t(t(cprod2)/as.numeric(aggregated_weights))) 47 | } 48 | } 49 | 50 | #' Generating a clone for bflSmooth_matrices_impl 51 | #' 52 | #' This *function factory* returns a clone of bflSmooth_matrices_impl that gives 53 | #' the same results than the original function but uses cache to store computed matrices, 54 | #' which is useful when making a large number of similar calls, like calls to 55 | #' `threeRuleSmooth()` with the same hfserie but different lfserie, 56 | #' or to `twoStepsBenchmark()` with different lfserie of the same length. 57 | #' 58 | #' bflSmooth_matrices_factory is only run at build time. 59 | #' 60 | #' @keywords internal 61 | bflSmooth_matrices_factory <- function(cache_size=100L) { 62 | cache <- vector("list",cache_size) 63 | cache_next <- 1L 64 | function(lf_length,ratio,weights,lfserie.is.rate) { 65 | args <- list(lf_length,ratio,weights,lfserie.is.rate) 66 | cached_index <- Position(function(x) identical(x$args,args),cache) 67 | if (is.na(cached_index)) { 68 | value <- bflSmooth_matrices_impl(lf_length,ratio,weights,lfserie.is.rate) 69 | cache[[cache_next]] <<- list(args=args, 70 | value=value) 71 | cache_next <<- cache_next %% cache_size + 1L 72 | value 73 | } 74 | else cache[[cached_index]]$value 75 | } 76 | } 77 | 78 | bflSmooth_matrices <- bflSmooth_matrices_factory() 79 | 80 | #' Smooth a time series 81 | #' 82 | #' bflSmooth smoothes a time series into a time series of a higher frequency that 83 | #' exactly aggregates into the higher one. The process followed is Boot, Feibes 84 | #' and Lisman, which minimizes the squares of the variations. 85 | #' 86 | #' If `weights` isn't `NULL` the results depends of `lfserie.is.rate` : 87 | #' 88 | #' * if `FALSE` the rate output/weights is smoothed with the constraint that the 89 | #' aggregated output is equal to the input lfserie. 90 | #' * if `TRUE` the input lfserie is the rate to be smoothed, with the constraint 91 | #' that the low-frequency weighted means of the output are equal to 92 | #' lfserie. 93 | #' 94 | #' @param lfserie a time series to be smoothed 95 | #' @param nfrequency the new high frequency. It must be a multiple of the low 96 | #' frequency. 97 | #' @param weights NULL or a time series of the same size than the expected 98 | #' high-frequency serie. 99 | #' @param lfserie.is.rate TRUE or FALSE. Only taken into account if weights isn't 100 | #' NULL. 101 | #' 102 | #' @return A time series of frequency nfrequency 103 | #' 104 | #' @export 105 | bflSmooth <- function(lfserie,nfrequency,weights=NULL,lfserie.is.rate=FALSE) { 106 | if (!inherits(lfserie,"ts")) stop("Not a ts object", call. = FALSE) 107 | tsplf <- tsp(lfserie) 108 | if (as.integer(tsplf[3L]) != tsplf[3L]) stop("The frequency of the smoothed series must be an integer", call. = FALSE) 109 | if (nfrequency == 0) stop("The new frequency must be strictly positive", call. = FALSE) 110 | if (nfrequency %% tsplf[3L] != 0L) stop("The new frequency must be a multiple of the lower one", call. = FALSE) 111 | if (!is.null(dim(lfserie)) && dim(lfserie)[2L] != 1) stop("The low frequency series must be one-dimensional", call. = FALSE) 112 | if (is.null(weights) && lfserie.is.rate) { 113 | warning("weights is NULL. Ignoring lfserie.is.rate",call. = FALSE) 114 | lfserie.is.rate <- FALSE 115 | } 116 | 117 | ratio <- nfrequency/tsplf[3L] 118 | 119 | weights_control(weights,tsplf[1L],ratio*length(lfserie),nfrequency) 120 | 121 | if (nfrequency == tsplf[3L]) return(lfserie) 122 | 123 | matrices <- bflSmooth_matrices(lf_length = length(lfserie), 124 | ratio = nfrequency/tsplf[3L], 125 | weights = weights, 126 | lfserie.is.rate) 127 | 128 | x11 <- as.numeric(matrices$cprod1 %*% lfserie/(matrices$cprod1 %*% matrices$m1)) 129 | res <- cumsum(c(x11,matrices$cprod2 %*% (as.numeric(lfserie)-matrices$m1*x11))) 130 | if (!lfserie.is.rate && !is.null(weights)) res <- res * as.numeric(weights) 131 | ts(res,start=tsplf[1L],frequency = nfrequency) 132 | } 133 | -------------------------------------------------------------------------------- /R/data.R: -------------------------------------------------------------------------------- 1 | #' Total GFCF in construction at current prices 2 | #' 3 | #' An annual time series containing the french GFCF in construction from 2000 4 | #' to 2019, as retrieved the 08/12/2020. 5 | #' 6 | #' @format A time series of frequency 1 7 | #' 8 | #' @source \url{https://www.insee.fr/fr/statistiques/2015361} 9 | #' @keywords internal 10 | "construction" 11 | 12 | #' Turnover indicator in construction 13 | #' 14 | #' An monthly time series containing the turnover indicator in construction 15 | #' from january 2000 to may 2020, as retrieved the 08/12/2020. 16 | #' 17 | #' @format A time series of frequency 12 18 | #' 19 | #' @source \url{https://www.insee.fr/fr/statistiques/4636032} 20 | #' @keywords internal 21 | "turnover" 22 | 23 | #' Total consumption in accommodation and food services at current prices 24 | #' 25 | #' An annual time series containing the consumption in accommodation and food services services from 1999 26 | #' to 2021, as retrieved the 04/07/2022. 27 | #' 28 | #' @format A time series of frequency 1 29 | #' 30 | #' @source \url{https://www.insee.fr/en/statistiques/serie/010548586} 31 | #' @keywords internal 32 | "consumption_catering" 33 | 34 | #' Turnover indicator in accommodation and food services 35 | #' 36 | #' An monthly time series containing the turnover indicator in accommodation and food services 37 | #' from january 1999 to april 2022, as retrieved the 04/07/2022. 38 | #' 39 | #' @format A time series of frequency 12 40 | #' 41 | #' @source \url{https://www.insee.fr/en/statistiques/serie/010543406} 42 | #' @keywords internal 43 | "turnover_catering" 44 | -------------------------------------------------------------------------------- /R/disaggR.R: -------------------------------------------------------------------------------- 1 | #' @title Two-Steps Benchmarks for Time Series Disaggregation 2 | #' 3 | #' @description 4 | #' 5 | #' The `twoStepsBenchmark()` and `threeRuleSmooth()` functions allow you to 6 | #' disaggregate a low-frequency time series with higher frequency time series, 7 | #' using the French National Accounts methodology. The aggregated sum of the 8 | #' resulting time series is strictly equal to the low-frequency series within the 9 | #' benchmarking window. Typically, the low-frequency series is an annual one, 10 | #' unknown for the last year, and the high frequency one is either quarterly or 11 | #' monthly. 12 | #' 13 | #' See "Methodology of quarterly national accounts", Insee Méthodes 14 | #' N°126, by Insee (2012, ISBN:978-2-11-068613-8, 15 | #' https://www.insee.fr/en/information/2579410). 16 | #' 17 | #' @import stats graphics 18 | #' @keywords internal 19 | "_PACKAGE" 20 | 21 | globalVariables(c("Date","Values","Low-Frequency Periods","Variables", 22 | "High-frequency serie","Low-frequency serie", 23 | "Low-frequency periods","Time","xend","yend", 24 | "group")) 25 | -------------------------------------------------------------------------------- /R/praislm.R: -------------------------------------------------------------------------------- 1 | # this function multiplies by omega_inv_sqrt without 2 | # having to create the matrix (it is helpful if there are a lot of obs) 3 | omega_inv_sqrt <- function(x,rho) { 4 | if (is.null(dim(x))) { 5 | c(sqrt(1-rho^2)*x[1L], 6 | x[-1L]-rho*x[-length(x)]) 7 | } 8 | else { 9 | rbind(sqrt(1-rho^2)*x[1L,], 10 | x[-1L,,drop=FALSE]-rho*x[-nrow(x),,drop=FALSE]) 11 | } 12 | } 13 | 14 | autocor <- function(x) { 15 | x_center <- x-mean(x) 16 | tailxc <- x_center[-1L] 17 | headxc <- x_center[-length(x_center)] 18 | as.numeric(crossprod(tailxc,headxc)/ 19 | sqrt(crossprod(tailxc)) / 20 | sqrt(crossprod(headxc))) 21 | # Not exactly pearson but is a bit better to estimate the rho of an AR1 22 | } 23 | 24 | praislm_impl <- function(X,y,include.rho) { 25 | rho <- 0 26 | df_residual <- nrow(X) - ncol(X) 27 | 28 | if (ncol(X) != 0L) { 29 | if (any(is.na(X))) stop("The high frequency serie must have values in the full coefficients calculation window", call. = FALSE) 30 | PQR <- qr(X) 31 | if (PQR$rank != ncol(X)) stop("The regressed series should have a perfect rank", call. = FALSE) 32 | 33 | coefficients <- qr.coef(PQR,y) 34 | 35 | if (include.rho) { 36 | rho_prec <- 0 37 | rho <- 1 38 | i <- 1L 39 | 40 | while (abs(rho-rho_prec)>0.001) { 41 | rho_prec <- rho 42 | rho <- autocor(y - X %*% coefficients) 43 | 44 | y_star <- omega_inv_sqrt(y,rho) 45 | X_star <- omega_inv_sqrt(X,rho) 46 | 47 | tryCatch({ 48 | PQR <- qr(X_star) 49 | coefficients <- qr.coef(PQR,y_star) 50 | }, 51 | error = function(e) stop("After decorrelation, the rank becomes imperfect", call. = FALSE) 52 | ) 53 | 54 | if (i == 50L) { 55 | warning("Maximum iterations without convergence", call. = FALSE) 56 | break 57 | } 58 | i <- i+1L 59 | } 60 | } 61 | fitted <- X %*% coefficients 62 | residuals <- y-fitted 63 | residuals_decor <- omega_inv_sqrt(residuals,rho) 64 | resvar <- sum(residuals_decor^2) / df_residual 65 | R <- chol2inv(PQR$qr[1L:ncol(X), 1L:ncol(X), drop = FALSE]) 66 | se <- sqrt(diag(R) * resvar) 67 | } 68 | else { 69 | coefficients <- numeric() 70 | fitted <- rep(0,length(y)) 71 | residuals <- y 72 | residuals_decor <- y 73 | se <- numeric() 74 | } 75 | list(coefficients = coefficients, 76 | residuals = residuals, 77 | fitted=fitted, 78 | df.residual=df_residual, 79 | se=se, 80 | rho=rho, 81 | residuals.decorrelated=residuals_decor) 82 | } 83 | 84 | #' @rdname prais 85 | #' @keywords internal 86 | praislm <- function(X,y,include.rho,include.differenciation,set_coefficients,cl) { 87 | modellist <- list(X=X, 88 | y=y, 89 | include.rho=include.rho, 90 | include.differenciation=include.differenciation, 91 | set.coefficients=set_coefficients) 92 | if ( !is.ts(X) || !is.ts(y) ) stop("Not a ts object", call. = FALSE) 93 | if (is.null(dim(X))) stop("Not a matrix object", call. = FALSE) 94 | if (!tsp_equal(tsp(X),tsp(y))) stop("X and y should have the same windows and frequencies", call. = FALSE) 95 | 96 | tspx <- tsp(X) 97 | X <- matrix(as.numeric(X),nrow = nrow(X),ncol = ncol(X),dimnames = dimnames(X)) 98 | y <- as.numeric(y) 99 | 100 | if (include.differenciation) { 101 | if (length(y) == 1L) stop("Differenciation with stricly less than two observations", call. = FALSE) 102 | X <- diff(X) 103 | y <- diff(y) 104 | tspx[1L] <- tspx[1L] + 1/tspx[3L] 105 | } 106 | 107 | if (length(set_coefficients) == 0L) names(set_coefficients) <- character() 108 | else if (is.null(names(set_coefficients))) stop("The coefficients setter must be empty or have names", call. = FALSE) 109 | 110 | coefficients <- rep(NA_real_,ncol(X)) 111 | names(coefficients) <- colnames(X) 112 | se <- rep(NA_real_,ncol(X)) 113 | names(se) <- colnames(X) 114 | 115 | match_set <- match(names(set_coefficients),colnames(X)) 116 | if (any(is.na(set_coefficients))) stop("A coefficient can't be set to NA", call. = FALSE) 117 | if (any(is.na(match_set))) stop("These names of the set.coeff argument are not found : ", 118 | paste(names(set_coefficients)[is.na(match_set)]), call. = FALSE) 119 | coefficients[match_set] <- set_coefficients 120 | match_notset <- which(is.na(coefficients)) 121 | 122 | offset <- X[,match_set,drop=FALSE] %*% set_coefficients 123 | 124 | calculated <- praislm_impl(X[,match_notset,drop=FALSE],y-offset,include.rho) 125 | 126 | coefficients[match_notset] <- calculated$coefficients 127 | 128 | se[match_notset] <- calculated$se 129 | 130 | fitted <- calculated$fitted + offset 131 | 132 | res <- list(coefficients=coefficients, 133 | residuals=ts_from_tsp(drop(calculated$residuals),tspx), 134 | fitted.values=ts_from_tsp(drop(fitted),tspx), 135 | se=se, 136 | df.residual=calculated$df.residual, 137 | rho=calculated$rho, 138 | residuals.decorrelated=ts_from_tsp(drop(calculated$residuals.decor),tspx), 139 | fitted.values.decorrelated=ts_from_tsp(drop(omega_inv_sqrt(fitted,calculated$rho)),tspx), 140 | model.list=modellist, 141 | call=cl) 142 | class(res) <- "praislm" 143 | res 144 | } 145 | -------------------------------------------------------------------------------- /R/s4register.R: -------------------------------------------------------------------------------- 1 | #' Virtual Class "disaggR" Class of disaggregations 2 | #' 3 | #' The `"disaggR"` class is a class contained by the actual disaggregation 4 | #' classes in the disaggR package. It is a “virtual” class. disaggR classes are 5 | #' minimalist S4 classes, containing disaggR and list. This allows Ops group 6 | #' generic double dispatch but most of the package rather uses S3 methods. 7 | #' 8 | #' @seealso 9 | #' the functions \link{twoStepsBenchmark} and \link{threeRuleSmooth}. 10 | #' 11 | #' @aliases 12 | #' Ops,disaggR,missing-method 13 | #' Ops,disaggR,vector-method Ops,vector,disaggR-method 14 | #' Ops,disaggR,ts-method Ops,ts,disaggR-method 15 | #' Ops,disaggR,disaggR-method 16 | #' Math2,disaggR-method 17 | #' show,disaggR-method 18 | #' threeRuleSmooth-class 19 | #' twoStepsBenchmark-class 20 | #' @keywords internal 21 | #' @export 22 | setClass("disaggR", contains = "VIRTUAL") 23 | 24 | #' @import methods 25 | #' @keywords internal 26 | #' @export 27 | setClass("threeRuleSmooth", contains = c("disaggR", "list")) 28 | 29 | #' @import methods 30 | #' @keywords internal 31 | #' @export 32 | setClass("twoStepsBenchmark", contains = c("disaggR", "list")) 33 | -------------------------------------------------------------------------------- /R/utils.R: -------------------------------------------------------------------------------- 1 | ts_from_tsp <- function(x,tspx) { 2 | ts(x, start=tspx[1L], frequency=tspx[3L]) 3 | } 4 | 5 | tsp_equal <- function(tspx,tspy) { 6 | 7 | ts.eps <- getOption("ts.eps") 8 | 9 | tspx[c(1L,2L)] <- tspx[c(1L,2L)] * tspx[3L] 10 | tspy[c(1L,2L)] <- tspy[c(1L,2L)] * tspy[3L] 11 | 12 | all(abs(tspx - tspy) < ts.eps) 13 | 14 | } 15 | 16 | clean_tsp <- function(x) { 17 | s <- start(x) 18 | if (length(s) == 2L) ts(x,start = s, frequency = frequency(x)) 19 | else if (as.integer(frequency(x)) != frequency(x)) stop("The frequencies must be integers", call. = FALSE) 20 | else stop("Incorrect time-serie phase", call. = FALSE) 21 | } 22 | 23 | drop_tsp <- function(x) { 24 | attr(x,"tsp") <- NULL 25 | class(x) <- setdiff(class(x),c("mts","ts")) 26 | x 27 | } 28 | 29 | fast_op_on_x <- function(x,y,FUN) { 30 | FUN <- match.fun(FUN) 31 | tsp <- tsp(x) 32 | ts_from_tsp(FUN(drop_tsp(x), 33 | drop_tsp(window(y,start=tsp[1L],end=tsp[2L],extend=TRUE))), 34 | tspx = tsp) 35 | } 36 | 37 | fast_aggregate <- function(x,nfrequency) { 38 | dimx <- dim(x) 39 | tspx <- tsp(x) 40 | ratio <- tspx[3L]/nfrequency 41 | 42 | res <- .colSums(as.numeric(x),n = length(x)/ratio,m = ratio) 43 | 44 | if (is.null(dimx)) { 45 | ts(res, 46 | start = tspx[1L], 47 | frequency = nfrequency) 48 | } else { 49 | ts(matrix(res,ncol = dimx[2L]), 50 | start = tspx[1L], 51 | frequency = nfrequency, 52 | names = colnames(x)) 53 | } 54 | } 55 | 56 | neither_outlier_nor_constant_impl <- function(hfserie, object) { 57 | hfserie[,!(colnames(hfserie) %in% c("constant", 58 | names(outliers(object)))), 59 | drop = FALSE] 60 | } 61 | 62 | neither_outlier_nor_constant <- function(object) UseMethod("neither_outlier_nor_constant") 63 | 64 | #' @export 65 | neither_outlier_nor_constant.twoStepsBenchmark <- function(object) { 66 | neither_outlier_nor_constant_impl(model.list(object)$hfserie, object) 67 | } 68 | 69 | #' @export 70 | neither_outlier_nor_constant.threeRuleSmooth <- function(object) { 71 | model.list(object)$hfserie 72 | } 73 | 74 | #' @export 75 | neither_outlier_nor_constant.praislm <- function(object) { 76 | neither_outlier_nor_constant_impl(model.list(object)$X, object) 77 | } 78 | 79 | #' Extend tsp with lf 80 | #' 81 | #' This window is the smallest that is all around tsphf 82 | #' that is compatible with the low frequency. 83 | #' 84 | #' @param tsphf a numeric of length 3, a tsp of high-frequency 85 | #' @param lffreq a numeric of length 1, the low frequency 86 | #' @return 87 | #' a numeric of length 3, a tsp of high-frequency. 88 | #' @keywords internal 89 | extend_tsp <- function(tsphf,lffreq) { 90 | 91 | ts.eps <- getOption("ts.eps") 92 | 93 | c(floor(tsphf[1L]*lffreq+ts.eps)/lffreq, 94 | ceiling((tsphf[2L]+1/tsphf[3L])*lffreq-ts.eps)/lffreq-1/tsphf[3L], 95 | tsphf[3L]) 96 | } 97 | 98 | aggregate_and_crop_hf_to_lf <- function(hfserie,lfserie) { 99 | tsplf <- tsp(lfserie) 100 | fast_aggregate( 101 | window(hfserie,tsplf[1L],tsplf[2L]+1/tsplf[3L]-1/frequency(hfserie),extend = TRUE), 102 | nfrequency = tsplf[3L] 103 | ) 104 | } 105 | 106 | ts_expand <- function(x,nfrequency,divide.by.ratio=TRUE) { 107 | ratio <- nfrequency/frequency(x) 108 | res <- if (divide.by.ratio) x/ratio else x 109 | ts(rep(res, each = ratio), start = tsp(x)[1L], frequency = nfrequency) 110 | } 111 | 112 | switch_window <- function(start,end,init_tsp) { 113 | c(switch(length(start), 114 | start, 115 | start[1L] + (start[2L] - 1)/init_tsp[3L]) %||% 116 | init_tsp[1L], 117 | switch(length(end), 118 | end, 119 | end[1L] + (end[2L] - 1)/init_tsp[3L]) %||% 120 | init_tsp[2L] 121 | ) 122 | } 123 | 124 | `%||%` <- function(x,y) if (is.null(x)) y else x 125 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | 6 | 7 | ```{r, include = FALSE} 8 | knitr::opts_chunk$set( 9 | collapse = TRUE, 10 | comment = "#>", 11 | fig.path = "man/figures/README-", 12 | out.width = "100%" 13 | ) 14 | ``` 15 | 16 | 17 | 18 | [![CRAN status](https://www.r-pkg.org/badges/version/disaggR)](https://cran.r-project.org/package=disaggR) 19 | [![R build status](https://github.com/InseeFr/disaggR/workflows/R-CMD-check/badge.svg)](https://github.com/InseeFr/disaggR/actions) 20 | [![codecov](https://codecov.io/gh/InseeFr/disaggR/branch/master/graph/badge.svg)](https://app.codecov.io/gh/InseeFr/disaggR) 21 | [![Downloads](https://cranlogs.r-pkg.org/badges/disaggR)](https://cran.r-project.org/package=disaggR) 22 | 23 | 24 | 25 | ## Overview 26 | 27 | The R package disaggR is an implementation of the French Quarterly National Accounts method for temporal disaggregation of time series. `twoStepsBenchmark()` and `threeRuleSmooth()` bend a time series with another one of a lower frequency. 28 | 29 | ## Installation 30 | 31 | You can install the __stable__ version from [CRAN](https://cran.r-project.org/package=disaggR). 32 | 33 | ```{r, eval = FALSE} 34 | install.packages("disaggR") 35 | ``` 36 | 37 | You can install the __development__ version from [Github](https://github.com/InseeFr/disaggR). 38 | 39 | ```{r, eval = FALSE} 40 | # install.packages("devtools") 41 | install_github("InseeFr/disaggR") 42 | ``` 43 | 44 | ## Usage 45 | 46 | ```{r, echo = TRUE, results = 'hide', fig.show="hold", out.width="50%"} 47 | library(disaggR) 48 | 49 | benchmark <- twoStepsBenchmark(hfserie = turnover, 50 | lfserie = construction, 51 | include.differenciation = TRUE) 52 | as.ts(benchmark) 53 | coef(benchmark) 54 | summary(benchmark) 55 | plot(benchmark) 56 | plot(in_sample(benchmark)) 57 | ``` 58 | 59 | ```{r, echo = TRUE, results = 'hide', fig.show="hold", out.width="50%"} 60 | plot(in_disaggr(benchmark,type="changes"), 61 | start=c(2015,1),end=c(2020,12)) 62 | plot(in_disaggr(benchmark,type="contributions"), 63 | start=c(2015,1),end=c(2020,12)) 64 | ``` 65 | 66 | ```{r, echo = TRUE, results = 'hide', fig.show="hold", out.width="50%"} 67 | plot(in_scatter(benchmark)) 68 | 69 | new_benchmark <- twoStepsBenchmark(hfserie = turnover, 70 | lfserie = construction, 71 | include.differenciation = FALSE) 72 | plot(in_revisions(new_benchmark, 73 | benchmark),start = c(2010,1)) 74 | ``` 75 | 76 | ## Shiny app 77 | 78 | You can also use the shiny application __reView__, to easily chose the best parameters for your benchmark. 79 | 80 | ```{r, echo = TRUE, eval = FALSE} 81 | reView(benchmark) 82 | ``` 83 | 84 | ![shinyscreen](man/figures/shiny-screen.jpg){ width=100% }\ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | [![CRAN 6 | status](https://www.r-pkg.org/badges/version/disaggR)](https://cran.r-project.org/package=disaggR) 7 | [![R build 8 | status](https://github.com/InseeFr/disaggR/workflows/R-CMD-check/badge.svg)](https://github.com/InseeFr/disaggR/actions) 9 | [![codecov](https://codecov.io/gh/InseeFr/disaggR/branch/master/graph/badge.svg)](https://app.codecov.io/gh/InseeFr/disaggR) 10 | [![Downloads](https://cranlogs.r-pkg.org/badges/disaggR)](https://cran.r-project.org/package=disaggR) 11 | 12 | 13 | 14 | ## Overview 15 | 16 | The R package disaggR is an implementation of the French Quarterly 17 | National Accounts method for temporal disaggregation of time series. 18 | `twoStepsBenchmark()` and `threeRuleSmooth()` bend a time series with 19 | another one of a lower frequency. 20 | 21 | ## Installation 22 | 23 | You can install the **stable** version from 24 | [CRAN](https://cran.r-project.org/package=disaggR). 25 | 26 | ``` r 27 | install.packages("disaggR") 28 | ``` 29 | 30 | You can install the **development** version from 31 | [Github](https://github.com/InseeFr/disaggR). 32 | 33 | ``` r 34 | # install.packages("devtools") 35 | install_github("InseeFr/disaggR") 36 | ``` 37 | 38 | ## Usage 39 | 40 | ``` r 41 | library(disaggR) 42 | 43 | benchmark <- twoStepsBenchmark(hfserie = turnover, 44 | lfserie = construction, 45 | include.differenciation = TRUE) 46 | as.ts(benchmark) 47 | coef(benchmark) 48 | summary(benchmark) 49 | plot(benchmark) 50 | plot(in_sample(benchmark)) 51 | ``` 52 | 53 | 54 | 55 | ``` r 56 | plot(in_disaggr(benchmark,type="changes"), 57 | start=c(2015,1),end=c(2020,12)) 58 | plot(in_disaggr(benchmark,type="contributions"), 59 | start=c(2015,1),end=c(2020,12)) 60 | ``` 61 | 62 | 63 | 64 | ``` r 65 | plot(in_scatter(benchmark)) 66 | 67 | new_benchmark <- twoStepsBenchmark(hfserie = turnover, 68 | lfserie = construction, 69 | include.differenciation = FALSE) 70 | plot(in_revisions(new_benchmark, 71 | benchmark),start = c(2010,1)) 72 | ``` 73 | 74 | 75 | 76 | ## Shiny app 77 | 78 | You can also use the shiny application **reView**, to easily chose the 79 | best parameters for your benchmark. 80 | 81 | ``` r 82 | reView(benchmark) 83 | ``` 84 | 85 | shinyscreen 86 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: https://inseefr.github.io/disaggR/ 2 | template: 3 | bootstrap: 5 4 | 5 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | require_ci_to_pass: no 3 | notify: 4 | wait_for_ci: no 5 | 6 | -------------------------------------------------------------------------------- /data/construction.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InseeFr/disaggR/c2a531babcb77d6ee9e0d33dd4c13c3576e582c5/data/construction.RData -------------------------------------------------------------------------------- /data/consumption_catering.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InseeFr/disaggR/c2a531babcb77d6ee9e0d33dd4c13c3576e582c5/data/consumption_catering.RData -------------------------------------------------------------------------------- /data/turnover.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InseeFr/disaggR/c2a531babcb77d6ee9e0d33dd4c13c3576e582c5/data/turnover.RData -------------------------------------------------------------------------------- /data/turnover_catering.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InseeFr/disaggR/c2a531babcb77d6ee9e0d33dd4c13c3576e582c5/data/turnover_catering.RData -------------------------------------------------------------------------------- /disaggR.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | BuildType: Package 16 | PackageUseDevtools: Yes 17 | PackageInstallArgs: --no-multiarch --with-keep.source 18 | -------------------------------------------------------------------------------- /inst/rmd/report.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | params: 3 | new_bn: NA 4 | old_bn: NA 5 | hfserie_name: NA 6 | lfserie_name: NA 7 | title: "Benchmark report `r deparse(params$hfserie_name)` on `r deparse(params$lfserie_name)`" 8 | date: "`r format(Sys.time(), '%d %B %Y')`" 9 | --- 10 | 11 | ```{r include=F} 12 | knitr::opts_chunk$set(fig.height = 2.5,out.width = "100%") 13 | knitr::opts_knit$set(global.par = TRUE) 14 | hfserie <- disaggR:::neither_outlier_nor_constant.twoStepsBenchmark(params$new_bn) 15 | 16 | # the parameters not affected by preset models are kept (i.e. time series, outliers and time boundaries) 17 | 18 | list_args <- c(list(hfserie= hfserie, 19 | outliers = outliers(params$new_bn)), 20 | model.list(params$new_bn)[c("lfserie", 21 | "start.coeff.calc","end.coeff.calc", 22 | "start.benchmark","end.benchmark", 23 | "start.domain","end.domain")] 24 | ) 25 | 26 | presets_list <- do.call(disaggR:::presets_list_fun, list_args) 27 | 28 | ``` 29 | 30 | # Presets 31 | 32 | :::: {.columns} 33 | 34 | ::: {.column width="50%"} 35 | 36 | Model 1 (*differences --- with constant*) 37 | 38 | ```{r echo=FALSE} 39 | plot(in_sample(presets_list[[1]])) 40 | ``` 41 | 42 | Model 3 (*levels --- with constant*) 43 | 44 | ```{r echo=FALSE} 45 | plot(in_sample(presets_list[[3]])) 46 | ``` 47 | 48 | Model 5 (*levels --- without constant*) 49 | 50 | ```{r echo=FALSE} 51 | plot(in_sample(presets_list[[5]])) 52 | ``` 53 | 54 | ::: 55 | 56 | ::: {.column width="50%"} 57 | 58 | Model 2 (*differences --- without constant*) 59 | 60 | ```{r echo=FALSE} 61 | plot(in_sample(presets_list[[2]])) 62 | ``` 63 | 64 | Model 4 (*autocorrelated levels --- with constant*) 65 | 66 | ```{r echo=FALSE} 67 | plot(in_sample(presets_list[[4]])) 68 | ``` 69 | 70 | Model 6 (*autocorrelated levels --- without constant*) 71 | 72 | ```{r echo=FALSE} 73 | plot(in_sample(presets_list[[6]])) 74 | ``` 75 | 76 | ::: 77 | 78 | :::: 79 | 80 | ```{r echo=FALSE,results = 'asis'} 81 | htmltools::HTML( 82 | as.character( 83 | disaggR:::summary_table_html(presets_list, 84 | params$old_bn, 85 | 2L) 86 | )) 87 | ``` 88 | 89 | # Scatter plot 90 | 91 | :::: {.columns} 92 | 93 | ::: {.column width="50%"} 94 | 95 | **Before** 96 | 97 | ```{r echo=FALSE,fig.height=5} 98 | plot(in_scatter(params$old_bn), 99 | xlab = "High-frequency serie", 100 | ylab = "Low-frequency serie") 101 | ``` 102 | 103 | ::: 104 | 105 | ::: {.column width="50%"} 106 | 107 | **After** 108 | 109 | ```{r echo=FALSE,fig.height=5} 110 | plot(in_scatter(params$new_bn)) 111 | ``` 112 | 113 | ::: 114 | 115 | :::: 116 | 117 | # Benchmark 118 | 119 | :::: {.columns} 120 | 121 | ::: {.column width="50%"} 122 | 123 | **Before** 124 | 125 | ```{r echo=FALSE,comment="\t"} 126 | cat(disaggR:::get_benchmark_call(params$old_bn,params$hfserie_name,params$lfserie_name)) 127 | ``` 128 | 129 | ::: 130 | 131 | 132 | ::: {.column width="50%"} 133 | 134 | **After** 135 | 136 | ```{r echo=FALSE,comment="\t"} 137 | cat(disaggR:::get_benchmark_call(params$new_bn,params$hfserie_name,params$lfserie_name)) 138 | ``` 139 | 140 | ::: 141 | 142 | :::: 143 | 144 | :::: {.columns} 145 | 146 | ::: {.column width="50%"} 147 | 148 | ```{r echo=FALSE} 149 | plot(params$old_bn) 150 | ``` 151 | 152 | ::: 153 | 154 | ::: {.column width="50%"} 155 | 156 | ```{r echo=FALSE} 157 | plot(params$new_bn) 158 | ``` 159 | 160 | ::: 161 | 162 | :::: 163 | 164 | # In-sample predictions 165 | 166 | :::: {.columns} 167 | 168 | ::: {.column width="50%"} 169 | 170 | **Before** 171 | 172 | ```{r echo=FALSE} 173 | plot(in_sample(params$old_bn,type="levels"), 174 | ylab = "Levels") 175 | plot(in_sample(params$old_bn,type="changes"), 176 | ylab = "Changes") 177 | ``` 178 | 179 | ::: 180 | 181 | ::: {.column width="50%"} 182 | 183 | **After** 184 | 185 | ```{r echo=FALSE} 186 | plot(in_sample(params$new_bn,type="levels"), 187 | ylab = "Levels") 188 | plot(in_sample(params$new_bn,type="changes"), 189 | ylab = "Changes") 190 | ``` 191 | 192 | ::: 193 | 194 | :::: 195 | 196 | # Benchmark summary 197 | 198 | :::: {.columns} 199 | 200 | ::: {.column width="50%"} 201 | 202 | **Before** 203 | 204 | ```{r echo=FALSE} 205 | print(summary(params$old_bn),call=FALSE) 206 | ``` 207 | 208 | ::: 209 | 210 | ::: {.column width="50%"} 211 | 212 | **After** 213 | 214 | ```{r echo=FALSE} 215 | print(summary(params$new_bn),call=FALSE) 216 | ``` 217 | 218 | ::: 219 | 220 | :::: 221 | 222 | # Comparison benchmark/input 223 | 224 | :::: {.columns} 225 | 226 | ::: {.column width="100%"} 227 | 228 | ```{r echo=FALSE,fig.width = 14} 229 | plot(in_disaggr(params$new_bn,type="levels-rebased"), 230 | ylab = "Rebased levels") 231 | plot(in_disaggr(params$new_bn,type="changes"), 232 | ylab = "Changes") 233 | plot(in_disaggr(params$new_bn,type="contributions"), 234 | ylab = "Contributions") 235 | ``` 236 | 237 | ::: 238 | 239 | :::: 240 | 241 | # Revisions 242 | 243 | :::: {.columns} 244 | 245 | ::: {.column width="100%"} 246 | 247 | ```{r echo=FALSE,fig.width=14} 248 | plot(in_revisions(params$new_bn,params$old_bn,type="levels"), 249 | ylab = "Levels") 250 | plot(in_revisions(params$new_bn,params$old_bn,type="changes"), 251 | ylab = "Changes") 252 | plot(in_revisions(params$new_bn,params$old_bn,type="contributions"), 253 | ylab = "Contributions") 254 | ``` 255 | 256 | ::: 257 | 258 | :::: -------------------------------------------------------------------------------- /inst/rmd/report.css: -------------------------------------------------------------------------------- 1 | table{border-collapse:collapse;border-spacing:0}td,th{padding:0} 2 | .bg-success{background-color:#dff0d8}a.bg-success:hover,a.bg-success:focus{background-color:#c1e2b3} 3 | .bg-danger{background-color:#f2dede}a.bg-danger:hover,a.bg-danger:focus{background-color:#e4b9b9} 4 | -------------------------------------------------------------------------------- /inst/rmd/report_nocompare.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | params: 3 | new_bn: NA 4 | old_bn: NA 5 | hfserie_name: NA 6 | lfserie_name: NA 7 | title: "Benchmark report `r deparse(params$hfserie_name)` on `r deparse(params$lfserie_name)`" 8 | date: "`r format(Sys.time(), '%d %B %Y')`" 9 | --- 10 | 11 | ```{r include=F} 12 | knitr::opts_chunk$set(fig.height = 2.5,out.width = "100%") 13 | knitr::opts_knit$set(global.par = TRUE) 14 | hfserie <- disaggR:::neither_outlier_nor_constant.twoStepsBenchmark(params$new_bn) 15 | 16 | # the parameters not affected by preset models are kept (i.e. time series, outliers and time boundaries) 17 | 18 | list_args <- c(list(hfserie= hfserie, 19 | outliers = outliers(params$new_bn)), 20 | model.list(params$new_bn)[c("lfserie", 21 | "start.coeff.calc","end.coeff.calc", 22 | "start.benchmark","end.benchmark", 23 | "start.domain","end.domain")] 24 | ) 25 | 26 | presets_list <- do.call(disaggR:::presets_list_fun, list_args) 27 | ``` 28 | 29 | # Presets 30 | 31 | :::: {.columns} 32 | 33 | ::: {.column width="50%"} 34 | 35 | Model 1 (*differences --- with constant*) 36 | 37 | ```{r echo=FALSE} 38 | plot(in_sample(presets_list[[1]])) 39 | ``` 40 | 41 | Model 3 (*levels --- with constant*) 42 | 43 | ```{r echo=FALSE} 44 | plot(in_sample(presets_list[[3]])) 45 | ``` 46 | 47 | Model 5 (*levels --- without constant*) 48 | 49 | ```{r echo=FALSE} 50 | plot(in_sample(presets_list[[5]])) 51 | ``` 52 | 53 | ::: 54 | 55 | ::: {.column width="50%"} 56 | 57 | Model 2 (*differences --- without constant*) 58 | 59 | ```{r echo=FALSE} 60 | plot(in_sample(presets_list[[2]])) 61 | ``` 62 | 63 | Model 4 (*autocorrelated levels --- with constant*) 64 | 65 | ```{r echo=FALSE} 66 | plot(in_sample(presets_list[[4]])) 67 | ``` 68 | 69 | Model 6 (*autocorrelated levels --- without constant*) 70 | 71 | ```{r echo=FALSE} 72 | plot(in_sample(presets_list[[6]])) 73 | ``` 74 | 75 | ::: 76 | 77 | :::: 78 | 79 | ```{r echo=FALSE,results = 'asis'} 80 | htmltools::HTML( 81 | as.character( 82 | disaggR:::summary_table_html(presets_list, 83 | params$old_bn, 84 | 2L) 85 | )) 86 | ``` 87 | 88 | # Scatter plot 89 | 90 | :::: {.columns} 91 | 92 | ::: {.column width="100%"} 93 | 94 | ```{r echo=FALSE} 95 | plot(in_scatter(params$new_bn)) 96 | ``` 97 | 98 | ::: 99 | 100 | :::: 101 | 102 | # Benchmark 103 | 104 | :::: {.columns} 105 | 106 | ::: {.column width="100%"} 107 | 108 | ```{r echo=FALSE,comment="\t"} 109 | cat(disaggR:::get_benchmark_call(params$new_bn,params$hfserie_name,params$lfserie_name)) 110 | ``` 111 | 112 | ```{r echo=FALSE, fig.width=14} 113 | plot(params$new_bn) 114 | ``` 115 | 116 | ::: 117 | 118 | :::: 119 | 120 | # In-sample predictions 121 | 122 | :::: {.columns} 123 | 124 | ::: {.column width="100%"} 125 | 126 | ```{r echo=FALSE, fig.width=14} 127 | plot(in_sample(params$new_bn,type="levels"), 128 | ylab = "Levels") 129 | plot(in_sample(params$new_bn,type="changes"), 130 | ylab = "Changes") 131 | ``` 132 | 133 | ::: 134 | 135 | :::: 136 | 137 | # Benchmark summary 138 | 139 | :::: {.columns} 140 | 141 | ::: {.column width="100%"} 142 | 143 | ```{r echo=FALSE, fig.width=14} 144 | print(summary(params$new_bn),call=FALSE) 145 | ``` 146 | 147 | ::: 148 | 149 | :::: 150 | 151 | # Comparison benchmark/input 152 | 153 | :::: {.columns} 154 | 155 | ::: {.column width="100%"} 156 | 157 | ```{r echo=FALSE,fig.width = 14} 158 | plot(in_disaggr(params$new_bn,type="levels-rebased"), 159 | ylab = "Rebased levels") 160 | plot(in_disaggr(params$new_bn,type="changes"), 161 | ylab = "Changes") 162 | plot(in_disaggr(params$new_bn,type="contributions"), 163 | ylab = "Contributions") 164 | ``` 165 | 166 | ::: 167 | 168 | :::: -------------------------------------------------------------------------------- /man/bflSmooth.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/bflSmooth.R 3 | \name{bflSmooth} 4 | \alias{bflSmooth} 5 | \title{Smooth a time series} 6 | \usage{ 7 | bflSmooth(lfserie, nfrequency, weights = NULL, lfserie.is.rate = FALSE) 8 | } 9 | \arguments{ 10 | \item{lfserie}{a time series to be smoothed} 11 | 12 | \item{nfrequency}{the new high frequency. It must be a multiple of the low 13 | frequency.} 14 | 15 | \item{weights}{NULL or a time series of the same size than the expected 16 | high-frequency serie.} 17 | 18 | \item{lfserie.is.rate}{TRUE or FALSE. Only taken into account if weights isn't 19 | NULL.} 20 | } 21 | \value{ 22 | A time series of frequency nfrequency 23 | } 24 | \description{ 25 | bflSmooth smoothes a time series into a time series of a higher frequency that 26 | exactly aggregates into the higher one. The process followed is Boot, Feibes 27 | and Lisman, which minimizes the squares of the variations. 28 | } 29 | \details{ 30 | If \code{weights} isn't \code{NULL} the results depends of \code{lfserie.is.rate} : 31 | \itemize{ 32 | \item if \code{FALSE} the rate output/weights is smoothed with the constraint that the 33 | aggregated output is equal to the input lfserie. 34 | \item if \code{TRUE} the input lfserie is the rate to be smoothed, with the constraint 35 | that the low-frequency weighted means of the output are equal to 36 | lfserie. 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /man/bflSmooth_matrices_factory.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/bflSmooth.R 3 | \name{bflSmooth_matrices_factory} 4 | \alias{bflSmooth_matrices_factory} 5 | \title{Generating a clone for bflSmooth_matrices_impl} 6 | \usage{ 7 | bflSmooth_matrices_factory(cache_size = 100L) 8 | } 9 | \description{ 10 | This \emph{function factory} returns a clone of bflSmooth_matrices_impl that gives 11 | the same results than the original function but uses cache to store computed matrices, 12 | which is useful when making a large number of similar calls, like calls to 13 | \code{threeRuleSmooth()} with the same hfserie but different lfserie, 14 | or to \code{twoStepsBenchmark()} with different lfserie of the same length. 15 | } 16 | \details{ 17 | bflSmooth_matrices_factory is only run at build time. 18 | } 19 | \keyword{internal} 20 | -------------------------------------------------------------------------------- /man/construction.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{construction} 5 | \alias{construction} 6 | \title{Total GFCF in construction at current prices} 7 | \format{ 8 | A time series of frequency 1 9 | } 10 | \source{ 11 | \url{https://www.insee.fr/fr/statistiques/2015361} 12 | } 13 | \usage{ 14 | construction 15 | } 16 | \description{ 17 | An annual time series containing the french GFCF in construction from 2000 18 | to 2019, as retrieved the 08/12/2020. 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/consumption_catering.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{consumption_catering} 5 | \alias{consumption_catering} 6 | \title{Total consumption in accommodation and food services at current prices} 7 | \format{ 8 | A time series of frequency 1 9 | } 10 | \source{ 11 | \url{https://www.insee.fr/en/statistiques/serie/010548586} 12 | } 13 | \usage{ 14 | consumption_catering 15 | } 16 | \description{ 17 | An annual time series containing the consumption in accommodation and food services services from 1999 18 | to 2021, as retrieved the 04/07/2022. 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/default_col_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plot.R 3 | \name{default_col_pal} 4 | \alias{default_col_pal} 5 | \title{Default color palette} 6 | \usage{ 7 | default_col_pal(object) 8 | } 9 | \description{ 10 | The default color palette for the graphics, inspired from the package 11 | \pkg{scales} whose scales can also be used as alternatives. 12 | } 13 | \keyword{internal} 14 | -------------------------------------------------------------------------------- /man/default_lty_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plot.R 3 | \name{default_lty_pal} 4 | \alias{default_lty_pal} 5 | \title{Default linetype palette} 6 | \usage{ 7 | default_lty_pal(object) 8 | } 9 | \description{ 10 | The default linetype palette for the graphics. The palette for the objects 11 | with another class than \code{"in_scatter"} is taken from \code{linetype_pal} as seen 12 | in the package \pkg{scales}. Hence it is based on a set supplied by Richard 13 | Pearson, University of Manchester. 14 | } 15 | \keyword{internal} 16 | -------------------------------------------------------------------------------- /man/default_margins.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plot.R 3 | \name{default_margins} 4 | \alias{default_margins} 5 | \title{Default margins} 6 | \usage{ 7 | default_margins(main, xlab, ylab) 8 | } 9 | \description{ 10 | The default margins for the graphics. 11 | } 12 | \keyword{internal} 13 | -------------------------------------------------------------------------------- /man/default_theme_ggplot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plot.R 3 | \name{default_theme_ggplot} 4 | \alias{default_theme_ggplot} 5 | \title{Default ggplot theme} 6 | \usage{ 7 | default_theme_ggplot(object, start, end, show.legend, xlab, ylab, mar) 8 | } 9 | \description{ 10 | This is the default theme for the ggplot graphics produced with autoplot 11 | } 12 | \keyword{internal} 13 | -------------------------------------------------------------------------------- /man/disaggR-class.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/s4register.R 3 | \docType{class} 4 | \name{disaggR-class} 5 | \alias{disaggR-class} 6 | \alias{Ops,disaggR,missing-method} 7 | \alias{Ops,disaggR,vector-method} 8 | \alias{Ops,vector,disaggR-method} 9 | \alias{Ops,disaggR,ts-method} 10 | \alias{Ops,ts,disaggR-method} 11 | \alias{Ops,disaggR,disaggR-method} 12 | \alias{Math2,disaggR-method} 13 | \alias{show,disaggR-method} 14 | \alias{threeRuleSmooth-class} 15 | \alias{twoStepsBenchmark-class} 16 | \title{Virtual Class "disaggR" Class of disaggregations} 17 | \description{ 18 | The \code{"disaggR"} class is a class contained by the actual disaggregation 19 | classes in the disaggR package. It is a “virtual” class. disaggR classes are 20 | minimalist S4 classes, containing disaggR and list. This allows Ops group 21 | generic double dispatch but most of the package rather uses S3 methods. 22 | } 23 | \seealso{ 24 | the functions \link{twoStepsBenchmark} and \link{threeRuleSmooth}. 25 | } 26 | \keyword{internal} 27 | -------------------------------------------------------------------------------- /man/disaggR-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/disaggR.R 3 | \docType{package} 4 | \name{disaggR-package} 5 | \alias{disaggR} 6 | \alias{disaggR-package} 7 | \title{Two-Steps Benchmarks for Time Series Disaggregation} 8 | \description{ 9 | The \code{twoStepsBenchmark()} and \code{threeRuleSmooth()} functions allow you to 10 | disaggregate a low-frequency time series with higher frequency time series, 11 | using the French National Accounts methodology. The aggregated sum of the 12 | resulting time series is strictly equal to the low-frequency series within the 13 | benchmarking window. Typically, the low-frequency series is an annual one, 14 | unknown for the last year, and the high frequency one is either quarterly or 15 | monthly. 16 | 17 | See "Methodology of quarterly national accounts", Insee Méthodes 18 | N°126, by Insee (2012, ISBN:978-2-11-068613-8, 19 | https://www.insee.fr/en/information/2579410). 20 | } 21 | \seealso{ 22 | Useful links: 23 | \itemize{ 24 | \item \url{https://inseefr.github.io/disaggR/} 25 | \item Report bugs at \url{https://github.com/InseeFr/disaggR/issues} 26 | } 27 | 28 | } 29 | \author{ 30 | \strong{Maintainer}: Pauline Meinzel \email{pauline.meinzel@insee.fr} 31 | 32 | Authors: 33 | \itemize{ 34 | \item Arnaud Feldmann \email{arnaud.feldmann@gmail.com} (\href{https://orcid.org/0000-0003-0109-7505}{ORCID}) (Author and maintener of the package until the version 1.0.1) 35 | } 36 | 37 | Other contributors: 38 | \itemize{ 39 | \item Thomas Laurent (Maintener of the package from 1.0.2 to 1.0.5.2) [contributor] 40 | \item Franck Arnaud (barplot base graphics method for the mts class) [contributor] 41 | \item Institut national de la statistique et des études économiques \email{comptes-trimestriels@insee.fr} (https://www.insee.fr/) [copyright holder] 42 | } 43 | 44 | } 45 | \keyword{internal} 46 | -------------------------------------------------------------------------------- /man/distance.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/in.R 3 | \name{distance} 4 | \alias{distance} 5 | \title{Distance computation for disaggregations} 6 | \usage{ 7 | distance(x, p = 2) 8 | } 9 | \arguments{ 10 | \item{x}{an object of class \code{tscomparison}} 11 | 12 | \item{p}{an integer greater than 1L, or Inf.} 13 | } 14 | \value{ 15 | a numeric of length 1, the distance. 16 | } 17 | \description{ 18 | This function \code{distance} computes the Minkowski distance of exponent p, 19 | related to a tscomparison object, produced with \code{in_sample}, \code{in_disaggr} or 20 | \code{in_revisions} 21 | } 22 | \details{ 23 | The meaning depends on the tscomparison function : 24 | \itemize{ 25 | \item \code{in_sample} will produce the low-frequency distance between the predicted 26 | value and the response, on the coefficient calculation window. 27 | \item \code{in_disaggr} will produce the high-frequency distance between the inputs 28 | (eventually, the sum of its contributions) and the benchmarked series. 29 | \item \code{in_revisions} will produce the high-frequency distance between the two 30 | benchmarked series (contributions distance isn't permitted). 31 | } 32 | } 33 | \examples{ 34 | benchmark <- twoStepsBenchmark(turnover,construction,include.rho = TRUE) 35 | distance(in_sample(benchmark,type="changes")) 36 | distance(in_disaggr(benchmark,type="contributions"),p=1L) 37 | distance(in_disaggr(benchmark,type="changes"),p=Inf) 38 | } 39 | \seealso{ 40 | in_sample in_disaggr in_revisions 41 | } 42 | -------------------------------------------------------------------------------- /man/extend_tsp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{extend_tsp} 4 | \alias{extend_tsp} 5 | \title{Extend tsp with lf} 6 | \usage{ 7 | extend_tsp(tsphf, lffreq) 8 | } 9 | \arguments{ 10 | \item{tsphf}{a numeric of length 3, a tsp of high-frequency} 11 | 12 | \item{lffreq}{a numeric of length 1, the low frequency} 13 | } 14 | \value{ 15 | a numeric of length 3, a tsp of high-frequency. 16 | } 17 | \description{ 18 | This window is the smallest that is all around tsphf 19 | that is compatible with the low frequency. 20 | } 21 | \keyword{internal} 22 | -------------------------------------------------------------------------------- /man/figures/README-fi-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InseeFr/disaggR/c2a531babcb77d6ee9e0d33dd4c13c3576e582c5/man/figures/README-fi-1.png -------------------------------------------------------------------------------- /man/figures/README-unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InseeFr/disaggR/c2a531babcb77d6ee9e0d33dd4c13c3576e582c5/man/figures/README-unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /man/figures/README-unnamed-chunk-3-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InseeFr/disaggR/c2a531babcb77d6ee9e0d33dd4c13c3576e582c5/man/figures/README-unnamed-chunk-3-2.png -------------------------------------------------------------------------------- /man/figures/README-unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InseeFr/disaggR/c2a531babcb77d6ee9e0d33dd4c13c3576e582c5/man/figures/README-unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /man/figures/README-unnamed-chunk-4-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InseeFr/disaggR/c2a531babcb77d6ee9e0d33dd4c13c3576e582c5/man/figures/README-unnamed-chunk-4-2.png -------------------------------------------------------------------------------- /man/figures/README-unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InseeFr/disaggR/c2a531babcb77d6ee9e0d33dd4c13c3576e582c5/man/figures/README-unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /man/figures/README-unnamed-chunk-5-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InseeFr/disaggR/c2a531babcb77d6ee9e0d33dd4c13c3576e582c5/man/figures/README-unnamed-chunk-5-2.png -------------------------------------------------------------------------------- /man/figures/README-unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InseeFr/disaggR/c2a531babcb77d6ee9e0d33dd4c13c3576e582c5/man/figures/README-unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /man/figures/README-unnamed-chunk-6-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InseeFr/disaggR/c2a531babcb77d6ee9e0d33dd4c13c3576e582c5/man/figures/README-unnamed-chunk-6-2.png -------------------------------------------------------------------------------- /man/figures/shiny-screen.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InseeFr/disaggR/c2a531babcb77d6ee9e0d33dd4c13c3576e582c5/man/figures/shiny-screen.jpg -------------------------------------------------------------------------------- /man/hfserie_extrap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/threeRuleSmooth.R 3 | \name{hfserie_extrap} 4 | \alias{hfserie_extrap} 5 | \title{Extrapolation function for the hfserie in a threeRuleSmooth} 6 | \usage{ 7 | hfserie_extrap(hfserie, lffreq) 8 | } 9 | \arguments{ 10 | \item{hfserie}{a time series, the high frequency series to extrapolate} 11 | 12 | \item{lffreq}{an integer of length 1. The low frequency} 13 | } 14 | \value{ 15 | a time series, the extrapolated hfserie 16 | } 17 | \description{ 18 | This function replaces the incomplete low frequency cycles, at the start and 19 | the end of the hfserie, with respectively the first and the last complete 20 | cycles. 21 | It may seem very raw, but it's only used for the weights in \code{bflSmooth}, in 22 | order to get the high-frequency rate. 23 | } 24 | \keyword{internal} 25 | -------------------------------------------------------------------------------- /man/in_disaggr.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/in.R 3 | \name{in_disaggr} 4 | \alias{in_disaggr} 5 | \title{Comparing a disaggregation with the high-frequency input} 6 | \usage{ 7 | in_disaggr(object, type = "changes") 8 | } 9 | \arguments{ 10 | \item{object}{an object of class \code{"twoStepsBenchmark"} or \code{"threeRuleSmooth"}.} 11 | 12 | \item{type}{\code{"levels"},\code{"levels-rebased"}, \code{"changes"} or \code{"contributions"}. 13 | This defines the type of output.} 14 | } 15 | \value{ 16 | a named matrix time series of two columns, one for the response and the other 17 | for the input. 18 | A \code{tscomparison} class is added to the object. 19 | } 20 | \description{ 21 | The function \code{in_disaggr} takes a \link{twoStepsBenchmark} or a 22 | \link{threeRuleSmooth} object as an input. It produces a comparison between 23 | the benchmarked time series and the high-frequency input. 24 | } 25 | \details{ 26 | The functions \code{plot} and \code{autoplot} can be used on this object to produce 27 | graphics. 28 | } 29 | \examples{ 30 | benchmark <- twoStepsBenchmark(turnover,construction,include.rho = TRUE) 31 | plot(in_disaggr(benchmark)) 32 | } 33 | \seealso{ 34 | \link{in_sample} \link{in_revisions} \link{in_scatter} 35 | \link{plot.tscomparison} 36 | } 37 | -------------------------------------------------------------------------------- /man/in_revisions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/in.R 3 | \name{in_revisions} 4 | \alias{in_revisions} 5 | \title{Comparing two disaggregations together} 6 | \usage{ 7 | in_revisions(object, object_old, type = "changes") 8 | } 9 | \arguments{ 10 | \item{object}{an object of class \code{"twoStepsBenchmark"} or \code{"threeRuleSmooth"}.} 11 | 12 | \item{object_old}{an object of class \code{"twoStepsBenchmark"} or \code{"threeRuleSmooth"}.} 13 | 14 | \item{type}{\code{"levels"},\code{"levels-rebased"}, \code{"changes"} or \code{"contributions"}. 15 | This defines the type of output.} 16 | } 17 | \value{ 18 | a named matrix time series of two columns, one for the response and the other 19 | for the predicted value. 20 | A \code{tscomparison} class is added to the object. 21 | } 22 | \description{ 23 | The function \code{in_revisions}takes two inputs, \link{twoStepsBenchmark} or a 24 | \link{threeRuleSmooth}, and produces a comparison between those. 25 | } 26 | \details{ 27 | The functions \code{plot} and \code{autoplot} can be used on this object to produce 28 | graphics. 29 | } 30 | \examples{ 31 | benchmark <- twoStepsBenchmark(turnover,construction,include.rho = TRUE) 32 | benchmark2 <- twoStepsBenchmark(turnover,construction,include.differenciation = TRUE) 33 | plot(in_revisions(benchmark,benchmark2)) 34 | } 35 | \seealso{ 36 | \link{in_sample} \link{in_disaggr} \link{in_scatter} 37 | \link{plot.tscomparison} 38 | } 39 | -------------------------------------------------------------------------------- /man/in_sample.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/in.R 3 | \name{in_sample} 4 | \alias{in_sample} 5 | \title{Producing the in sample predictions of a prais-lm regression} 6 | \usage{ 7 | in_sample(object, type = "changes") 8 | } 9 | \arguments{ 10 | \item{object}{an object of class \code{"praislm"} or \code{"twoStepsBenchmark"}.} 11 | 12 | \item{type}{\code{"changes"} or \code{"levels"}. The results are either returned 13 | in changes or in levels.} 14 | } 15 | \value{ 16 | a named matrix time series of two columns, one for the response and the other 17 | for the predicted value. 18 | A \code{"tscomparison"} class is added to the object. 19 | } 20 | \description{ 21 | The function \code{in_sample} returns in-sample predictions from a \link{praislm} 22 | or a \link{twoStepsBenchmark} object. 23 | } 24 | \details{ 25 | The functions \code{plot} and \code{autoplot} can be used on this object to produce 26 | graphics. 27 | 28 | The predicted values are different from the fitted values : 29 | \itemize{ 30 | \item they are eventually reintegrated. 31 | \item they contain the autocorrelated part of the residuals. 32 | } 33 | 34 | Besides, changes are relative to the latest benchmark value, not the latest 35 | predicted value. 36 | } 37 | \examples{ 38 | benchmark <- twoStepsBenchmark(turnover,construction,include.rho = TRUE) 39 | plot(in_sample(benchmark)) 40 | } 41 | \seealso{ 42 | \link{in_disaggr} \link{in_revisions} \link{in_scatter} 43 | \link{plot.tscomparison} 44 | } 45 | -------------------------------------------------------------------------------- /man/in_scatter.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/in.R 3 | \name{in_scatter} 4 | \alias{in_scatter} 5 | \title{Comparing the inputs of a praislm regression} 6 | \usage{ 7 | in_scatter( 8 | object, 9 | type = if (model.list(object)$include.differenciation) "changes" else "levels" 10 | ) 11 | } 12 | \arguments{ 13 | \item{object}{an object of class \code{"praislm"}, \code{"twoStepsBenchmark"} 14 | or \code{"threeRuleSmooth"}.} 15 | 16 | \item{type}{\code{"levels"} or \code{"changes"}. 17 | This defines the type of output. A differencied model can't have a scatterplot 18 | in levels.} 19 | } 20 | \value{ 21 | a named matrix time series of two or three columns, one for the low-frequency serie 22 | and the others for the high-frequency series (eventually differentiated if 23 | \code{include.differenciation} is \code{TRUE}). 24 | A \code{tscomparison} class is added to the object. 25 | For a \code{twoStepsBenchmark} object, this matrix has three columns, 26 | for the low-frequency series, the high-frequency on the regression span and 27 | the high-frequency series on the benchmark span. 28 | 29 | If outlier effects are estimated, the contributions of the outliers are 30 | substracted from the low-frequency series. 31 | } 32 | \description{ 33 | The function \code{in_scatter} returns low-frequency comparisons of the inputs from 34 | a \link{praislm}, a \link{twoStepsBenchmark} or \link{threeRuleSmooth}. 35 | } 36 | \details{ 37 | The functions \code{plot} and \code{autoplot} can be used on this object to produce 38 | graphics. 39 | } 40 | \examples{ 41 | benchmark <- twoStepsBenchmark(turnover,construction,include.rho = TRUE) 42 | plot(in_scatter(benchmark)) 43 | } 44 | \seealso{ 45 | \link{in_sample} \link{in_disaggr} \link{in_revisions} 46 | \link{plot.tscomparison} 47 | } 48 | -------------------------------------------------------------------------------- /man/model.list.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods.R 3 | \name{model.list} 4 | \alias{model.list} 5 | \title{Extracting all the arguments submitted to generate an object} 6 | \usage{ 7 | model.list(object) 8 | } 9 | \arguments{ 10 | \item{object}{an object of class \code{"twoStepsBenchmark"}, \code{"threeRuleSmooth"} 11 | or \code{"praislm"}.} 12 | } 13 | \value{ 14 | a list containing every evaluated arguments 15 | } 16 | \description{ 17 | The function \code{model.list} returns the arguments submitted to the function 18 | used to generate the object of class \code{"twoStepsBenchmark"}, 19 | \code{"threeRuleSmooth"} or \code{"praislm"}. 20 | } 21 | \details{ 22 | These are returned as they are after evaluation, model.list doesn't 23 | return a call. 24 | } 25 | \examples{ 26 | benchmark <- twoStepsBenchmark(turnover,construction); model.list(benchmark) 27 | 28 | } 29 | \keyword{internal} 30 | -------------------------------------------------------------------------------- /man/outliers.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods.R 3 | \name{outliers} 4 | \alias{outliers} 5 | \title{Extracting the standard error} 6 | \usage{ 7 | outliers(object, as.ts = FALSE) 8 | } 9 | \arguments{ 10 | \item{object}{a praislm or twoStepsBenchmark object.} 11 | 12 | \item{as.ts}{a boolean of length 1. If \code{TRUE}, the returned 13 | outliers are returned as a time series with (dim and colnames). 14 | If \code{FALSE}, the returned outliers is the named list that was 15 | submitted as a function argument.} 16 | } 17 | \value{ 18 | a named list or a time series, depending of the 19 | argument \code{"as.ts"}. 20 | } 21 | \description{ 22 | The function \code{outliers} returns the outliers 23 | from either a \link{praislm} or a \link{twoStepsBenchmark} object. 24 | } 25 | \keyword{internal} 26 | -------------------------------------------------------------------------------- /man/plot.tscomparison.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plot.R 3 | \name{plot.twoStepsBenchmark} 4 | \alias{plot.twoStepsBenchmark} 5 | \alias{plot.threeRuleSmooth} 6 | \alias{plot.tscomparison} 7 | \alias{autoplot.twoStepsBenchmark} 8 | \alias{autoplot.threeRuleSmooth} 9 | \alias{autoplot.tscomparison} 10 | \title{Plotting disaggR objects} 11 | \usage{ 12 | \method{plot}{twoStepsBenchmark}( 13 | x, 14 | xlab = NULL, 15 | ylab = NULL, 16 | start = NULL, 17 | end = NULL, 18 | col = default_col_pal(x), 19 | lty = default_lty_pal(x), 20 | show.legend = TRUE, 21 | main = NULL, 22 | mar = default_margins(main, xlab, ylab), 23 | ... 24 | ) 25 | 26 | \method{plot}{threeRuleSmooth}( 27 | x, 28 | xlab = NULL, 29 | ylab = NULL, 30 | start = NULL, 31 | end = NULL, 32 | col = default_col_pal(x), 33 | lty = default_lty_pal(x), 34 | show.legend = TRUE, 35 | main = NULL, 36 | mar = default_margins(main, xlab, ylab), 37 | ... 38 | ) 39 | 40 | \method{plot}{tscomparison}( 41 | x, 42 | xlab = NULL, 43 | ylab = NULL, 44 | start = NULL, 45 | end = NULL, 46 | col = default_col_pal(x), 47 | lty = default_lty_pal(x), 48 | show.legend = TRUE, 49 | main = NULL, 50 | mar = default_margins(main, xlab, ylab), 51 | ... 52 | ) 53 | 54 | \method{autoplot}{twoStepsBenchmark}( 55 | object, 56 | xlab = NULL, 57 | ylab = NULL, 58 | start = NULL, 59 | end = NULL, 60 | col = default_col_pal(object), 61 | lty = default_lty_pal(object), 62 | show.legend = TRUE, 63 | main = NULL, 64 | mar = NULL, 65 | theme = default_theme_ggplot(object, start, end, show.legend, xlab, ylab, mar), 66 | ... 67 | ) 68 | 69 | \method{autoplot}{threeRuleSmooth}( 70 | object, 71 | xlab = NULL, 72 | ylab = NULL, 73 | start = NULL, 74 | end = NULL, 75 | col = default_col_pal(object), 76 | lty = default_lty_pal(object), 77 | show.legend = TRUE, 78 | main = NULL, 79 | mar = NULL, 80 | theme = default_theme_ggplot(object, start, end, show.legend, xlab, ylab, mar), 81 | ... 82 | ) 83 | 84 | \method{autoplot}{tscomparison}( 85 | object, 86 | xlab = NULL, 87 | ylab = NULL, 88 | start = NULL, 89 | end = NULL, 90 | col = default_col_pal(object), 91 | lty = default_lty_pal(object), 92 | show.legend = TRUE, 93 | main = NULL, 94 | mar = NULL, 95 | theme = default_theme_ggplot(object, start, end, show.legend, xlab, ylab, mar), 96 | ... 97 | ) 98 | } 99 | \arguments{ 100 | \item{x}{(for the plot method) a tscomparison, a twoStepsBenchmark or a 101 | threeRuleSmooth.} 102 | 103 | \item{xlab}{the title for the x axis} 104 | 105 | \item{ylab}{the title for the y axis} 106 | 107 | \item{start}{a numeric of length 1 or 2. The start of the plot.} 108 | 109 | \item{end}{a numeric of length 1 or 2. The end of the plot.} 110 | 111 | \item{col}{the color scale applied on the plot. Could be a vector of colors, 112 | or a function from n to a color vector of size n.} 113 | 114 | \item{lty}{the linetype scales applied on the plot. Could be a vector of 115 | linetypes, or a function from n to a linetypes vector of size n.} 116 | 117 | \item{show.legend}{\code{TRUE} or \code{FALSE}. Should an automatic legend be added to 118 | the plot.} 119 | 120 | \item{main}{a character of length 1, the title of the plot} 121 | 122 | \item{mar}{a numeric of length 4, the margins of the plot specified in the 123 | form \code{c(bottom, left, top, right)}.} 124 | 125 | \item{...}{other arguments passed either to ggplot or plot} 126 | 127 | \item{object}{(for the autoplot method) a tscomparison, a twoStepsBenchmark 128 | or a threeRuleSmooth.} 129 | 130 | \item{theme}{a ggplot theme object to replace the default one (only for 131 | autoplot methods)} 132 | } 133 | \value{ 134 | \code{NULL} for the plot methods, the ggplot object for the autoplot 135 | methods 136 | } 137 | \description{ 138 | Plot methods for objects of class \code{"tscomparison"}, \link{threeRuleSmooth} 139 | and \link{twoStepsBenchmark}. : 140 | \itemize{ 141 | \item \code{plot} draws a plot with base graphics 142 | \item \code{autoplot} produces a ggplot object 143 | } 144 | 145 | Objects of class \code{tscomparison} can be produced with the functions 146 | \link{in_sample}, \link{in_scatter}, \link{in_revisions}, \link{in_disaggr}. 147 | } 148 | \examples{ 149 | benchmark <- twoStepsBenchmark(turnover,construction,include.rho = TRUE) 150 | plot(benchmark) 151 | plot(in_sample(benchmark)) 152 | if(require("ggplot2")) { 153 | autoplot(in_disaggr(benchmark,type="changes"), 154 | start=c(2015,1), 155 | end=c(2020,12)) 156 | } 157 | plot(in_scatter(benchmark),xlab="title x",ylab="title y") 158 | } 159 | -------------------------------------------------------------------------------- /man/prais.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods.R, R/praislm.R 3 | \name{prais} 4 | \alias{prais} 5 | \alias{praislm} 6 | \title{Extracting the regression of a twoStepsBenchmark} 7 | \usage{ 8 | prais(x) 9 | 10 | praislm(X, y, include.rho, include.differenciation, set_coefficients, cl) 11 | } 12 | \arguments{ 13 | \item{x}{a twoStepsBenchmark} 14 | } 15 | \value{ 16 | prais returns an object of class \code{"praislm"}. 17 | 18 | The functions that can be used on that class are almost the same than 19 | for the class \code{twoStepsBenchmark}. 20 | \code{summary}, \code{coefficients}, \code{residuals} will return the same values. 21 | However, as for \code{fitted.values}, the accessor returns the fitted values 22 | of the regression, not the high-frequency, eventually integrated, time series 23 | contained in a twoStepsBenchmark. 24 | 25 | An object of class \code{"praislm"} is a list containing the following components : 26 | \item{coefficients}{a named vector of coefficients.} 27 | \item{residuals}{the residuals, that is response minus fitted values.} 28 | \item{fitted.values}{a time series, the fitted mean values} 29 | \item{se}{a named vector of standard errors.} 30 | \item{df.residuals}{the residual degrees of freedom.} 31 | \item{rho}{the autocorrelation coefficients of the residuals. It 32 | is equal to zero if twoStepsBenchmark was called with \code{include.rho=FALSE}} 33 | \item{residuals.decorrelated}{the residuals of the model after having been 34 | transformed by rho in a least square model.} 35 | \item{fitted.values.decorrelated}{the fitted values of the model after 36 | having been transformed by rho in a least square model.} 37 | } 38 | \description{ 39 | prais extracts the regression, which is an object of class \code{"praislm"}, of a 40 | twoStepsBenchmark object. 41 | } 42 | \examples{ 43 | benchmark <- twoStepsBenchmark(turnover,construction); prais(benchmark) 44 | } 45 | \keyword{internal} 46 | -------------------------------------------------------------------------------- /man/rePort.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/reView.R 3 | \name{rePort} 4 | \alias{rePort} 5 | \title{Producing a report} 6 | \usage{ 7 | rePort( 8 | object, 9 | output_file = NULL, 10 | launch.browser = if (is.null(output_file)) TRUE else FALSE, 11 | hfserie_name = NULL, 12 | lfserie_name = NULL, 13 | ... 14 | ) 15 | } 16 | \arguments{ 17 | \item{object}{a twoStepsBenchmark with an univariate hfserie, a reViewOutput, 18 | or a character of length 1 with the path of their RDS file. If a reViewOutput 19 | is chosen, the former new benchmark is taken as the old one.} 20 | 21 | \item{output_file}{The file in which the html should be saved. If \code{NULL} 22 | the file is temporary, and opened in a tab of the default browser.} 23 | 24 | \item{launch.browser}{\code{TRUE} or \code{FALSE}. If TRUE, the output is opened in the 25 | browser. Defaults to TRUE if output_file is NULL.} 26 | 27 | \item{hfserie_name}{a language object or a character of length 1. The name of 28 | the hfserie, eventually its expression.} 29 | 30 | \item{lfserie_name}{a language object or a character of length 1. The name of 31 | the lfserie, eventually its expression.} 32 | 33 | \item{\dots}{other arguments passed to rmarkdown::render} 34 | } 35 | \description{ 36 | This function takes an output of the \link{reView} \pkg{shiny} application 37 | and produces an html report with the same outputs than in shiny. 38 | } 39 | \details{ 40 | It can also directly take a \link{twoStepsBenchmark} as an input. 41 | } 42 | \seealso{ 43 | reView 44 | } 45 | -------------------------------------------------------------------------------- /man/reUseBenchmark.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/twoStepsBenchmark.R 3 | \name{reUseBenchmark} 4 | \alias{reUseBenchmark} 5 | \title{Using an estimated benchmark model on another time series} 6 | \usage{ 7 | reUseBenchmark(hfserie,benchmark,reeval.smoothed.part=FALSE) 8 | } 9 | \arguments{ 10 | \item{hfserie}{the bended time series. If it is a matrix time series, it has to 11 | have the same column names than the \code{hfserie} used for the benchmark.} 12 | 13 | \item{benchmark}{a twoStepsBenchmark object, from which the parameters and 14 | coefficients are taken.} 15 | 16 | \item{reeval.smoothed.part}{a boolean of length 1. If \code{TRUE}, the smoothed 17 | part is reevaluated, hence the aggregated benchmarked series is equal to the 18 | low-frequency series.} 19 | } 20 | \value{ 21 | \code{reUseBenchmark} returns an object of class \link{twoStepsBenchmark}. 22 | } 23 | \description{ 24 | This function reapplies the coefficients and parameters of a benchmark on new 25 | time series. 26 | } 27 | \details{ 28 | \code{reUseBenchmark} is primarily meant to be used on a series that is derived 29 | from the previous one, after some modifications that would bias the 30 | estimation otherwise. Working-day adjustment is a good example. Hence, by 31 | default, the smoothed part of the first model isn't reevaluated ; the 32 | aggregated benchmarked series isn't equal to the low-frequency series. 33 | } 34 | \examples{ 35 | benchmark <- twoStepsBenchmark(turnover,construction) 36 | turnover_modif <- turnover 37 | turnover_modif[2] <- turnover[2]+2 38 | benchmark2 <- reUseBenchmark(turnover_modif,benchmark) 39 | } 40 | -------------------------------------------------------------------------------- /man/reView.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/reView.R 3 | \name{reView} 4 | \alias{reView} 5 | \title{A shiny app to reView and modify twoStepsBenchmarks} 6 | \usage{ 7 | reView(object, hfserie_name = NULL, lfserie_name = NULL, compare = TRUE) 8 | } 9 | \arguments{ 10 | \item{object}{a twoStepsBenchmark with an univariate hfserie, a reViewOutput, 11 | or a character of length 1 with the path of their RDS file. If a reViewOutput 12 | is chosen, the former new benchmark is taken as the old one.} 13 | 14 | \item{hfserie_name}{a language object or a character of length 1. The name of 15 | the hfserie, eventually its expression.} 16 | 17 | \item{lfserie_name}{a language object or a character of length 1. The name of 18 | the lfserie, eventually its expression.} 19 | 20 | \item{compare}{a boolean of length 1, that tells if the outputs of 21 | the old benchmark should be displayed.} 22 | } 23 | \value{ 24 | a list, of class reViewOutput, containing the new benchmark, 25 | the old one, the names of the series and the boolean compare. 26 | This object can also be saved in RDS format through the app. 27 | The reViewOutput object can be displayed as a html report with the same 28 | informations than in shiny, with the \link{rePort} method. 29 | } 30 | \description{ 31 | reView allows the user to easily access diverse outputs in order to 32 | review a benchmark object, made with \link{twoStepsBenchmark}. 33 | 34 | The \code{hfserie_name} and \code{lfserie_name} define : 35 | } 36 | \details{ 37 | \itemize{ 38 | \item the default file name of the RDS file 39 | \item the names of the series in the output \code{call} element 40 | } 41 | 42 | By default, these are set as defined in their \code{call} element. 43 | 44 | The app is made of \pkg{shiny} modules in order to make it easy to integrate 45 | it into a wider application. In the module part, every input are defined as 46 | reactive variables. 47 | } 48 | \examples{ 49 | \dontrun{ 50 | reView(twoStepsBenchmark(turnover,construction)) 51 | } 52 | 53 | } 54 | \seealso{ 55 | \link{rePort} 56 | } 57 | -------------------------------------------------------------------------------- /man/residuals_extrap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/twoStepsBenchmark.R 3 | \name{residuals_extrap} 4 | \alias{residuals_extrap} 5 | \title{Extrapolation function for the residuals in a twoStepsBenchmark} 6 | \usage{ 7 | residuals_extrap(lfresiduals, rho, include.differenciation) 8 | } 9 | \arguments{ 10 | \item{lfresiduals}{the residuals to extrapolate} 11 | 12 | \item{rho}{the autocorrelation parameter of the regression} 13 | 14 | \item{include.differenciation}{a boolean, the same as submitted 15 | to twoStepsBenchmark} 16 | } 17 | \value{ 18 | a numeric, the extrapolated sequence of residuals, to replace the NA of 19 | the residuals 20 | } 21 | \description{ 22 | This function is the rule to extrapolate the low-frequency residuals. 23 | If include.differenciation is \code{TRUE}, u(n+1)-u(n) = rho*(u(n)-u(n-1)) 24 | Else u(n+1) = rho * u(n) 25 | } 26 | \keyword{internal} 27 | -------------------------------------------------------------------------------- /man/rho.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods.R 3 | \name{rho} 4 | \alias{rho} 5 | \title{Extracting the autocorrelation parameter} 6 | \usage{ 7 | rho(object) 8 | } 9 | \arguments{ 10 | \item{object}{a praislm or twoStepsBenchmark object.} 11 | } 12 | \value{ 13 | a double of length 1. 14 | } 15 | \description{ 16 | The function \code{rho} returns the autocorrelation parameter 17 | from either a \link{praislm} or a \link{twoStepsBenchmark} object. 18 | If \code{include.rho} is \code{FALSE}, \code{rho} returns zero. 19 | } 20 | \examples{ 21 | benchmark <- twoStepsBenchmark(turnover,construction,include.rho = TRUE); rho(benchmark) 22 | 23 | } 24 | \keyword{internal} 25 | -------------------------------------------------------------------------------- /man/se.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods.R 3 | \name{se} 4 | \alias{se} 5 | \title{Extracting the standard error} 6 | \usage{ 7 | se(object) 8 | } 9 | \arguments{ 10 | \item{object}{a praislm or twoStepsBenchmark object.} 11 | } 12 | \value{ 13 | a numeric, that is named the same way that the coefficients are. 14 | If some coefficients are set by the user, they return \code{NA} as for 15 | their standard error. 16 | } 17 | \description{ 18 | The function \code{se} returns the standard error of the coefficients 19 | from either a \link{praislm} or a \link{twoStepsBenchmark} object. 20 | } 21 | \keyword{internal} 22 | -------------------------------------------------------------------------------- /man/smoothed.part.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods.R 3 | \name{smoothed.part} 4 | \alias{smoothed.part} 5 | \title{Extracting the smoothed part of a twoStepsBenchmark} 6 | \usage{ 7 | smoothed.part(object) 8 | } 9 | \arguments{ 10 | \item{object}{a twoStepsBenchmark object.} 11 | } 12 | \value{ 13 | a time series 14 | } 15 | \description{ 16 | The function \code{smoothed.part} returns the smoothed part of a 17 | \link{twoStepsBenchmark}. It derives from the residuals of the 18 | aggregated regression, with some differences : 19 | \itemize{ 20 | \item it is eventually integrated if \code{include.differenciation=TRUE}. 21 | \item it is extrapolated to match the domain window. 22 | \item it is smoothed using the \link{bflSmooth} function. 23 | } 24 | } 25 | \examples{ 26 | benchmark <- twoStepsBenchmark(turnover,construction); smoothed.part(benchmark) 27 | 28 | } 29 | \keyword{internal} 30 | -------------------------------------------------------------------------------- /man/smoothed.rate.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods.R 3 | \name{smoothed.rate} 4 | \alias{smoothed.rate} 5 | \title{Extracting the rate of a threeRuleSmooth} 6 | \usage{ 7 | smoothed.rate(object) 8 | } 9 | \arguments{ 10 | \item{object}{a threeRuleSmooth object.} 11 | } 12 | \description{ 13 | The function \code{smoothed.rate} returns the high-frequency rate 14 | from a \link{threeRuleSmooth} object. 15 | } 16 | \examples{ 17 | benchmark <- threeRuleSmooth(turnover,construction); smoothed.rate(benchmark) 18 | 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/threeRuleSmooth.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/threeRuleSmooth.R 3 | \name{threeRuleSmooth} 4 | \alias{threeRuleSmooth} 5 | \title{Bends a time series with a lower frequency one by smoothing their rate} 6 | \usage{ 7 | threeRuleSmooth( 8 | hfserie, 9 | lfserie, 10 | start.benchmark = NULL, 11 | end.benchmark = NULL, 12 | start.domain = NULL, 13 | end.domain = NULL, 14 | start.delta.rate = NULL, 15 | end.delta.rate = NULL, 16 | set.delta.rate = NULL, 17 | ... 18 | ) 19 | } 20 | \arguments{ 21 | \item{hfserie}{the bended time series. It can be a matrix time series.} 22 | 23 | \item{lfserie}{a time series whose frequency divides the frequency of 24 | \code{hfserie}.} 25 | 26 | \item{start.benchmark}{an optional start for \code{lfserie} to bend \code{hfserie}. 27 | Should be a numeric of length 1 or 2, like a window for \code{lfserie}. If NULL, 28 | the start is defined by lfserie's window.} 29 | 30 | \item{end.benchmark}{an optional end for \code{lfserie} to bend \code{hfserie}. 31 | Should be a numeric of length 1 or 2, like a window for \code{lfserie}. If NULL, 32 | the start is defined by lfserie's window.} 33 | 34 | \item{start.domain}{an optional start of the output high-frequency series. It 35 | also defines the smoothing window : 36 | The low-frequency residuals will be extrapolated until they contain the 37 | smallest low-frequency window that is around the high-frequency domain 38 | window. 39 | Should be a numeric of length 1 or 2, like a window for \code{hfserie}. If NULL, 40 | the start is defined by hfserie's window.} 41 | 42 | \item{end.domain}{an optional end of the output high-frequency series. It also 43 | defines the smoothing window : 44 | The low-frequency residuals will be extrapolated until they contain the 45 | smallest low-frequency window that is around the high-frequency domain 46 | window.} 47 | 48 | \item{start.delta.rate}{an optional start for the mean of the rate difference. 49 | It is required as a common difference for the arithmetical extrapolation of 50 | the rate. 51 | Should be a numeric of length 1 or 2, like a window for \code{lfserie}. If NULL, 52 | the start is defined by lfserie's window.} 53 | 54 | \item{end.delta.rate}{an optional end for the mean of the rate difference. 55 | It is required as a common difference for the arithmetical extrapolation of 56 | the rate. 57 | Should be a numeric of length 1 or 2, like a window for \code{lfserie}. If NULL, 58 | the end is defined by lfserie's window.} 59 | 60 | \item{set.delta.rate}{an optional double, that allows the user to set the 61 | delta mean instead of using a mean.} 62 | 63 | \item{\dots}{if the dots contain a cl item, its value overwrites the value 64 | of the returned call. This feature allows to build wrappers.} 65 | } 66 | \value{ 67 | threeRuleSmooth returns an object of class \code{"threeRuleSmooth"}. 68 | 69 | The functions \code{plot} and \code{autoplot} (the generic from \pkg{ggplot2}) produce 70 | graphics of the benchmarked series and the bending series. 71 | The functions \link{in_disaggr}, \link{in_revisions}, \link{in_scatter} 72 | produce various comparisons on which plot and autoplot can also be used. 73 | 74 | The generic accessor functions \code{as.ts}, \code{model.list}, \code{smoothed.rate} extract 75 | various useful features of the returned value. 76 | 77 | An object of class \code{"threeRuleSmooth"} is a list containing the following 78 | components : 79 | 80 | \item{benchmarked.serie}{a time series, that is the result of the 81 | benchmark.} 82 | \item{lfrate}{a time series, that is the low-frequency rate of the 83 | threeRuleSmooth.} 84 | \item{smoothed.rate}{the smoothed rate of the threeRuleSmooth.} 85 | \item{hfserie.as.weights}{the modified and extrapolated hfserie (see 86 | details).} 87 | \item{delta.rate}{the low-frequency delta of the rate, used to extrapolate 88 | the low-frequenccy rate time series. It is estimated as the mean value in 89 | the specified window.} 90 | \item{model.list}{a list containing all the arguments submitted to the 91 | function.} 92 | \item{call}{the matched call.} 93 | } 94 | \description{ 95 | threeRuleSmooth bends a time series with a time series of a lower 96 | frequency. The procedure involved is a proportional Denton benchmark. 97 | 98 | Therefore, the resulting time series is the product of the high frequency input 99 | with a smoothed rate. This latter is extrapolated through an arithmetic 100 | sequence. 101 | 102 | The resulting time series is equal to the low-frequency series after aggregation 103 | within the benchmark window. 104 | } 105 | \details{ 106 | In order to smooth the rate, threeRuleSmooth calls \link{bflSmooth} 107 | and uses a modified and extrapolated version of hfserie as weights : 108 | \itemize{ 109 | \item only the full cycles are kept 110 | \item the first and last full cycles are replicated respectively backwards and 111 | forwards to fill the domain window. 112 | } 113 | } 114 | \examples{ 115 | 116 | ## How to use threeRuleSmooth 117 | 118 | smooth <- threeRuleSmooth(hfserie = turnover, 119 | lfserie = construction) 120 | as.ts(smooth) 121 | coef(smooth) 122 | summary(smooth) 123 | library(ggplot2) 124 | autoplot(in_disaggr(smooth)) 125 | 126 | } 127 | -------------------------------------------------------------------------------- /man/turnover.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{turnover} 5 | \alias{turnover} 6 | \title{Turnover indicator in construction} 7 | \format{ 8 | A time series of frequency 12 9 | } 10 | \source{ 11 | \url{https://www.insee.fr/fr/statistiques/4636032} 12 | } 13 | \usage{ 14 | turnover 15 | } 16 | \description{ 17 | An monthly time series containing the turnover indicator in construction 18 | from january 2000 to may 2020, as retrieved the 08/12/2020. 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/turnover_catering.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{turnover_catering} 5 | \alias{turnover_catering} 6 | \title{Turnover indicator in accommodation and food services} 7 | \format{ 8 | A time series of frequency 12 9 | } 10 | \source{ 11 | \url{https://www.insee.fr/en/statistiques/serie/010543406} 12 | } 13 | \usage{ 14 | turnover_catering 15 | } 16 | \description{ 17 | An monthly time series containing the turnover indicator in accommodation and food services 18 | from january 1999 to april 2022, as retrieved the 04/07/2022. 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(disaggR) 3 | 4 | test_check("disaggR") 5 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot/gg-indicator-changes-2008-4-2012-7-gt44.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 | -2 43 | 0 44 | 2 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 2009 54 | 2010 55 | 2011 56 | 2012 57 | 58 | Changes 59 | 60 | 61 | 62 | 63 | Benchmark 64 | High-frequency serie 65 | 66 | 67 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot/gg-indicator-changes-2008-4-2012-7-lt43.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 | -2 43 | 0 44 | 2 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 2009 54 | 2010 55 | 2011 56 | 2012 57 | 58 | Changes 59 | 60 | 61 | 62 | 63 | Benchmark 64 | High-frequency serie 65 | 66 | 67 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot/gg-indicator-changes-2008-4-2012-7-smooth-gt44.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 | -2 43 | 0 44 | 2 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 2009 54 | 2010 55 | 2011 56 | 2012 57 | 58 | Changes 59 | 60 | 61 | 62 | 63 | Benchmark 64 | High-frequency serie 65 | 66 | 67 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot/gg-indicator-changes-2008-4-2012-7-smooth-lt43.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 | -2 43 | 0 44 | 2 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 2009 54 | 2010 55 | 2011 56 | 2012 57 | 58 | Changes 59 | 60 | 61 | 62 | 63 | Benchmark 64 | High-frequency serie 65 | 66 | 67 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot/gg-indicator-levels-2008-4-2012-7-gt44.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 | 25 44 | 50 45 | 75 46 | 100 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 2009 57 | 2010 58 | 2011 59 | 2012 60 | 61 | Levels 62 | 63 | 64 | 65 | 66 | Benchmark 67 | High-frequency serie 68 | 69 | 70 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot/gg-indicator-levels-2008-4-2012-7-lt43.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 | 25 44 | 50 45 | 75 46 | 100 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 2009 57 | 2010 58 | 2011 59 | 2012 60 | 61 | Levels 62 | 63 | 64 | 65 | 66 | Benchmark 67 | High-frequency serie 68 | 69 | 70 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot/gg-indicator-levels-2008-4-2012-7-smooth-gt44.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 | 25 44 | 50 45 | 75 46 | 100 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 2009 57 | 2010 58 | 2011 59 | 2012 60 | 61 | Levels 62 | 63 | 64 | 65 | 66 | Benchmark 67 | High-frequency serie 68 | 69 | 70 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot/gg-insample-changes-2008-2012-gt44.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 | -4 43 | 0 44 | 4 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 2009 54 | 2010 55 | 2011 56 | 2012 57 | 58 | Changes 59 | 60 | 61 | 62 | 63 | Benchmark 64 | Predicted value 65 | 66 | 67 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot/gg-insample-changes-2008-2012-lt43.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 | -4 43 | 0 44 | 4 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 2009 54 | 2010 55 | 2011 56 | 2012 57 | 58 | Changes 59 | 60 | 61 | 62 | 63 | Benchmark 64 | Predicted value 65 | 66 | 67 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot/gg-insample-levels-2008-2012-gt44.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 | 210 45 | 215 46 | 220 47 | 225 48 | 230 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 2009 60 | 2010 61 | 2011 62 | 2012 63 | 64 | Levels 65 | 66 | 67 | 68 | 69 | Benchmark 70 | Predicted value 71 | 72 | 73 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot/gg-insample-levels-2008-2012-lt43.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 | 210 45 | 215 46 | 220 47 | 225 48 | 230 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 2009 60 | 2010 61 | 2011 62 | 2012 63 | 64 | Levels 65 | 66 | 67 | 68 | 69 | Benchmark 70 | Predicted value 71 | 72 | 73 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot/plot-insample-changes-2008-2012-gt44.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 | Benchmark 45 | Predicted value 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -6 57 | -4 58 | -2 59 | 0 60 | 2 61 | 4 62 | 6 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 2008 71 | 2009 72 | 2010 73 | 2011 74 | 2012 75 | 76 | 77 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot/plot-insample-changes-2008-2012-lt43.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 | Benchmark 45 | Predicted value 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -6 57 | -4 58 | -2 59 | 0 60 | 2 61 | 4 62 | 6 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 2008 71 | 2009 72 | 2010 73 | 2011 74 | 2012 75 | 76 | 77 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot/plot-insample-levels-2008-2012-gt44.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 | Benchmark 43 | Predicted value 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 210 53 | 215 54 | 220 55 | 225 56 | 230 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 2008 65 | 2009 66 | 2010 67 | 2011 68 | 2012 69 | 70 | 71 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot/plot-insample-levels-2008-2012-lt43.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 | Benchmark 43 | Predicted value 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 210 53 | 215 54 | 220 55 | 225 56 | 230 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 2008 65 | 2009 66 | 2010 67 | 2011 68 | 2012 69 | 70 | 71 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot/plot-scatter-2008-2012-smooth-gt44.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 | 2009 50 | 2010 51 | 2011 52 | 2012 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 210 61 | 215 62 | 220 63 | 225 64 | 65 | 66 | 67 | 68 | 69 | 1180 70 | 1200 71 | 1220 72 | 1240 73 | 74 | 75 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/plot/plot-scatter-2008-2012-smooth-lt43.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 | 2009 50 | 2010 51 | 2011 52 | 2012 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 210 61 | 215 62 | 220 63 | 225 64 | 65 | 66 | 67 | 68 | 69 | 1180 70 | 1200 71 | 1220 72 | 1240 73 | 74 | 75 | -------------------------------------------------------------------------------- /tests/testthat/shiny-outliers/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | library(disaggR) 3 | ui <- disaggR:::reView_ui() 4 | 5 | server <- disaggR:::reView_server(twoStepsBenchmark(turnover,construction, 6 | outliers = list(AO2005 = rep(0.1,12L))), 7 | as.symbol("turnover"),as.symbol("construction"), 8 | TRUE) 9 | 10 | shinyApp(ui = ui, server = server) 11 | -------------------------------------------------------------------------------- /tests/testthat/shiny-outlierssetcoef/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | library(disaggR) 3 | ui <- disaggR:::reView_ui() 4 | 5 | server <- disaggR:::reView_server(twoStepsBenchmark(turnover,construction, 6 | outliers = list(AO2005 = rep(0.1,12L)), 7 | set.coeff = c(AO2005 = 1)), 8 | as.symbol("turnover"),as.symbol("construction"), 9 | TRUE) 10 | 11 | shinyApp(ui = ui, server = server) 12 | -------------------------------------------------------------------------------- /tests/testthat/shiny-setcoefconst/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | library(disaggR) 3 | ui <- disaggR:::reView_ui() 4 | 5 | server <- disaggR:::reView_server( 6 | twoStepsBenchmark(turnover,construction, 7 | set.coeff = 1, 8 | set.const = 0, 9 | include.differenciation = TRUE, 10 | include.rho = TRUE, 11 | start.coeff.calc = 2005,end.coeff.calc = 2015, 12 | start.benchmark = 2004,end.benchmark = 2018, 13 | start.domain = 1990,end.domain = c(2030,12)), 14 | quote(2*x+1),as.symbol("construction"), 15 | TRUE) 16 | 17 | shinyApp(ui = ui, server = server) 18 | -------------------------------------------------------------------------------- /tests/testthat/shiny-withoutset/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | library(disaggR) 3 | ui <- disaggR:::reView_ui() 4 | 5 | server <- disaggR:::reView_server(twoStepsBenchmark(turnover,construction), 6 | as.symbol("turnover"),as.symbol("construction"), 7 | TRUE) 8 | 9 | shinyApp(ui = ui, server = server) -------------------------------------------------------------------------------- /tests/testthat/test-praislm.R: -------------------------------------------------------------------------------- 1 | test_that("omega inv sqrt monovar", { 2 | expect_equal(omega_inv_sqrt(c(1,5,6,7),0.5) %>% unname, 3 | c(sqrt(0.75),4.5,3.5,4)) 4 | }) 5 | 6 | test_that("error praislm", { 7 | expect_error(praislm(ts(matrix(1:10,ncol=1),start=2011),ts(matrix(1:10,ncol=1),start=2010),FALSE,FALSE,numeric(),NULL), 8 | "same windows and frequencies") 9 | expect_error(praislm(1:120,ts(1:10,frequency=1,start=2010), 10 | TRUE,numeric(),NULL),"ts object") 11 | expect_error(praislm(ts(1:120,frequency=12,start=2010),1:10, 12 | TRUE,numeric(),NULL),"ts object") 13 | expect_error(praislm(ts(matrix(1,1,1),frequency=1,start=2010), 14 | ts(1,frequency=1,start=2010), 15 | FALSE, TRUE, numeric(), NULL),"less than two observations") 16 | expect_error(praislm(ts(structure(c(1, 1, pi, 17 * pi), 17 | dim = c(2L, 2L), 18 | dimnames = list(NULL, c("constant", "hfserie"))), 19 | frequency=1,start=2010), 20 | ts(c(99,-4),frequency=1,start=2010), 21 | TRUE, FALSE, numeric(), NULL),"rank becomes imperfect") 22 | }) 23 | 24 | test_that("max iter",{ 25 | expect_warning(praislm_impl(matrix(c(1.324398899494450,-0.953033704627492,0.153551486265972),ncol=1), 26 | c(26.080220590193644,-20.148635100560220,2.606520694629608),TRUE), 27 | "Maximum iterations") 28 | }) 29 | -------------------------------------------------------------------------------- /vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | --------------------------------------------------------------------------------