Repository: stan-dev/posteriordb (language: python)

Issue:
Update python stan methods
Add backend options for stan framework. (`"pystan", "pystan2", "cmdtanpy"`)

Add CmdStanPy as the default Stan backend.

Change code to work with PyStan (3+).

Adds `posteriordb.STAN_BACKEND` "global" variable that is used automatically by `posterior` class.

To change this value users can call `posteriordb.change_stan_backend` function which accepts `{"cmdstanpy", "pystan", "pystan2"}`


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/posteriordb_content.yml b/.github/workflows/posteriordb_content.yml
new file mode 100644
index 00000000..6027baab
--- /dev/null
+++ b/.github/workflows/posteriordb_content.yml
@@ -0,0 +1,61 @@
+# Check posteriordb
+name: check_posteriordb_content
+
+on:
+  push:
+    branches:
+      - master
+      - development
+    paths:
+      - 'posterior_database'
+      - 'tests'
+  pull_request:
+    branches:
+      - master
+      - development
+
+jobs:
+  models:
+    name: Check posteriordb content
+    runs-on: ${{ matrix.config.os }}
+    strategy:
+      matrix:
+        config:
+          - {os: ubuntu-latest,     r: 'release'}
+      fail-fast: false
+    env:
+      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
+    steps:
+      - uses: actions/checkout@master
+
+      - uses: r-lib/actions/setup-r@master
+
+      - id: files
+        uses: jitterbit/get-changed-files@v1
+
+      - run: |
+          echo "${{ steps.files.outputs.added_modified }}" >> "added_modified.txt"
+
+      - name: Install curl
+        if: runner.os == 'Linux'
+        run: |
+          sudo apt-get install libcurl4-openssl-dev
+
+      - name: Cache R packages
+        if: runner.os != 'Windows'
+        uses: actions/cache@v1
+        with:
+          path: ${{ env.R_LIBS_USER }}
+          key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{ hashFiles('DESCRIPTION') }}
+
+      - name: Install packages
+        run: |
+          R -e 'install.packages(c("remotes"))'
+          R -e 'remotes::install_github("stan-dev/posteriordb-r", dependencies = TRUE)'
+
+      - name: Set PDB path
+        run: export PDB_PATH=$GITHUB_WORKSPACE;echo $PDB_PATH;echo PDB_PATH="$PDB_PATH" >> ~/.Renviron;ls $PDB_PATH
+        shell: bash
+
+      - name: Check PDB content
+        run: Rscript tests/check_posteriordb_content.R
diff --git a/.github/workflows/workflow-python.yml b/.github/workflows/workflow-python.yml
deleted file mode 100644
index 805a2ab8..00000000
--- a/.github/workflows/workflow-python.yml
+++ /dev/null
@@ -1,86 +0,0 @@
-name: Python
-
-on:
-  push:
-    branches:
-      - '**'
-    tags:
-      - '**'
-
-jobs:
-  models:
-    name: Python Tests
-    runs-on: ${{ matrix.os }}
-    strategy:
-      matrix:
-          os: [ubuntu-latest, macos-latest, windows-latest]
-          python-version: [3.6, 3.7, 3.8, 3.9]
-      fail-fast: false
-    env:
-      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
-    steps:
-      - name: Checkout github
-        uses: actions/checkout@v2
-        with:
-          fetch-depth: 0
-
-      - name: Set up Python ${{ matrix.python-version }}
-        uses: actions/setup-python@v1
-        with:
-          python-version: ${{ matrix.python-version }}
-
-      - name: Install python dependencies
-        run: |
-          pip install --upgrade pip wheel
-          pip install tox-gh-actions codecov
-
-      - name: Tox
-        run: |
-          cd python
-          tox
-          #codecov
-
-      - name: Build wheel
-        run: |
-          cd python
-          python setup.py bdist_wheel
-
-      - name: Install wheel
-        if: matrix.os != 'windows-latest'
-        run: |
-          python -m pip install python/dist/*.whl
-
-      - name: Install wheel [Windows]
-        if: matrix.os == 'windows-latest'
-        run: |
-          $whl = Get-ChildItem -Path python/dist -Filter *.whl | Select-Object -First 1
-          python -m pip install "$whl"
-
-      - name: Show libraries
-        run: |
-          python -m pip freeze
-
-      - uses: actions/upload-artifact@v2
-        if: success() && matrix.os == 'ubuntu-latest'
-        with:
-          name: posteriordb_wheel
-          path: python/dist/*.whl
-
-      - name: Upload wheel to release
-        uses: svenstaro/upload-release-action@v1-release
-        if: success() && startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-latest'
-        with:
-          repo_token: ${{ secrets.GITHUB_TOKEN }}
-          file: python/dist/*.whl
-          tag: ${{ github.ref }}
-          overwrite: true
-          file_glob: true
-
-      - name: Upload to pypi
-        if: success() && startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-latest'
-        env:
-          TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
-          TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
-        run: |
-          python -m pip install --no-cache-dir twine
-          python -m twine upload -u ${TWINE_USERNAME} -p ${TWINE_PASSWORD} --skip-existing python/dist/*
diff --git a/.github/workflows/workflow-r.yml b/.github/workflows/workflow-r.yml
deleted file mode 100644
index 1af38c6b..00000000
--- a/.github/workflows/workflow-r.yml
+++ /dev/null
@@ -1,121 +0,0 @@
-name: R
-
-on:
-  push:
-    branches:
-      - '**'
-    tags:
-      - '**'
-
-jobs:
-  models:
-    name: R Tests
-    runs-on: ${{ matrix.config.os }}
-    strategy:
-      matrix:
-        config:
-          - {os: ubuntu-latest,     r: 'release'}
-          - {os: ubuntu-latest,     r: 'oldrel'}
-          - {os: macos-latest,       r: 'release'}
-          - {os: windows-latest,   r: 'release'}
-      fail-fast: false
-    env:
-      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
-      _R_CHECK_TESTS_NLINES_: 0
-    steps:
-      - name: Checkout github
-        uses: actions/checkout@v2
-        with:
-          fetch-depth: 0
-
-      - name: Set up R ${{ matrix.config.r }}
-        uses: r-lib/actions/setup-r@v1
-        with:
-          r-version: ${{ matrix.config.r }}
-
-      - uses: r-lib/actions/setup-tinytex@v1
-
-      - run: tlmgr --version
-
-      - uses: r-lib/actions/setup-pandoc@master
-
-      - name: Cache R packages
-        if: runner.os != 'Windows'
-        uses: actions/cache@v1
-        with:
-          path: ${{ env.R_LIBS_USER }}
-          key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{ hashFiles('DESCRIPTION') }}
-          restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-
-
-      - name: Install dependencies (Ubuntu)
-        if: matrix.config.os == 'ubuntu-latest'
-        run: |
-          sudo apt-get update
-          sudo apt-get install libcurl4-openssl-dev libv8-dev
-
-      - name: Install R dependencies
-        run: |
-          options(install.packages.check.source = "no")
-          install.packages('posterior', repos = c('https://mc-stan.org/r-packages/', getOption('repos')))
-          options(pkgType = ifelse(grepl("linux", R.version$os), "source", "binary"))
-          install.packages('remotes')
-          install.packages('jsonlite')
-          install.packages('V8')
-          install.packages('covr')
-          install.packages('testthat')
-          install.packages('git2r')
-          install.packages('gh')
-          install.packages('bibtex')
-          install.packages('rstan', repos = 'https://cloud.r-project.org/', dependencies = TRUE)
-          writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
-        shell: Rscript {0}
-
-      - name: R version info (Ubuntu and macOS)
-        if: runner.os != 'Windows'
-        run: |
-          Rscript -e 'sessionInfo();cat("\nInstalled R packages:\n", paste(installed.packages()[,"Package"], installed.packages()[,"Version"], "\n"))'
-
-      - name: R version info (Windows)
-        if: runner.os == 'Windows'
-        run: |
-          RScript -e "sessionInfo();cat('\nInstalled R packages:\n', paste(installed.packages()[,'Package'], installed.packages()[,'Version'], '\n'))"
-
-      - name: Run R tests (Ubuntu)
-        if: matrix.config.os == 'ubuntu-latest'
-        run: |
-          R CMD build rpackage
-          R CMD check posteriordb_*.tar.gz
-
-      - name: Run R tests (macOS)
-        if: matrix.config.os == 'macos-latest'
-        run: |
-          export LC_ALL=C
-          export LANG=C
-          R CMD build rpackage
-          R CMD check posteriordb_*.tar.gz
-
-      - name: Run R tests (Windows)
-        if: matrix.config.os == 'windows-latest'
-        run: |
-          RCMD build rpackage
-          RCMD check posteriordb_*.tar.gz
-
-      - name: debug logs
-        if: failure() && (matrix.config.os == 'ubuntu-latest')
-        uses: actions/upload-artifact@v2
-        with:
-          name: exception_results_${{ matrix.config.os}}_${{ matrix.config.r}}
-          path: /home/runner/work/posteriordb/posteriordb/posteriordb.Rcheck/*.log
-
-      - name: debug logs
-        if: failure() && (matrix.config.os == 'macos-latest')
-        uses: actions/upload-artifact@v2
-        with:
-          name: exception_results_${{ matrix.config.os}}_${{ matrix.config.r}}
-          path: /Users/runner/work/posteriordb/posteriordb/posteriordb.Rcheck/*.log
-
-      - name: Codecov
-        if: (matrix.config.r == 'release') && (matrix.config.os == 'macos-latest')
-        run: |
-          echo $GITHUB_WORKSPACE
-          Rscript -e "covr::codecov(path = 'rpackage', quiet = FALSE)"
diff --git a/.gitignore b/.gitignore
index 825220ef..f52c457a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,3 +12,7 @@ python/build*
 sandbox/*
 TODO.tdl
 .Rhistory
+*.exe
+*.hpp
+*.dll
+tmp*
diff --git a/CITATION.cff b/CITATION.cff
new file mode 100644
index 00000000..e858efc1
--- /dev/null
+++ b/CITATION.cff
@@ -0,0 +1,12 @@
+cff-version: 1.2.0
+message: "If you use posteriordb, please cite it as below."
+authors:
+  - family-names: Magnusson
+    given-names: Måns
+  - family-names: Bürkner
+    given-names: Paul
+  - family-names: Vehtari
+    given-names: Aki
+title: "posteriordb: a set of posteriors for Bayesian inference and probabilistic programming"
+version: 0.2.1
+date-released: 2021-09-10
diff --git a/README.Rmd b/README.Rmd
index 3313bc13..720e1e47 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -6,10 +6,7 @@ output:
 
 <!-- README.md is generated from README.Rmd. Please edit that file -->
 
-
-[![CRAN status](https://www.r-pkg.org/badges/version/posterior)](https://CRAN.R-project.org/package=posterior)
-[![R build status](https://github.com/stan-dev/posteriordb/workflows/R/badge.svg)](https://github.com/stan-dev/posteriordb/actions)
-[![Python build status](https://github.com/stan-dev/posteriordb/workflows/Python/badge.svg)](https://github.com/stan-dev/posteriordb/actions)
+[![R-CMD-check](https://github.com/stan-dev/posteriordb-r/actions/workflows/check-release.yaml/badge.svg)](https://github.com/stan-dev/posteriordb-r/actions/workflows/check-release.yaml) [![Codecov test coverage](https://codecov.io/gh/stan-dev/posteriordb-r/branch/main/graph/badge.svg)](https://codecov.io/gh/stan-dev/posteriordb-r?branch=main)
 
 
 # `posteriordb`: a database of Bayesian posterior inference
@@ -20,17 +17,15 @@ output:
 
 ## Why use `posteriordb`?
 
-`posteriordb` is designed to test inference algorithms across a wide range of models and data sets.  Applications include testing for accuracy, testing for speed, and testing for scalability.  Algorithms being tested may be approximate like variational inference or asymptotically exact like Markov chain Monte Carlo.  `posteriordb` can be used to test new algorithms being developed or deployed as part of continuous integration for ongoing regression testing of algorithms in probabilistic programming frameworks.
+`posteriordb` is designed to test inference algorithms across a wide range of models and data sets.  Applications include testing for accuracy, speed, and scalability. `posteriordb` can be used to test new algorithms being developed or deployed as part of continuous integration for ongoing regression testing algorithms in probabilistic programming frameworks.
 
-`posteriordb` also makes it easy for students and instructors to access a range of pedagogical and real-world examples with precise model definitions, well-curated data sets, and reference posteriors.
+`posteriordb` also makes it easy for students and instructors to access various pedagogical and real-world examples with precise model definitions, well-curated data sets, and reference posteriors.
 
 `posteriordb` is framework agnostic and easily accessible from R and Python.
 
 For more details regarding the use cases of  `posteriordb`, see [doc/use_cases.md](https://github.com/stan-dev/posteriordb/blob/master/doc/use_cases.md).
 
 
-
-
 ## Content
 
 See [DATABASE_CONTENT.md](https://github.com/stan-dev/posteriordb/blob/master/doc/DATABASE_CONTENT.md) for the details content of the posterior database.
@@ -40,89 +35,12 @@ See [DATABASE_CONTENT.md](https://github.com/stan-dev/posteriordb/blob/master/do
 We are happy with any help in adding posteriors, data, and models to the database! See [CONTRIBUTING.md](https://github.com/stan-dev/posteriordb/blob/master/doc/CONTRIBUTING.md) for the details on how to contribute.
 
 
-## Quick usage of the posterior database from R
-
-Install the package from GitHub
-
-```{r, eval = FALSE}
-remotes::install_github("stan-dev/posteriordb", subdir = "rpackage")
-```
-
-Load the R package and load a posterior from the default posteriordb.
-
-```{r}
-library(posteriordb)
-pd <- pdb_default() # Posterior database connection
-pn <- posterior_names(pd)
-head(pn)
-```
-
-```{r}
-po <- pdb_posterior("eight_schools-eight_schools_centered", pdb = pd)
-po
-```
-
-From the posterior, we can easily access data and models as
-
-```{r}
-sc <- pdb_stan_code(x = po)
-sc
-```
-
-We can get additional information about the model by using `info()`.
-
-```{r}
-info(sc)
-```
-
-To access data for a specific posterior, we can use `pdb_data()`
+## Using `posteriordb`
 
-```{r}
-dat <- pdb_data(po)
-dat
-```
+To simplify the use of `posteriordb`, there are convenience functions both in Python and in R. To use R, see the [posteriordb-r](https://github.com/stan-dev/posteriordb-r) repository, and to use Python, see the [posteriordb-python](https://github.com/stan-dev/posteriordb-python) repository.
 
-Again, we can get additional information about the data by using `info()`.
-
-```{r}
-info(dat)
-```
-
-Finally, we can access reference posterior draws for the given posterior.
-
-```{r}
-rpd <- reference_posterior_draws(po)
-```
-
-The posterior is based on the [posterior](https://github.com/jgabry/posterior) R package structure and can easily be summarized and transformed using the `posterior` R package.
-
-```{r}
-library(posterior)
-summarize_draws(rpd)
-```
-
-Using `info()`, we can access more detailed information on the reference posterior draws.
-
-```{r}
-info(rpd)
-```
-
-It is also possible to access only information for models, data, and draws as follows.
-
-```{r}
-pdb_model_info(po)
-pdb_data_info(po)
-pdb_reference_posterior_draws_info(po)
-```
-
-## Using the posterior database from python
-See [python README](./python/README.md)
-
-## Using the posterior database from R (extensive)
-See [R README](./rpackage/README.md)
 
 ## Design choices (so far)
-
 The main focus of the database is simplicity, both in understanding and in use.
 
 The following are the current design choices in designing the posterior database.
@@ -136,3 +54,6 @@ The following are the current design choices in designing the posterior database
 1. Prefix 'syn_' stands for synthetic data where the generative process is known and found in content/data-raw.
 1. All data preprocessing is included in content/data-raw.
 1. Specific information for different PPL representations of models is included in the PPL syntax files as comments, not in the model.info.json files.
+
+## Versioning of models
+We might update models included in posteriordb over time. However, the models will only have the same name in posteriordb if the log density is the same (up to a normalizing constant). Otherwise, we will include a new model in the database.
diff --git a/README.md b/README.md
index 140a054d..3ae2a589 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,8 @@
 <!-- README.md is generated from README.Rmd. Please edit that file -->
 
-[![CRAN
-status](https://www.r-pkg.org/badges/version/posterior)](https://CRAN.R-project.org/package=posterior)
-[![R build
-status](https://github.com/stan-dev/posteriordb/workflows/R/badge.svg)](https://github.com/stan-dev/posteriordb/actions)
-[![Python build
-status](https://github.com/stan-dev/posteriordb/workflows/Python/badge.svg)](https://github.com/stan-dev/posteriordb/actions)
-
+[![R-CMD-check](https://github.com/stan-dev/posteriordb-r/actions/workflows/check-release.yaml/badge.svg)](https://github.com/stan-dev/posteriordb-r/actions/workflows/check-release.yaml)
+[![Codecov test
+coverage](https://codecov.io/gh/stan-dev/posteriordb-r/branch/main/graph/badge.svg)](https://codecov.io/gh/stan-dev/posteriordb-r?branch=main)
 
 `posteriordb`: a database of Bayesian posterior inference
 =========================================================
@@ -24,15 +20,13 @@ Why use `posteriordb`?
 
 `posteriordb` is designed to test inference algorithms across a wide
 range of models and data sets. Applications include testing for
-accuracy, testing for speed, and testing for scalability. Algorithms
-being tested may be approximate like variational inference or
-asymptotically exact like Markov chain Monte Carlo. `posteriordb` can be
-used to test new algorithms being developed or deployed as part of
-continuous integration for ongoing regression testing of algorithms in
-probabilistic programming frameworks.
+accuracy, speed, and scalability. `posteriordb` can be used to test new
+algorithms being developed or deployed as part of continuous integration
+for ongoing regression testing algorithms in probabilistic programming
+frameworks.
 
 `posteriordb` also makes it easy for students and instructors to access
-a range of pedagogical and real-world examples with precise model
+various pedagogical and real-world examples with precise model
 definitions, well-curated data sets, and reference posteriors.
 
 `posteriordb` is framework agnostic and easily accessible from R and
@@ -56,196 +50,15 @@ database! See
 [CONTRIBUTING.md](https://github.com/stan-dev/posteriordb/blob/master/doc/CONTRIBUTING.md)
 for the details on how to contribute.
 
-Quick usage of the posterior database from R
---------------------------------------------
-
-Install the package from GitHub
-
-``` r
-remotes::install_github("stan-dev/posteriordb", subdir = "rpackage")
-```
-
-Load the R package and load a posterior from the default posteriordb.
-
-``` r
-library(posteriordb)
-pd <- pdb_default() # Posterior database connection
-pn <- posterior_names(pd)
-head(pn)
-```
-
-    ## [1] "arK-arK"                         "arma-arma11"                    
-    ## [3] "bball_drive_event_0-hmm_drive_0" "bball_drive_event_1-hmm_drive_1"
-    ## [5] "butterfly-multi_occupancy"       "diamonds-diamonds"
-
-``` r
-po <- pdb_posterior("eight_schools-eight_schools_centered", pdb = pd)
-po
-```
-
-    ## Posterior (eight_schools-eight_schools_centered)
-    ## 
-    ## Data: eight_schools
-    ## The 8 schools dataset of Rubin (1981)
-    ## 
-    ## Model: eight_schools_centered
-    ## A centered hiearchical model for 8 schools
-    ## Frameworks: 'stan', 'pymc3'
-
-From the posterior, we can easily access data and models as
-
-``` r
-sc <- pdb_stan_code(x = po)
-sc
-```
-
-    ## data {
-    ##   int <lower=0> J; // number of schools
-    ##   real y[J]; // estimated treatment
-    ##   real<lower=0> sigma[J]; // std of estimated effect
-    ## }
-    ## parameters {
-    ##   real theta[J]; // treatment effect in school j
-    ##   real mu; // hyper-parameter of mean
-    ##   real<lower=0> tau; // hyper-parameter of sdv
-    ## }
-    ## model {
-    ##   tau ~ cauchy(0, 5); // a non-informative prior
-    ##   theta ~ normal(mu, tau);
-    ##   y ~ normal(theta, sigma);
-    ##   mu ~ normal(0, 5);
-    ## }
-
-We can get additional information about the model by using `info()`.
-
-``` r
-info(sc)
-```
-
-    ## Model: eight_schools_centered
-    ## A centered hiearchical model for 8 schools
-    ## Frameworks: 'stan', 'pymc3'
-
-To access data for a specific posterior, we can use `pdb_data()`
-
-``` r
-dat <- pdb_data(po)
-dat
-```
-
-    ## $J
-    ## [1] 8
-    ## 
-    ## $y
-    ## [1] 28  8 -3  7 -1  1 18 12
-    ## 
-    ## $sigma
-    ## [1] 15 10 16 11  9 11 10 18
-
-Again, we can get additional information about the data by using
-`info()`.
-
-``` r
-info(dat)
-```
-
-    ## Data: eight_schools
-    ## The 8 schools dataset of Rubin (1981)
-
-Finally, we can access reference posterior draws for the given
-posterior.
+Using `posteriordb`
+-------------------
 
-``` r
-rpd <- reference_posterior_draws(po)
-```
-
-The posterior is based on the
-[posterior](https://github.com/jgabry/posterior) R package structure and
-can easily be summarized and transformed using the `posterior` R
-package.
-
-``` r
-library(posterior)
-```
-
-    ## This is posterior version 0.1.2
-
-``` r
-summarize_draws(rpd)
-```
-
-    ## # A tibble: 10 x 10
-    ##    variable  mean median    sd   mad     q5   q95  rhat ess_bulk ess_tail
-    ##    <chr>    <dbl>  <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl>    <dbl>    <dbl>
-    ##  1 theta[1]  6.15   5.59  5.62  4.56 -1.68  16.3   1.00   10095.    9732.
-    ##  2 theta[2]  4.94   4.77  4.65  4.14 -2.22  12.8   1.00   10049.   10139.
-    ##  3 theta[3]  3.91   4.11  5.28  4.48 -4.91  11.8   1.00    9533.    9339.
-    ##  4 theta[4]  4.80   4.70  4.77  4.22 -2.67  12.6   1.00   10026.    9666.
-    ##  5 theta[5]  3.61   3.82  4.61  4.15 -4.26  10.6   1.00    9922.   10207.
-    ##  6 theta[6]  4.05   4.16  4.80  4.32 -3.87  11.5   1.00    9783.   10039.
-    ##  7 theta[7]  6.32   5.80  5.00  4.39 -0.855 15.3   1.00   10039.    9690.
-    ##  8 theta[8]  4.88   4.79  5.32  4.47 -3.32  13.5   1.00    9605.    9871.
-    ##  9 mu        4.41   4.36  3.31  3.30 -0.936  9.83  1.00   10041.    9973.
-    ## 10 tau       3.60   2.75  3.20  2.55  0.257  9.73  1.00    9989.    9992.
-
-Using `info()`, we can access more detailed information on the reference
-posterior draws.
-
-``` r
-info(rpd)
-```
-
-    ## Posterior: eight_schools-eight_schools_noncentered
-    ## Method: stan_sampling (rstan 2.21.1)
-    ## Arguments:
-    ##   chains: 10
-    ##   iter: 20000
-    ##   warmup: 10000
-    ##   thin: 10
-    ##   seed: 4711
-    ##     adapt_delta: 0.95
-
-It is also possible to access only information for models, data, and
-draws as follows.
-
-``` r
-pdb_model_info(po)
-```
-
-    ## Model: eight_schools_centered
-    ## A centered hiearchical model for 8 schools
-    ## Frameworks: 'stan', 'pymc3'
-
-``` r
-pdb_data_info(po)
-```
-
-    ## Data: eight_schools
-    ## The 8 schools dataset of Rubin (1981)
-
-``` r
-pdb_reference_posterior_draws_info(po)
-```
-
-    ## Posterior: eight_schools-eight_schools_noncentered
-    ## Method: stan_sampling (rstan 2.21.1)
-    ## Arguments:
-    ##   chains: 10
-    ##   iter: 20000
-    ##   warmup: 10000
-    ##   thin: 10
-    ##   seed: 4711
-    ##     adapt_delta: 0.95
-
-Using the posterior database from python
-----------------------------------------
-
-See [python README](./python/README.md)
-
-Using the posterior database from R (extensive)
------------------------------------------------
-
-See [R README](./rpackage/README.md)
+To simplify the use of `posteriordb`, there are convenience functions
+both in Python and in R. To use R, see the
+[posteriordb-r](https://github.com/stan-dev/posteriordb-r) repository,
+and to use Python, see the
+[posteriordb-python](https://github.com/stan-dev/posteriordb-python)
+repository.
 
 Design choices (so far)
 -----------------------
@@ -273,3 +86,11 @@ database.
 7.  Specific information for different PPL representations of models is
     included in the PPL syntax files as comments, not in the
     model.info.json files.
+
+Versioning of models
+--------------------
+
+We might update models included in posteriordb over time. However, the
+models will only have the same name in posteriordb if the log density is
+the same (up to a normalizing constant). Otherwise, we will include a
+new model in the database.
diff --git a/doc/CONTRIBUTING.md b/doc/CONTRIBUTING.md
index 54c091d7..75db46e3 100644
--- a/doc/CONTRIBUTING.md
+++ b/doc/CONTRIBUTING.md
@@ -7,7 +7,7 @@ Don't hesitate to make a Pull Request (PR) with a new model, data, or posterior
 
 Copyright
 -------------
-All models supplied will use the BD3 license by default (see R package). It is possible to manually specify a license in data, model or reference posterior info object.
+All models supplied will use the BSD3 license by default (see R package). It is possible to specify an altenrative open-source license in data, model or reference posterior info object.
 
 Pull request workflow
 -------------
diff --git a/posterior_database/alias/posteriors.json b/posterior_database/alias/posteriors.json
index 47f01b7b..22d4e07b 100644
--- a/posterior_database/alias/posteriors.json
+++ b/posterior_database/alias/posteriors.json
@@ -10,5 +10,8 @@
   "irt_2pl": "irt_2pl-irt_2pl",
   "pkpd": "one_comp_mm_elim_abs-one_comp_mm_elim_abs",
   "sir": "sir-sir",
-  "covid19imperial_v2-covid19imperial_v2": "ecdc0401-covid19imperial_v2"
+  "low_dim_gauss_mix_collapse": "low_dim_gauss_mix_collapse-low_dim_gauss_mix_collapse",
+  "covid19imperial_v2-covid19imperial_v2": "ecdc0401-covid19imperial_v2",
+  "prideprejustice_chapter-ldaK5": "prideprejudice_chapter-ldaK5",
+  "prideprejustice_paragraph-ldaK5": "prideprejudice_paragraph-ldaK5"
 }
diff --git a/posterior_database/bibliography/references.bib b/posterior_database/bibliography/references.bib
index 691f05a3..3c2f68c7 100644
--- a/posterior_database/bibliography/references.bib
+++ b/posterior_database/bibliography/references.bib
@@ -6,6 +6,20 @@ @misc{furr2016hier
   month={Apr}
 }
 
+@book{kery2011population,
+  title={Bayesian population analysis using WinBUGS},
+  author={M Kery, M Schaub},
+  year={2011},
+  publisher={Academic Press}
+}
+
+@book{lee2013cognitive,
+  title={Bayesian Cognitive Modeling},
+  author={M D Lee, E Wagenmakers},
+  year={2013},
+  publisher={Cambridge University Press}
+}
+
 @article{glas2003computerized,
   title={Computerized adaptive testing with item cloning},
   author={Glas, Cees AW and van der Linden, Wim J},
@@ -128,8 +142,6 @@ @book{venables2013modern
   publisher={Springer Science \& Business Media}
 }
 
-
-
 @book{gelman2006data,
   title={Data analysis using regression and multilevel/hierarchical models},
   author={Gelman, Andrew and Hill, Jennifer},
@@ -205,7 +217,6 @@ @article{lampinen2001bayesian
   publisher={Elsevier}
 }
 
-
 @misc{jonasson2021rapid,
 Author = {Johan Jonasson and Måns Magnusson},
 Title = {Rapid mixing in unimodal landscapes and efficient simulated annealing for multimodal distributions},
@@ -219,3 +230,35 @@ @misc{farkas2014threemen
 url = {FarkasTranslations.com},
 Year = {2014},
 }
+
+@misc{reif2008bird,
+  Author = {Jil{\'i} Reif and David Storch and Petr Vol{\'i}nek and Karel Kpastn{\'y} and Vladim{\'i}r Bejbek},
+  Title = {Bird-habitat associations predict population trends in central European forest and farmland birds},
+  url = {https://link.springer.com/article/10.1007/s10531-008-9430-4},
+  Year = {2008},
+}
+
+@article{dimaggio2015small,
+  title={Small-area spatiotemporal analysis of pedestrian and bicyclist injuries in {New York City}},
+  author={DiMaggio, Charles},
+  journal={Epidemiology},
+  volume={26},
+  number={2},
+  pages={247--254},
+  year={2015},
+  publisher={JSTOR}
+}
+
+@article{flaxman2015fast,
+  title={Fast hierarchical Gaussian processes},
+  author={Flaxman, Seth and Gelman, Andrew and Neill, Daniel and Smola, Alex and Vehtari, Aki and Wilson, Andrew Gordon},
+  journal={Manuscript in preparation},
+  year={2015}
+}
+
+@book{reif1995euro,
+  title={Euro-barometer 38.1: Consumer protection and perceptions of science and technology, november 1992},
+  author={Reif, Karlheinz and Melich, Anna},
+  year={1995},
+  publisher={Inter-university Consortium for Political and Social Research}
+}
diff --git a/posterior_database/data/data/GLMM_Poisson_data.json.zip b/posterior_database/data/data/GLMM_Poisson_data.json.zip
new file mode 100644
index 00000000..bd59e73c
Binary files /dev/null and b/posterior_database/data/data/GLMM_Poisson_data.json.zip differ
diff --git a/posterior_database/data/data/GLMM_data.json.zip b/posterior_database/data/data/GLMM_data.json.zip
new file mode 100644
index 00000000..b2d98ddf
Binary files /dev/null and b/posterior_database/data/data/GLMM_data.json.zip differ
diff --git a/posterior_database/data/data/GLM_Binomial_data.json.zip b/posterior_database/data/data/GLM_Binomial_data.json.zip
new file mode 100644
index 00000000..306c7fcd
Binary files /dev/null and b/posterior_database/data/data/GLM_Binomial_data.json.zip differ
diff --git a/posterior_database/data/data/GLM_Poisson_Data.json.zip b/posterior_database/data/data/GLM_Poisson_Data.json.zip
new file mode 100644
index 00000000..8e67c72c
Binary files /dev/null and b/posterior_database/data/data/GLM_Poisson_Data.json.zip differ
diff --git a/posterior_database/data/data/M0_data.json.zip b/posterior_database/data/data/M0_data.json.zip
new file mode 100644
index 00000000..4b17b810
Binary files /dev/null and b/posterior_database/data/data/M0_data.json.zip differ
diff --git a/posterior_database/data/data/Mb_data.json.zip b/posterior_database/data/data/Mb_data.json.zip
new file mode 100644
index 00000000..25db09ec
Binary files /dev/null and b/posterior_database/data/data/Mb_data.json.zip differ
diff --git a/posterior_database/data/data/Mh_data.json.zip b/posterior_database/data/data/Mh_data.json.zip
new file mode 100644
index 00000000..c2911eaa
Binary files /dev/null and b/posterior_database/data/data/Mh_data.json.zip differ
diff --git a/posterior_database/data/data/Mt_data.json.zip b/posterior_database/data/data/Mt_data.json.zip
new file mode 100644
index 00000000..b529aa96
Binary files /dev/null and b/posterior_database/data/data/Mt_data.json.zip differ
diff --git a/posterior_database/data/data/Mtbh_data.json.zip b/posterior_database/data/data/Mtbh_data.json.zip
new file mode 100644
index 00000000..d08e31f8
Binary files /dev/null and b/posterior_database/data/data/Mtbh_data.json.zip differ
diff --git a/posterior_database/data/data/Mth_data.json.zip b/posterior_database/data/data/Mth_data.json.zip
new file mode 100644
index 00000000..ef8af83f
Binary files /dev/null and b/posterior_database/data/data/Mth_data.json.zip differ
diff --git a/posterior_database/data/data/Rate_1_data.json.zip b/posterior_database/data/data/Rate_1_data.json.zip
new file mode 100644
index 00000000..7466b3f9
Binary files /dev/null and b/posterior_database/data/data/Rate_1_data.json.zip differ
diff --git a/posterior_database/data/data/Rate_2_data.json.zip b/posterior_database/data/data/Rate_2_data.json.zip
new file mode 100644
index 00000000..466f56ad
Binary files /dev/null and b/posterior_database/data/data/Rate_2_data.json.zip differ
diff --git a/posterior_database/data/data/Rate_3_data.json.zip b/posterior_database/data/data/Rate_3_data.json.zip
new file mode 100644
index 00000000..01fff65f
Binary files /dev/null and b/posterior_database/data/data/Rate_3_data.json.zip differ
diff --git a/posterior_database/data/data/Rate_4_data.json.zip b/posterior_database/data/data/Rate_4_data.json.zip
new file mode 100644
index 00000000..48c08479
Binary files /dev/null and b/posterior_database/data/data/Rate_4_data.json.zip differ
diff --git a/posterior_database/data/data/Rate_5_data.json.zip b/posterior_database/data/data/Rate_5_data.json.zip
new file mode 100644
index 00000000..06706a1b
Binary files /dev/null and b/posterior_database/data/data/Rate_5_data.json.zip differ
diff --git a/posterior_database/data/data/Survey_data.json.zip b/posterior_database/data/data/Survey_data.json.zip
new file mode 100644
index 00000000..26474e17
Binary files /dev/null and b/posterior_database/data/data/Survey_data.json.zip differ
diff --git a/posterior_database/data/data/fims_Aus_Jpn_irt.json.zip b/posterior_database/data/data/fims_Aus_Jpn_irt.json.zip
new file mode 100644
index 00000000..55ecb3e4
Binary files /dev/null and b/posterior_database/data/data/fims_Aus_Jpn_irt.json.zip differ
diff --git a/posterior_database/data/data/hmm_gaussian_simulated.json.zip b/posterior_database/data/data/hmm_gaussian_simulated.json.zip
new file mode 100644
index 00000000..33890095
Binary files /dev/null and b/posterior_database/data/data/hmm_gaussian_simulated.json.zip differ
diff --git a/posterior_database/data/data/iohmm_reg_simulated.json.zip b/posterior_database/data/data/iohmm_reg_simulated.json.zip
new file mode 100644
index 00000000..86987876
Binary files /dev/null and b/posterior_database/data/data/iohmm_reg_simulated.json.zip differ
diff --git a/posterior_database/data/data/loss_curves.json.zip b/posterior_database/data/data/loss_curves.json.zip
new file mode 100644
index 00000000..67c9e338
Binary files /dev/null and b/posterior_database/data/data/loss_curves.json.zip differ
diff --git a/posterior_database/data/data/prideprejudice_chapter.json.zip b/posterior_database/data/data/prideprejudice_chapter.json.zip
new file mode 100644
index 00000000..c960fbae
Binary files /dev/null and b/posterior_database/data/data/prideprejudice_chapter.json.zip differ
diff --git a/posterior_database/data/data/prideprejudice_paragraph.json.zip b/posterior_database/data/data/prideprejudice_paragraph.json.zip
new file mode 100644
index 00000000..5a89836f
Binary files /dev/null and b/posterior_database/data/data/prideprejudice_paragraph.json.zip differ
diff --git a/posterior_database/data/data/prideprejustice_chapter.json.zip b/posterior_database/data/data/prideprejustice_chapter.json.zip
deleted file mode 100644
index 50901458..00000000
Binary files a/posterior_database/data/data/prideprejustice_chapter.json.zip and /dev/null differ
diff --git a/posterior_database/data/data/prideprejustice_paragraph.json.zip b/posterior_database/data/data/prideprejustice_paragraph.json.zip
deleted file mode 100644
index a3272777..00000000
Binary files a/posterior_database/data/data/prideprejustice_paragraph.json.zip and /dev/null differ
diff --git a/posterior_database/data/data/science_irt.json.zip b/posterior_database/data/data/science_irt.json.zip
new file mode 100644
index 00000000..e6e40e60
Binary files /dev/null and b/posterior_database/data/data/science_irt.json.zip differ
diff --git a/posterior_database/data/data/state_wide_presidential_votes.json.zip b/posterior_database/data/data/state_wide_presidential_votes.json.zip
new file mode 100644
index 00000000..17212f12
Binary files /dev/null and b/posterior_database/data/data/state_wide_presidential_votes.json.zip differ
diff --git a/posterior_database/data/data/synthetic_grid_RBF_kernels.json.zip b/posterior_database/data/data/synthetic_grid_RBF_kernels.json.zip
new file mode 100644
index 00000000..7c754ce8
Binary files /dev/null and b/posterior_database/data/data/synthetic_grid_RBF_kernels.json.zip differ
diff --git a/posterior_database/data/data/timssAusTwn_irt.json.zip b/posterior_database/data/data/timssAusTwn_irt.json.zip
new file mode 100644
index 00000000..0e69bf97
Binary files /dev/null and b/posterior_database/data/data/timssAusTwn_irt.json.zip differ
diff --git a/posterior_database/data/data/traffic_accident_nyc.json.zip b/posterior_database/data/data/traffic_accident_nyc.json.zip
new file mode 100644
index 00000000..ecae27b5
Binary files /dev/null and b/posterior_database/data/data/traffic_accident_nyc.json.zip differ
diff --git a/posterior_database/data/data/uk_drivers.json.zip b/posterior_database/data/data/uk_drivers.json.zip
new file mode 100644
index 00000000..9a00b991
Binary files /dev/null and b/posterior_database/data/data/uk_drivers.json.zip differ
diff --git a/posterior_database/data/info/GLMM_Poisson_data.info.json b/posterior_database/data/info/GLMM_Poisson_data.info.json
new file mode 100644
index 00000000..a4fd6c6f
--- /dev/null
+++ b/posterior_database/data/info/GLMM_Poisson_data.info.json
@@ -0,0 +1,10 @@
+{
+  "name": "GLMM_Poisson_data",
+  "keywords": ["GLMM_Poisson_data", "population"],
+  "title": "Simulated Peregrine Population Observations with Random Year Effect",
+  "description": "Simulated population counts of peregrines in various sites and years in the French Jura over 9 years",
+  "references": "kery2011population",
+  "added_date": "2021-06-29",
+  "added_by": "Kane Lindsay",
+  "data_file": "data/data/GLMM_Poisson_data.json"
+}
diff --git a/posterior_database/data/info/GLMM_data.info.json b/posterior_database/data/info/GLMM_data.info.json
new file mode 100644
index 00000000..3158e9a3
--- /dev/null
+++ b/posterior_database/data/info/GLMM_data.info.json
@@ -0,0 +1,10 @@
+{
+  "name": "GLMM_data",
+  "keywords": ["GLMM_data", "population"],
+  "title": "Simulated Peregrine Population Observations",
+  "description": "Simulated population counts of peregrines in the French Jura over 9 years",
+  "references": "kery2011population",
+  "added_date": "2021-06-25",
+  "added_by": "Kane Lindsay",
+  "data_file": "data/data/GLMM_data.json"
+}
diff --git a/posterior_database/data/info/GLM_Binomial_data.info.json b/posterior_database/data/info/GLM_Binomial_data.info.json
new file mode 100644
index 00000000..deb058d4
--- /dev/null
+++ b/posterior_database/data/info/GLM_Binomial_data.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "GLM_Binomial_data",
+  "keywords": ["Success", "Peregrine"],
+  "title": "Counts of successful Peregrine Broods in the French Jura",
+  "description": "The counts of broods and successful broods of Peregrines the French Jura from 1964 to 2003",
+  "urls": "https://github.com/stan-dev/example-models/tree/master/BPA/Ch.03",
+  "references": "kery2011population",
+  "added_date": "2021-07-01",
+  "added_by": "Kane Lindsay",
+  "data_file": "data/data/GLM_Binomial_data.json"
+}
diff --git a/posterior_database/data/info/GLM_Poisson_Data.info.json b/posterior_database/data/info/GLM_Poisson_Data.info.json
new file mode 100644
index 00000000..abcb8976
--- /dev/null
+++ b/posterior_database/data/info/GLM_Poisson_Data.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "GLM_Poisson_Data",
+  "keywords": ["Population", "Peregrine"],
+  "title": "Counts of a Population of Peregrines 1964-2003",
+  "description": "The trajectory of the peregrine population breeding in the French Jura from 1964 to 2003",
+  "urls": "https://github.com/stan-dev/example-models/tree/master/BPA/Ch.03",
+  "references": "kery2011population",
+  "added_date": "2021-07-01",
+  "added_by": "Kane Lindsay",
+  "data_file": "data/data/GLM_Poisson_Data.json"
+}
diff --git a/posterior_database/data/info/M0_data.info.json b/posterior_database/data/info/M0_data.info.json
new file mode 100644
index 00000000..a16b3f64
--- /dev/null
+++ b/posterior_database/data/info/M0_data.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "M0_data",
+  "keywords": ["Capture", "Recapture", "Population", "Frequency", "Modelling", "Modeling", "M0_data", "Constant"],
+  "title": "Simulated capture-recapture data",
+  "description": "The number of times each individual was encountered\n          under a constant probability of detection.",
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.06",
+  "references": "kery2011population",
+  "added_date": "2021-06-24",
+  "added_by": "Kane Lindsay",
+  "data_file": "data/data/M0_data.json"
+}
diff --git a/posterior_database/data/info/Mb_data.info.json b/posterior_database/data/info/Mb_data.info.json
new file mode 100644
index 00000000..296930a7
--- /dev/null
+++ b/posterior_database/data/info/Mb_data.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "Mb_data",
+  "keywords": ["Capture", "Recapture", "Population", "Frequency", "Modelling", "Modeling", "Mb_data"],
+  "title": "Individuals detected in capture-recapture sampling",
+  "description": "Simulated data of the number of times each individual\n          was encountered in capture-recapture sampling.",
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.06",
+  "references": "kery2011population",
+  "added_date": "2021-06-25",
+  "added_by": "Kane Lindsay",
+  "data_file": "data/data/Mb_data.json"
+}
diff --git a/posterior_database/data/info/Mh_data.info.json b/posterior_database/data/info/Mh_data.info.json
new file mode 100644
index 00000000..10d415a2
--- /dev/null
+++ b/posterior_database/data/info/Mh_data.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "Mh_data",
+  "keywords": ["Capture", "Recapture", "Population", "Frequency", "Modelling", "Modeling", "Mh_data"],
+  "title": "Individuals detected in capture-recapture sampling",
+  "description": "Aggregated simulated capture frequencies: the counts of the number of times each individual was encountered.",
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.06",
+  "references": "kery2011population",
+  "added_date": "2021-06-25",
+  "added_by": "Kane Lindsay",
+  "data_file": "data/data/Mh_data.json"
+}
diff --git a/posterior_database/data/info/Mt_data.info.json b/posterior_database/data/info/Mt_data.info.json
new file mode 100644
index 00000000..b34e810f
--- /dev/null
+++ b/posterior_database/data/info/Mt_data.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "Mt_data",
+  "keywords": ["Capture", "Recapture", "Population", "Frequency", "Modelling", "Modeling", "Mt_data"],
+  "title": "Individuals detected or undetected in capture-recapture sampling",
+  "description": "Simulated capture-recapture data, binary of 'not observed' or 'observed' over 3 occasions",
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.06",
+  "references": "kery2011population",
+  "added_date": "2021-06-25",
+  "added_by": "Kane Lindsay",
+  "data_file": "data/data/Mt_data.json"
+}
diff --git a/posterior_database/data/info/Mtbh_data.info.json b/posterior_database/data/info/Mtbh_data.info.json
new file mode 100644
index 00000000..3c9192ec
--- /dev/null
+++ b/posterior_database/data/info/Mtbh_data.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "Mtbh_data",
+  "keywords": ["wryneck", "bird", "population", "Czechia", "Czech Republic"],
+  "title": "Bird Count Data in the Czech Republic",
+  "description": "Counts of the wryneck bird from cycling an East–West\n          transect spanning almost the whole of Czechia and conducting a 5 min\n          point count after every 500 m in 2004–2005. Repeated five times\n          within the same breeding season.",
+  "urls": "https://link.springer.com/article/10.1007/s10531-008-9430-4",
+  "references": "reif2008bird",
+  "added_date": "2021-06-25",
+  "added_by": "Kane Lindsay",
+  "data_file": "data/data/Mtbh_data.json"
+}
diff --git a/posterior_database/data/info/Mth_data.info.json b/posterior_database/data/info/Mth_data.info.json
new file mode 100644
index 00000000..a29a7ac3
--- /dev/null
+++ b/posterior_database/data/info/Mth_data.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "Mth_data",
+  "keywords": ["Capture", "Recapture", "Capture-Recapture", "Population", "Modelling", "Modeling", "Mth_data"],
+  "title": "Individuals detected or undetected in capture-recapture sampling",
+  "description": "Simulated unaggregated capture-recapture data, binary of 'not observed' or 'observed' over 5 occasions",
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.06",
+  "references": "kery2011population",
+  "added_date": "2021-06-25",
+  "added_by": "Kane Lindsay",
+  "data_file": "data/data/Mth_data.json"
+}
diff --git a/posterior_database/data/info/Rate_1_data.info.json b/posterior_database/data/info/Rate_1_data.info.json
new file mode 100644
index 00000000..f39faac1
--- /dev/null
+++ b/posterior_database/data/info/Rate_1_data.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "Rate_1_data",
+  "keywords": "Test Score",
+  "title": "A Single Test Score",
+  "description": "Test score of 5 correct answers (k) out of 10 questions (n)",
+  "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/GettingStarted",
+  "references": "lee2013cognitive",
+  "added_date": "2021-06-30",
+  "added_by": "Kane Lindsay",
+  "data_file": "data/data/Rate_1_data.json"
+}
diff --git a/posterior_database/data/info/Rate_2_data.info.json b/posterior_database/data/info/Rate_2_data.info.json
new file mode 100644
index 00000000..63a6ba71
--- /dev/null
+++ b/posterior_database/data/info/Rate_2_data.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "Rate_2_data",
+  "keywords": ["Success", "Trial"],
+  "title": "Success counts from two trials",
+  "description": "The number of successes (k1, k2) from two trials of sizes n1 and n2",
+  "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/ParameterEstimation/Binomial",
+  "references": "lee2013cognitive",
+  "added_date": "2021-06-30",
+  "added_by": "Kane Lindsay",
+  "data_file": "data/data/Rate_2_data.json"
+}
diff --git a/posterior_database/data/info/Rate_3_data.info.json b/posterior_database/data/info/Rate_3_data.info.json
new file mode 100644
index 00000000..092c590b
--- /dev/null
+++ b/posterior_database/data/info/Rate_3_data.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "Rate_3_data",
+  "keywords": "Test Score",
+  "title": "Success counts from two trials",
+  "description": "The number of successes (k1, k2) from two trials of sizes n1 and n2",
+  "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/ParameterEstimation/Binomial",
+  "references": "lee2013cognitive",
+  "added_date": "2021-06-30",
+  "added_by": "Kane Lindsay",
+  "data_file": "data/data/Rate_3_data.json"
+}
diff --git a/posterior_database/data/info/Rate_4_data.info.json b/posterior_database/data/info/Rate_4_data.info.json
new file mode 100644
index 00000000..2d2bf7fe
--- /dev/null
+++ b/posterior_database/data/info/Rate_4_data.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "Rate_4_data",
+  "keywords": "Test Score",
+  "title": "Success count from one trial",
+  "description": "Success count (k) from a trial of 15 iterations",
+  "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/ParameterEstimation/Binomial",
+  "references": "lee2013cognitive",
+  "added_date": "2021-06-30",
+  "added_by": "Kane Lindsay",
+  "data_file": "data/data/Rate_4_data.json"
+}
diff --git a/posterior_database/data/info/Rate_5_data.info.json b/posterior_database/data/info/Rate_5_data.info.json
new file mode 100644
index 00000000..5a5e5f58
--- /dev/null
+++ b/posterior_database/data/info/Rate_5_data.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "Rate_5_data",
+  "keywords": ["Success Count", "Trial"],
+  "title": "Success counts from two trials",
+  "description": "The number of successes (k1, k2) from two trials of sizes n1 and n2. There are no successes in k1 and all successes in k2.",
+  "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/ParameterEstimation/Binomial",
+  "references": "lee2013cognitive",
+  "added_date": "2021-06-30",
+  "added_by": "Kane Lindsay",
+  "data_file": "data/data/Rate_5_data.json"
+}
diff --git a/posterior_database/data/info/Survey_data.info.json b/posterior_database/data/info/Survey_data.info.json
new file mode 100644
index 00000000..b52bb1d6
--- /dev/null
+++ b/posterior_database/data/info/Survey_data.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "Survey_data",
+  "keywords": ["Survey", "Return Rate"],
+  "title": "Number of Returned Surveys",
+  "description": "The number of returned surveys (k) from 'm' number of 'helpers'.",
+  "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/ParameterEstimation/Binomial",
+  "references": "lee2013cognitive",
+  "added_date": "2021-06-30",
+  "added_by": "Kane Lindsay",
+  "data_file": "data/data/Survey_data.json"
+}
diff --git a/posterior_database/data/info/bball_drive_event_0.info.json b/posterior_database/data/info/bball_drive_event_0.info.json
index 3d73529b..0d23b8cd 100644
--- a/posterior_database/data/info/bball_drive_event_0.info.json
+++ b/posterior_database/data/info/bball_drive_event_0.info.json
@@ -5,7 +5,6 @@
   "description": "Data Dimensions:\n- N: length of the process\n- K: number of latent states (1: None, 2: drive)\n- u: 1 / speed\n- v: distance to hoop\n- alpha: transit prior matrix\n",
   "urls": "https://github.com/imadmali/bball-hmm/tree/master/data",
   "data_file": "data/data/bball_drive_event_0.json",
-  "references": "",
   "added_date": "2020-05-10",
   "added_by": "Oliver Järnefelt"
 }
diff --git a/posterior_database/data/info/bball_drive_event_1.info.json b/posterior_database/data/info/bball_drive_event_1.info.json
index 30239bce..ec1f6ca9 100644
--- a/posterior_database/data/info/bball_drive_event_1.info.json
+++ b/posterior_database/data/info/bball_drive_event_1.info.json
@@ -5,7 +5,7 @@
   "description": "Data Dimensions:\n- N: length of the process\n- K: number of latent states (1: None, 2: drive)\n- u: 1 / speed\n- v: distance to hoop\n- alpha: transit prior matrix\n- tau: sd of u\n- rho: sd of v\n",
   "urls": "https://github.com/imadmali/bball-hmm/tree/master/data",
   "data_file": "data/data/bball_drive_event_1.json",
-  "references": "",
+  "references": null,
   "added_date": "2020-05-10",
   "added_by": "Oliver Järnefelt"
 }
diff --git a/posterior_database/data/info/fims_Aus_Jpn_irt.info.json b/posterior_database/data/info/fims_Aus_Jpn_irt.info.json
new file mode 100644
index 00000000..f3e22f69
--- /dev/null
+++ b/posterior_database/data/info/fims_Aus_Jpn_irt.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "fims_Aus_Jpn_irt",
+  "keywords": "benchmarking_1.0",
+  "title": "The example data are from the The First International Mathematics Study (Husen and others 1967; Postlethwaite 1967). The data include information about student gender and country (Australia or Japan). For convenience, only a subset of the full data are used.",
+  "description": "Please look at the TAM package for more details",
+  "urls": "https://www.rdocumentation.org/packages/TAM/versions/3.6-45/topics/data.fims.Aus.Jpn.scored",
+  "references": null,
+  "added_date": "2021-08-03",
+  "added_by": "Keane Nguyen",
+  "data_file": "data/data/fims_Aus_Jpn_irt.json"
+}
diff --git a/posterior_database/data/info/hmm_example.info.json b/posterior_database/data/info/hmm_example.info.json
index 1e997766..55e12845 100644
--- a/posterior_database/data/info/hmm_example.info.json
+++ b/posterior_database/data/info/hmm_example.info.json
@@ -5,7 +5,7 @@
   "description": "Example data for a Hidden Markov Model\nData Dimensions:\n- N: number of data points\n- K: number of latent states\n- y: observed values\n",
   "urls": "https://github.com/imadmali/bball-hmm/tree/master/data",
   "data_file": "data/data/hmm_example.json",
-  "references": "",
+  "references": null,
   "added_date": "2020-05-10",
   "added_by": "Oliver Järnefelt"
 }
diff --git a/posterior_database/data/info/hmm_gaussian_simulated.info.json b/posterior_database/data/info/hmm_gaussian_simulated.info.json
new file mode 100644
index 00000000..02a38573
--- /dev/null
+++ b/posterior_database/data/info/hmm_gaussian_simulated.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "hmm_gaussian_simulated",
+  "keywords": "benchmarking_1.0",
+  "title": "Simulated data for hmm_gaussian model",
+  "description": "Simulated data for hmm_gaussian model",
+  "urls": "https://github.com/luisdamiano/stancon18",
+  "references": null,
+  "added_date": "2021-08-19",
+  "added_by": "Keane Nguyen",
+  "data_file": "data/data/hmm_gaussian_simulated.json"
+}
diff --git a/posterior_database/data/info/iohmm_reg_simulated.info.json b/posterior_database/data/info/iohmm_reg_simulated.info.json
new file mode 100644
index 00000000..8a23d962
--- /dev/null
+++ b/posterior_database/data/info/iohmm_reg_simulated.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "iohmm_reg_simulated",
+  "keywords": "benchmarking_1.0",
+  "title": "Simulated data for iohmm_reg model",
+  "description": "Simulated data for iohmm_reg model",
+  "urls": "https://github.com/luisdamiano/stancon18",
+  "references": null,
+  "added_date": "2021-08-19",
+  "added_by": "Keane Nguyen",
+  "data_file": "data/data/iohmm_reg_simulated.json"
+}
diff --git a/posterior_database/data/info/loss_curves.info.json b/posterior_database/data/info/loss_curves.info.json
new file mode 100644
index 00000000..e1088e80
--- /dev/null
+++ b/posterior_database/data/info/loss_curves.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "loss_curves",
+  "keywords": "benchmarking_1.0",
+  "title": "loss_curves",
+  "description": "loss_curves",
+  "urls": "https://mc-stan.org/users/documentation/case-studies/losscurves_casestudy.html",
+  "references": null,
+  "added_date": "2021-08-03",
+  "added_by": "Keane Nguyen",
+  "data_file": "data/data/loss_curves.json"
+}
diff --git a/posterior_database/data/info/normal_2.info.json b/posterior_database/data/info/normal_2.info.json
index 60f5b05f..45f9a9b9 100644
--- a/posterior_database/data/info/normal_2.info.json
+++ b/posterior_database/data/info/normal_2.info.json
@@ -5,7 +5,7 @@
   "description": "-N: number of observations\n- theta: mixture weight\n- mu1: mean of 1st component\n- mu2: mean of 2nd component",
   "urls": "https://github.com/stan-dev/example-models/tree/master/basic_estimators",
   "data_file": "data/data/normal_2.json",
-  "references": "",
+  "references": null,
   "added_date": "2020-04-20",
   "added_by": "Oliver Järnefelt"
 }
diff --git a/posterior_database/data/info/normal_5.info.json b/posterior_database/data/info/normal_5.info.json
index 25e1861d..0e8bee21 100644
--- a/posterior_database/data/info/normal_5.info.json
+++ b/posterior_database/data/info/normal_5.info.json
@@ -5,7 +5,7 @@
   "description": "- K: number of Gaussians\n- N: total number of observations\n- y: draws from the Gaussians\n- z: cluster labels\n- Ns: number of draws from each Gaussian\n- mus: means of the Gaussians\n- sigmas: sds of the Gaussians\n",
   "urls": "",
   "data_file": "data/data/normal_5.json",
-  "references": "",
+  "references": null,
   "added_date": "2020-03-11",
   "added_by": "Oliver Järnefelt"
 }
diff --git a/posterior_database/data/info/ovarian.info.json b/posterior_database/data/info/ovarian.info.json
index a945f3b8..e5cd98ef 100644
--- a/posterior_database/data/info/ovarian.info.json
+++ b/posterior_database/data/info/ovarian.info.json
@@ -5,7 +5,7 @@
   "description": "Ovarian cancer dataset with 1536 predictors and 54 instances",
   "urls": "",
   "data_file": "data/data/ovarian.json",
-  "references": "",
+  "references": null,
   "added_date": "2020-02-29",
   "added_by": "Oliver Järnefelt"
 }
diff --git a/posterior_database/data/info/prideprejustice_chapter.info.json b/posterior_database/data/info/prideprejudice_chapter.info.json
similarity index 69%
rename from posterior_database/data/info/prideprejustice_chapter.info.json
rename to posterior_database/data/info/prideprejudice_chapter.info.json
index 1b74c531..1cfe2c60 100644
--- a/posterior_database/data/info/prideprejustice_chapter.info.json
+++ b/posterior_database/data/info/prideprejudice_chapter.info.json
@@ -1,13 +1,11 @@
 {
-  "name": "prideprejustice_chapter",
-  "keywords": [
-    "text"
-  ],
+  "name": "prideprejudice_chapter",
+  "keywords": "text",
   "description": "The book has been tokenized, stop words and rare words (<=5) has been removed. Variable 'doc' is chapter id.",
   "urls": [],
   "title": "The book 'Pride and Prejustice' by Jane Austen.",
   "references": [],
-  "data_file": "data/data/prideprejustice_chapter.json",
+  "data_file": "data/data/prideprejudice_chapter.json",
   "added_by": "Mans Magnusson",
   "added_date": "2019-08-12"
 }
diff --git a/posterior_database/data/info/prideprejustice_paragraph.info.json b/posterior_database/data/info/prideprejudice_paragraph.info.json
similarity index 69%
rename from posterior_database/data/info/prideprejustice_paragraph.info.json
rename to posterior_database/data/info/prideprejudice_paragraph.info.json
index f756a5e7..0c48b6dd 100644
--- a/posterior_database/data/info/prideprejustice_paragraph.info.json
+++ b/posterior_database/data/info/prideprejudice_paragraph.info.json
@@ -1,13 +1,11 @@
 {
-  "name": "prideprejustice_paragraph",
-  "keywords": [
-    "text"
-  ],
+  "name": "prideprejudice_paragraph",
+  "keywords": "text",
   "description": "The book has been tokenized, stop words and rare words (<=5) has been removed. Variable 'doc' is paragraph id.",
   "urls": [],
   "title": "The book 'Pride and Prejustice' by Jane Austen.",
   "references": [],
-  "data_file": "data/data/prideprejustice_paragraph.json",
+  "data_file": "data/data/prideprejudice_paragraph.json",
   "added_by": "Mans Magnusson",
   "added_date": "2019-08-12"
 }
diff --git a/posterior_database/data/info/science_irt.info.json b/posterior_database/data/info/science_irt.info.json
new file mode 100644
index 00000000..8622209e
--- /dev/null
+++ b/posterior_database/data/info/science_irt.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "science_irt",
+  "keywords": "benchmarking_1.0",
+  "title": "This data set comes from the Consumer Protection and Perceptions of Science and Technology section of the 1992 Euro-Barometer Survey (Karlheinz and Melich, 1992) based on a sample from Great Britain. T",
+  "description": "Please look at Science data set from ltm package for more details",
+  "urls": "https://www.rdocumentation.org/packages/ltm/versions/1.1-1/topics/Science",
+  "references": "reif1995euro",
+  "added_date": "2021-08-03",
+  "added_by": "Keane Nguyen",
+  "data_file": "data/data/science_irt.json"
+}
diff --git a/posterior_database/data/info/state_wide_presidential_votes.info.json b/posterior_database/data/info/state_wide_presidential_votes.info.json
new file mode 100644
index 00000000..43794284
--- /dev/null
+++ b/posterior_database/data/info/state_wide_presidential_votes.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "state_wide_presidential_votes",
+  "keywords": "benchmarking_1.0",
+  "title": "State-wide presidential votes",
+  "description": "Historical presidential votes by state",
+  "urls": "https://mc-stan.org/events/stancon2017-notebooks/stancon2017-trangucci-hierarchical-gps.pdf",
+  "references": null,
+  "added_date": "2021-08-03",
+  "added_by": "Keane Nguyen",
+  "data_file": "data/data/state_wide_presidential_votes.json"
+}
diff --git a/posterior_database/data/info/synthetic_grid_RBF_kernels.info.json b/posterior_database/data/info/synthetic_grid_RBF_kernels.info.json
new file mode 100644
index 00000000..f4fa59e7
--- /dev/null
+++ b/posterior_database/data/info/synthetic_grid_RBF_kernels.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "synthetic_grid_RBF_kernels",
+  "keywords": "benchmarking_1.0",
+  "title": "Synthetic 2D grid data",
+  "description": "Simulated from a Gaussian process on an n × n regular grid using a product of RBF kernels",
+  "urls": "https://sethrf.com/files/fast-hierarchical-GPs.pdf",
+  "references": "flaxman2015fast",
+  "added_date": "2021-08-03",
+  "added_by": "Keane Nguyen",
+  "data_file": "data/data/synthetic_grid_RBF_kernels.json"
+}
diff --git a/posterior_database/data/info/timssAusTwn_irt.info.json b/posterior_database/data/info/timssAusTwn_irt.info.json
new file mode 100644
index 00000000..fb0528d6
--- /dev/null
+++ b/posterior_database/data/info/timssAusTwn_irt.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "timssAusTwn_irt",
+  "keywords": "benchmarking_1.0",
+  "title": "The example data are from the TIMSS 2011 mathematics assessment (Mullis et al. 2012) of Australian and Taiwanese students. For convenience, a subset of 500 students is used. The subsetted data is then divided into a person covariate matrix and an item response matrix.",
+  "description": "Please look at the TAM package for more details",
+  "urls": "https://www.rdocumentation.org/packages/TAM/versions/3.7-16/topics/data.timssAusTwn",
+  "references": null,
+  "added_date": "2021-08-03",
+  "added_by": "Keane Nguyen",
+  "data_file": "data/data/timssAusTwn_irt.json"
+}
diff --git a/posterior_database/data/info/traffic_accident_nyc.info.json b/posterior_database/data/info/traffic_accident_nyc.info.json
new file mode 100644
index 00000000..3e9caa51
--- /dev/null
+++ b/posterior_database/data/info/traffic_accident_nyc.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "traffic_accident_nyc",
+  "keywords": "benchmarking_1.0",
+  "title": "Traffic Accidents in NYC",
+  "description": "This dataset was compiled from all reported traffic accidents involving a car and either a pedestrian or bicyclist in New York City between 2001 and 2009, localized to the census tract level. We are using just the 2001 data for total population per census tract and total number of accidents. Although there are 2168 total census tracts in New York City, we only have data for 1929 regions, 8 of which aren’t properly connected to other regions and are therefore omitted for the sake of simplicity.",
+  "urls": "https://pubmed.ncbi.nlm.nih.gov/25643104/",
+  "references": "dimaggio2015small",
+  "added_date": "2021-08-03",
+  "added_by": "Keane Nguyen",
+  "data_file": "data/data/traffic_accident_nyc.json"
+}
diff --git a/posterior_database/data/info/uk_drivers.info.json b/posterior_database/data/info/uk_drivers.info.json
new file mode 100644
index 00000000..df3eba0b
--- /dev/null
+++ b/posterior_database/data/info/uk_drivers.info.json
@@ -0,0 +1,11 @@
+{
+  "name": "uk_drivers",
+  "keywords": "benchmarking_1.0",
+  "title": "UK Drivers dataset from An Introduction to State Space Time Series Analysis text",
+  "description": "UK Drivers dataset from An Introduction to State Space Time Series Analysis text",
+  "urls": "https://github.com/sinhrks/stan-statespace/tree/master/data",
+  "references": null,
+  "added_date": "2021-08-19",
+  "added_by": "Keane Nguyen",
+  "data_file": "data/data/uk_drivers.json"
+}
diff --git a/posterior_database/models/info/2pl_latent_reg_irt.info.json b/posterior_database/models/info/2pl_latent_reg_irt.info.json
new file mode 100644
index 00000000..4291b8b5
--- /dev/null
+++ b/posterior_database/models/info/2pl_latent_reg_irt.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "2pl_latent_reg_irt",
+  "keywords": "item response model",
+  "title": "Two-parameter logistic item theory model with latent regression",
+  "description": "The Rasch model (Rasch 1960) is an item response theory model for dichotomous items. The two-parameter logistic model (2PL) (Swaminathan and Gifford 1985) is an item response theory model that includes parameters for both the difficulty and discrimination of dichotomous items. The version presented includes a latent regression. However, the latent regression part of the model may be restricted to an intercept only, resulting in a regular 2PL.",
+  "urls": "https://github.com/danielcfurr/edstan",
+  "references": null,
+  "added_by": "Keane Nguyen",
+  "added_date": "2021-08-03",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/2pl_latent_reg_irt.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/GLMM1_model.info.json b/posterior_database/models/info/GLMM1_model.info.json
new file mode 100644
index 00000000..7cb46a8e
--- /dev/null
+++ b/posterior_database/models/info/GLMM1_model.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "GLMM1_model",
+  "keywords": ["BPA", "Ch.4", "GLMM1_model"],
+  "title": "Generalized Linear Mixed Model for Peregrine Population Size",
+  "description": "A GLMM for modeling peregrine population size with a random effect being the site of observation.",
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.04",
+  "references": "kery2011population",
+  "added_by": "Kane Lindsay",
+  "added_date": "2021-06-25",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/GLMM1_model.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/GLMM_Poisson_model.info.json b/posterior_database/models/info/GLMM_Poisson_model.info.json
new file mode 100644
index 00000000..0c8d6b43
--- /dev/null
+++ b/posterior_database/models/info/GLMM_Poisson_model.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "GLMM_Poisson_model",
+  "keywords": ["BPA", "Ch.4", "GLMM_Poisson_model"],
+  "title": "Mixed Model to Predict Population Size with Random Site and Year Effects",
+  "description": "A GLMM for modeling peregrine population size with a random effect being the site and year of observation using the Poisson distribution to model counts.",
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.04",
+  "references": "kery2011population",
+  "added_by": "Kane Lindsay",
+  "added_date": "2021-06-29",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/GLMM_Poisson_model.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/GLM_Binomial_model.info.json b/posterior_database/models/info/GLM_Binomial_model.info.json
new file mode 100644
index 00000000..04a621db
--- /dev/null
+++ b/posterior_database/models/info/GLM_Binomial_model.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "GLM_Binomial_model",
+  "keywords": ["Success", "Peregrine", "Generalized", "Generalised", "Linear Model", "Binomial"],
+  "title": "Success Rate of Peregrine broods",
+  "description": "Binomial GLM for modeling the success rate of Peregrine broods in the French Jura.",
+  "urls": "https://github.com/stan-dev/example-models/tree/master/BPA/Ch.03",
+  "references": "kery2011population",
+  "added_by": "Kane Lindsay",
+  "added_date": "2021-07-01",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/GLM_Binomial_model.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/GLM_Poisson_model.info.json b/posterior_database/models/info/GLM_Poisson_model.info.json
new file mode 100644
index 00000000..67523aaf
--- /dev/null
+++ b/posterior_database/models/info/GLM_Poisson_model.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "GLM_Poisson_model",
+  "keywords": ["Population", "Peregrine", "Generalized", "Generalised", "Linear Model"],
+  "title": "Poisson GLM for modeling a population of Peregrines",
+  "description": "Poisson Generalised Linear Model where the linear predictor is a cubic polynomial function of time.",
+  "urls": "https://github.com/stan-dev/example-models/tree/master/BPA/Ch.03",
+  "references": "kery2011population",
+  "added_by": "Kane Lindsay",
+  "added_date": "2021-07-01",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/GLM_Poisson_model.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/M0_model.info.json b/posterior_database/models/info/M0_model.info.json
new file mode 100644
index 00000000..74b529a8
--- /dev/null
+++ b/posterior_database/models/info/M0_model.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "M0_model",
+  "keywords": ["BPA", "Ch.6", "Population", "Capture", "Recapture", "Individual", "Constant"],
+  "title": "Inferring population size with constant detection probability",
+  "description": "Detection probability of an individual is assumed constant over individuals and over time periods",
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.06",
+  "references": "kery2011population",
+  "added_by": "Kane Lindsay",
+  "added_date": "2021-06-24",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/M0_model.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/Mb_model.info.json b/posterior_database/models/info/Mb_model.info.json
new file mode 100644
index 00000000..61a60567
--- /dev/null
+++ b/posterior_database/models/info/Mb_model.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "Mb_model",
+  "keywords": ["BPA", "Ch.6", "Population", "Capture", "Recapture", "Trap", "Response", "Immediate"],
+  "title": "Inferring population size considering immediate trap-response",
+  "description": "Capture-recapture population model where capture\n          probability is modeled by a different parameter for p depending on\n          whether an animal was caught immediately before or not.",
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.06",
+  "references": "kery2011population",
+  "added_by": "Kane Lindsay",
+  "added_date": "2021-06-25",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/Mb_model.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/Mh_model.info.json b/posterior_database/models/info/Mh_model.info.json
new file mode 100644
index 00000000..a8cbd9a2
--- /dev/null
+++ b/posterior_database/models/info/Mh_model.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "Mh_model",
+  "keywords": ["Heterogeneity", "BPA", "Ch.6", "Population", "Capture", "Recapture", "Individual", "Logistic-Normal", "Logistic", "Normal"],
+  "title": "Logistic-Normal Heterogeneity Model",
+  "description": "Heterogeneity is inherent difference\n          in the behaviour of individuals. Individual heterogeneity is\n          modeled as random noise around some mean on a logit-transformed scale,\n          and the model for the noise is the normal distribution.",
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.06",
+  "references": "kery2011population",
+  "added_by": "Kane Lindsay",
+  "added_date": "2021-06-25",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/Mh_model.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/Mt_model.info.json b/posterior_database/models/info/Mt_model.info.json
new file mode 100644
index 00000000..f54d103b
--- /dev/null
+++ b/posterior_database/models/info/Mt_model.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "Mt_model",
+  "keywords": ["BPA", "Ch.6", "Population", "Capture", "Recapture", "Individual", "Capture-Recapture", "Occasion", "Mt", "Mt_model"],
+  "title": "Capture-recapture model where detection probability varies by occasion",
+  "description": "A capture-recapture sampling model where that assumes \n          detection probability p varies only by occasion, perhaps because of \n          weather conditions or because different traps or detection devices were used",
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.06",
+  "references": "kery2011population",
+  "added_by": "Kane Lindsay",
+  "added_date": "2021-06-25",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/Mt_model.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/Mtbh_model.info.json b/posterior_database/models/info/Mtbh_model.info.json
new file mode 100644
index 00000000..35e77387
--- /dev/null
+++ b/posterior_database/models/info/Mtbh_model.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "Mtbh_model",
+  "keywords": ["BPA", "Ch.6", "Population", "Capture-Recapture", "Mtbh", "Mtbh_model", "Heterogeneity", "Behaviour", "Occasion"],
+  "title": "Capture-recapture model where detection probability varies by occasion",
+  "description": "The model Mtbh estimates the size of a closed population from capture-recapture data \n          which has additive effects of time, behavior, and individual heterogeneity on the detection probability of a species",
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.06",
+  "references": "kery2011population",
+  "added_by": "Kane Lindsay",
+  "added_date": "2021-06-25",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/Mtbh_model.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/Mth_model.info.json b/posterior_database/models/info/Mth_model.info.json
new file mode 100644
index 00000000..0a81b1dc
--- /dev/null
+++ b/posterior_database/models/info/Mth_model.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "Mth_model",
+  "keywords": ["BPA", "Ch.6", "Population", "Capture", "Recapture", "Individual", "Capture-Recapture", "Occasion", "Heterogeneity", "Mth", "Mth_model"],
+  "title": "Capture-recapture model where detection probability varies by occasion and heterogeneity",
+  "description": "A capture-recapture sampling model where that assumes \n          detection probability p varies by an additive effect of the occasion\n          and heterogeneity of individuals in a capture-history matrix with\n          columns representing time, and rows representing individuals.",
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.06",
+  "references": "kery2011population",
+  "added_by": "Kane Lindsay",
+  "added_date": "2021-06-25",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/Mth_model.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/Rate_1_model.info.json b/posterior_database/models/info/Rate_1_model.info.json
new file mode 100644
index 00000000..dc390649
--- /dev/null
+++ b/posterior_database/models/info/Rate_1_model.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "Rate_1_model",
+  "keywords": ["Test Score", "Correct Answer Rate", "Beta Distribution"],
+  "title": "Predicting the rate of correct test question answers",
+  "description": "Predicting the rate of correct answers for one subject over questions with the same difficulty.",
+  "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/GettingStarted",
+  "references": "lee2013cognitive",
+  "added_by": "Kane Lindsay",
+  "added_date": "2021-06-30",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/Rate_1_model.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/Rate_2_model.info.json b/posterior_database/models/info/Rate_2_model.info.json
new file mode 100644
index 00000000..586d0979
--- /dev/null
+++ b/posterior_database/models/info/Rate_2_model.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "Rate_2_model",
+  "keywords": ["Trial", "Success Rate", "Beta Distribution", "Difference"],
+  "title": "Difference in success rates",
+  "description": "Predicting the difference between the success rates of two trials",
+  "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/ParameterEstimation/Binomial",
+  "references": "lee2013cognitive",
+  "added_by": "Kane Lindsay",
+  "added_date": "2021-06-30",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/Rate_2_model.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/Rate_3_model.info.json b/posterior_database/models/info/Rate_3_model.info.json
new file mode 100644
index 00000000..bfecf373
--- /dev/null
+++ b/posterior_database/models/info/Rate_3_model.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "Rate_3_model",
+  "keywords": ["Test Score", "Correct Answer Rate", "Beta Distribution", "Common Rate"],
+  "title": "Common rate of success from two trials",
+  "description": "Inference of a common rate of success from two trials",
+  "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/ParameterEstimation/Binomial",
+  "references": "lee2013cognitive",
+  "added_by": "Kane Lindsay",
+  "added_date": "2021-06-30",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/Rate_3_model.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/Rate_4_model.info.json b/posterior_database/models/info/Rate_4_model.info.json
new file mode 100644
index 00000000..c614530f
--- /dev/null
+++ b/posterior_database/models/info/Rate_4_model.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "Rate_4_model",
+  "keywords": ["Trial", "Success Rate", "Inference", "Prior Inference", "Posterior Inference"],
+  "title": "Success rate of a trial with prior and posterior inference",
+  "description": "Inference of the success rate of a trial with prior and posterior inference",
+  "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/ParameterEstimation/Binomial",
+  "references": "lee2013cognitive",
+  "added_by": "Kane Lindsay",
+  "added_date": "2021-06-30",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/Rate_4_model.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/Rate_5_model.info.json b/posterior_database/models/info/Rate_5_model.info.json
new file mode 100644
index 00000000..19c098fb
--- /dev/null
+++ b/posterior_database/models/info/Rate_5_model.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "Rate_5_model",
+  "keywords": ["Trial", "Correct Answer Rate", "Beta Distribution", "Common Rate"],
+  "title": "Common Rate of Success From Two Trials with Posterior Predictives",
+  "description": "Inference of a common rate of success from two trials with posterior predictive for each trial for checking the adequacy of the model.",
+  "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/ParameterEstimation/Binomial",
+  "references": "lee2013cognitive",
+  "added_by": "Kane Lindsay",
+  "added_date": "2021-06-30",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/Rate_5_model.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/Survey_model.info.json b/posterior_database/models/info/Survey_model.info.json
new file mode 100644
index 00000000..728e87ea
--- /dev/null
+++ b/posterior_database/models/info/Survey_model.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "Survey_model",
+  "keywords": ["Return Rate", "Joint Probability Distribution", "Survey"],
+  "title": "Inferring the Return Rate and Number of Surveys from Observed Returns",
+  "description": "Inference for the joint probability distribution of the\n          rate of return and the number of surveys by observing the number of returned surveys.",
+  "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/ParameterEstimation/Binomial",
+  "references": "lee2013cognitive",
+  "added_by": "Kane Lindsay",
+  "added_date": "2021-06-30",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/Survey_model.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/bym2_offset_only.info.json b/posterior_database/models/info/bym2_offset_only.info.json
new file mode 100644
index 00000000..33a819b9
--- /dev/null
+++ b/posterior_database/models/info/bym2_offset_only.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "bym2_offset_only",
+  "keywords": "spatial model, car",
+  "title": "BYM2 model",
+  "description": "The BYM2 model was proposed by Riebler et al 2016, following Simpson 2014. Like the BYM model, it includes two random effects components, and like the alternative Leroux (1999) model, it places a single precision (scale) parameter on the combined components, and a mixing parameter for the amount of spatial/non-spatial variation.",
+  "urls": ["https://github.com/stan-dev/example-models/tree/master/knitr/car-iar-poisson", "https://mc-stan.org/users/documentation/case-studies/icar_stan.html"],
+  "references": null,
+  "added_by": "Keane Nguyen",
+  "added_date": "2021-08-03",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/bym2_offset_only.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/gpcm_latent_reg_irt.info.json b/posterior_database/models/info/gpcm_latent_reg_irt.info.json
new file mode 100644
index 00000000..f174f5a8
--- /dev/null
+++ b/posterior_database/models/info/gpcm_latent_reg_irt.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "gpcm_latent_reg_irt",
+  "keywords": "item response model",
+  "title": "Partial credit and generalized partial credit models with latent regression",
+  "description": "The PCM (Masters 1982) is used for item response data that features more than two ordered response categories for some or all items. This extends the PCM by including a discrimination term.",
+  "urls": "https://github.com/danielcfurr/edstan",
+  "references": null,
+  "added_by": "Keane Nguyen",
+  "added_date": "2021-08-03",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/gpcm_latent_reg_irt.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/grsm_latent_reg_irt.info.json b/posterior_database/models/info/grsm_latent_reg_irt.info.json
new file mode 100644
index 00000000..18c47c26
--- /dev/null
+++ b/posterior_database/models/info/grsm_latent_reg_irt.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "grsm_latent_reg_irt",
+  "keywords": "item response model",
+  "title": "Rating scale and generalized rating scale models with latent regression",
+  "description": "The rating scale model (Andrich 1978) is used for item response data that involves Likert scale responses. This model extends the RSM by including a discrimination term",
+  "urls": "https://github.com/danielcfurr/edstan",
+  "references": null,
+  "added_by": "Keane Nguyen",
+  "added_date": "2021-08-03",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/grsm_latent_reg_irt.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/hierarchical_gp.info.json b/posterior_database/models/info/hierarchical_gp.info.json
new file mode 100644
index 00000000..7329da18
--- /dev/null
+++ b/posterior_database/models/info/hierarchical_gp.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "hierarchical_gp",
+  "keywords": "gaussian process",
+  "title": "Hierarchical Gaussian Process",
+  "description": "Hierarchical Gaussian Process",
+  "urls": "https://mc-stan.org/events/stancon2017-notebooks/stancon2017-trangucci-hierarchical-gps.pdf",
+  "references": null,
+  "added_by": "Keane Nguyen",
+  "added_date": "2021-08-03",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/hierarchical_gp.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/hmm_drive_0.info.json b/posterior_database/models/info/hmm_drive_0.info.json
index 767bb6ff..34577d56 100644
--- a/posterior_database/models/info/hmm_drive_0.info.json
+++ b/posterior_database/models/info/hmm_drive_0.info.json
@@ -12,7 +12,6 @@
       "model_code": "models/stan/hmm_drive_0.stan"
     }
   },
-  "references": "",
   "added_date": "2020-05-10",
   "added_by": "Oliver Järnefelt"
 }
diff --git a/posterior_database/models/info/hmm_drive_1.info.json b/posterior_database/models/info/hmm_drive_1.info.json
index 407f6a27..bf83a3ac 100644
--- a/posterior_database/models/info/hmm_drive_1.info.json
+++ b/posterior_database/models/info/hmm_drive_1.info.json
@@ -12,7 +12,7 @@
       "model_code": "models/stan/hmm_drive_1.stan"
     }
   },
-  "references": "",
+  "references": null,
   "added_date": "2020-05-10",
   "added_by": "Oliver Järnefelt"
 }
diff --git a/posterior_database/models/info/hmm_example.info.json b/posterior_database/models/info/hmm_example.info.json
index 09b60aaf..6e968d27 100644
--- a/posterior_database/models/info/hmm_example.info.json
+++ b/posterior_database/models/info/hmm_example.info.json
@@ -12,7 +12,7 @@
       "model_code": "models/stan/hmm_example.stan"
     }
   },
-  "references": "",
+  "references": null,
   "added_date": "2020-05-10",
   "added_by": "Oliver Järnefelt"
 }
diff --git a/posterior_database/models/info/hmm_gaussian.info.json b/posterior_database/models/info/hmm_gaussian.info.json
new file mode 100644
index 00000000..d8529b07
--- /dev/null
+++ b/posterior_database/models/info/hmm_gaussian.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "hmm_gaussian",
+  "keywords": "HMM",
+  "title": "HMM with Gaussian emission",
+  "description": "HMM with Gaussian emission",
+  "urls": "https://github.com/luisdamiano/stancon18",
+  "references": null,
+  "added_by": "Keane Nguyen",
+  "added_date": "2021-08-19",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/hmm_gaussian.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/iohmm_reg.info.json b/posterior_database/models/info/iohmm_reg.info.json
new file mode 100644
index 00000000..f9e0c1b7
--- /dev/null
+++ b/posterior_database/models/info/iohmm_reg.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "iohmm_reg",
+  "keywords": "HMM",
+  "title": "Input Output HMM",
+  "description": "Input Output HMM",
+  "urls": "https://github.com/luisdamiano/stancon18",
+  "references": null,
+  "added_by": "Keane Nguyen",
+  "added_date": "2021-08-19",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/iohmm_reg.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/kronecker_gp.info.json b/posterior_database/models/info/kronecker_gp.info.json
new file mode 100644
index 00000000..e85cb267
--- /dev/null
+++ b/posterior_database/models/info/kronecker_gp.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "kronecker_gp",
+  "keywords": "gaussian process, kronecker",
+  "title": "Kronecker Gaussian Process",
+  "description": "Gaussian Process using Kronecker structure",
+  "urls": "https://sethrf.com/files/fast-hierarchical-GPs.pdf",
+  "references": "flaxman2015fast",
+  "added_by": "Keane Nguyen",
+  "added_date": "2021-08-03",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/kronecker_gp.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/losscurve_sislob.info.json b/posterior_database/models/info/losscurve_sislob.info.json
new file mode 100644
index 00000000..06c32eb1
--- /dev/null
+++ b/posterior_database/models/info/losscurve_sislob.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "losscurve_sislob",
+  "keywords": "actuarial",
+  "title": "Hierarchical Loss Curve Model",
+  "description": "Hierarchical Loss Curve Model",
+  "urls": "https://mc-stan.org/users/documentation/case-studies/losscurves_casestudy.html",
+  "references": null,
+  "added_by": "Keane Nguyen",
+  "added_date": "2021-08-03",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/losscurve_sislob.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/info/normal_mixture.info.json b/posterior_database/models/info/normal_mixture.info.json
index e932ce97..abf2d6ce 100644
--- a/posterior_database/models/info/normal_mixture.info.json
+++ b/posterior_database/models/info/normal_mixture.info.json
@@ -12,7 +12,7 @@
       "model_code": "models/stan/normal_mixture.stan"
     }
   },
-  "references": "",
+  "references": null,
   "added_date": "2020-04-20",
   "added_by": "Oliver Järnefelt"
 }
diff --git a/posterior_database/models/info/normal_mixture_k.info.json b/posterior_database/models/info/normal_mixture_k.info.json
index d442e31c..62c8a5bc 100644
--- a/posterior_database/models/info/normal_mixture_k.info.json
+++ b/posterior_database/models/info/normal_mixture_k.info.json
@@ -12,7 +12,7 @@
       "model_code": "models/stan/normal_mixture_k.stan"
     }
   },
-  "references": "",
+  "references": null,
   "added_date": "2020-03-11",
   "added_by": "Oliver Järnefelt"
 }
diff --git a/posterior_database/models/info/state_space_stochastic_level_stochastic_seasonal.info.json b/posterior_database/models/info/state_space_stochastic_level_stochastic_seasonal.info.json
new file mode 100644
index 00000000..930616a8
--- /dev/null
+++ b/posterior_database/models/info/state_space_stochastic_level_stochastic_seasonal.info.json
@@ -0,0 +1,15 @@
+{
+  "name": "state_space_stochastic_level_stochastic_seasonal",
+  "keywords": "Structured Time Series",
+  "title": "Structured Time Series model with stochastic level and stochastic seasonal",
+  "description": "Structured Time Series model with stochastic level and stochastic seasonal",
+  "urls": "https://github.com/sinhrks/stan-statespace/blob/master/models/fig07_02.stan",
+  "references": null,
+  "added_by": "Keane Nguyen",
+  "added_date": "2021-08-19",
+  "model_implementations": {
+    "stan": {
+      "model_code": "models/stan/state_space_stochastic_level_stochastic_seasonal.stan"
+    }
+  }
+}
diff --git a/posterior_database/models/stan/2pl_latent_reg_irt.stan b/posterior_database/models/stan/2pl_latent_reg_irt.stan
new file mode 100644
index 00000000..3135b5a0
--- /dev/null
+++ b/posterior_database/models/stan/2pl_latent_reg_irt.stan
@@ -0,0 +1,67 @@
+functions {
+  matrix obtain_adjustments(matrix W) {
+    real min_w;
+    real max_w;
+    int minmax_count;
+    matrix[2, cols(W)] adj;
+    adj[1, 1] = 0;
+    adj[2, 1] = 1;
+    if(cols(W) > 1) {
+      for(k in 2:cols(W)) {                       // remaining columns
+        min_w = min(W[1:rows(W), k]);
+        max_w = max(W[1:rows(W), k]);
+        minmax_count = 0;
+        for(j in 1:rows(W))
+          minmax_count = minmax_count + W[j,k] == min_w || W[j,k] == max_w;
+        if(minmax_count == rows(W)) {       // if column takes only 2 values
+          adj[1, k] = mean(W[1:rows(W), k]);
+          adj[2, k] = (max_w - min_w);
+        } else {                            // if column takes > 2 values
+          adj[1, k] = mean(W[1:rows(W), k]);
+          adj[2, k] = sd(W[1:rows(W), k]) * 2;
+        }
+      }
+    }
+    return adj;
+  }
+}
+data {
+  int<lower=1> I;               // # questions
+  int<lower=1> J;               // # persons
+  int<lower=1> N;               // # observations
+  int<lower=1, upper=I> ii[N];  // question for n
+  int<lower=1, upper=J> jj[N];  // person for n
+  int<lower=0, upper=1> y[N];   // correctness for n
+  int<lower=1> K;               // # person covariates
+  matrix[J,K] W;                // person covariate matrix
+}
+transformed data {
+  matrix[2,K] adj;               // values for centering and scaling covariates
+  matrix[J,K] W_adj;             // centered and scaled covariates
+  adj = obtain_adjustments(W);
+  for(k in 1:K) for(j in 1:J)
+      W_adj[j,k] = (W[j,k] - adj[1,k]) / adj[2,k];
+}
+parameters {
+  vector<lower=0>[I] alpha;
+  vector[I-1] beta_free;
+  vector[J] theta;
+  vector[K] lambda_adj;
+}
+transformed parameters {
+  vector[I] beta;
+  beta[1:(I-1)] = beta_free;
+  beta[I] = -1*sum(beta_free);
+}
+model {
+  alpha ~ lognormal(1, 1);
+  target += normal_lpdf(beta | 0, 3);
+  lambda_adj ~ student_t(3, 0, 1);
+  theta ~ normal(W_adj*lambda_adj, 1);
+  y ~ bernoulli_logit(alpha[ii].*theta[jj] - beta[ii]);
+}
+generated quantities {
+  vector[K] lambda;
+  lambda[2:K] = lambda_adj[2:K] ./ to_vector(adj[2,2:K]);
+  lambda[1] = W_adj[1, 1:K]*lambda_adj[1:K] - W[1, 2:K]*lambda[2:K];
+}
diff --git a/posterior_database/models/stan/GLMM1_model.stan b/posterior_database/models/stan/GLMM1_model.stan
new file mode 100644
index 00000000..af82e360
--- /dev/null
+++ b/posterior_database/models/stan/GLMM1_model.stan
@@ -0,0 +1,41 @@
+data {
+  int<lower=0> nobs;            // Number of observed data
+  int<lower=0> nmis;            // Number of missing data
+  int<lower=0> nyear;           // Number of years
+  int<lower=0> nsite;           // Number of sites
+  int<lower=0> obs[nobs];       // Observed counts
+  int<lower=0> obsyear[nobs];   // Years in observed data
+  int<lower=0> obssite[nobs];   // Sites in observed data
+  int<lower=0> misyear[nmis];   // Years in missing data
+  int<lower=0> missite[nmis];   // Sites in missing data
+}
+
+parameters {
+  vector[nsite] alpha;          // Random site effects
+  real mu_alpha;
+  real<lower=0,upper=5> sd_alpha;
+}
+
+transformed parameters {
+  matrix[nyear, nsite] log_lambda;
+
+  log_lambda = rep_matrix(alpha', nyear);
+}
+
+model {
+  // Priors
+  alpha ~ normal(mu_alpha, sd_alpha);
+  mu_alpha ~ normal(0, 10);
+  //  sd_alpha ~ uniform(0, 5);  // Implicitly defined
+
+  for (i in 1:nobs)
+    obs[i] ~ poisson_log(log_lambda[obsyear[i], obssite[i]]);
+}
+
+generated quantities {
+  int<lower=0> mis[nmis];
+
+  for (i in 1:nmis)
+    mis[i] = poisson_log_rng(log_lambda[misyear[i], missite[i]]);
+}
+
diff --git a/posterior_database/models/stan/GLMM_Poisson_model.stan b/posterior_database/models/stan/GLMM_Poisson_model.stan
new file mode 100644
index 00000000..7ae494e4
--- /dev/null
+++ b/posterior_database/models/stan/GLMM_Poisson_model.stan
@@ -0,0 +1,53 @@
+data {
+  int<lower=0> n;       // Number of years
+  int<lower=0> C[n];    // Counts
+  vector[n] year;       // Year
+}
+
+transformed data {
+  vector[n] year_squared;
+  vector[n] year_cubed;
+
+  year_squared = year .* year;
+  year_cubed = year .* year .* year;
+}
+
+parameters {
+  real<lower=-20,upper=20> alpha;
+  real<lower=-10,upper=10> beta1;
+  real<lower=-10,upper=20> beta2;
+  real<lower=-10,upper=10> beta3;
+  vector[n] eps;        // Year effects
+  real<lower=0,upper=5> sigma;
+}
+
+transformed parameters {
+  vector[n] log_lambda;
+
+  // Linear predictor incl. random year effect
+ log_lambda = alpha
+            + beta1 * year
+            + beta2 * year_squared
+            + beta3 * year_cubed
+            + eps;
+}
+
+model {
+  // Priors
+  alpha ~ uniform(-20, 20);
+  beta1 ~ uniform(-10, 10);
+  beta2 ~ uniform(-10, 10);
+  beta3 ~ uniform(-10, 10);
+  sigma ~ uniform(0, 5);
+
+  // Likelihood
+  C ~ poisson_log(log_lambda);
+  eps ~ normal(0, sigma);
+}
+
+generated quantities {
+  vector<lower=0>[n] lambda;
+
+  lambda = exp(log_lambda);
+}
+
diff --git a/posterior_database/models/stan/GLM_Binomial_model.stan b/posterior_database/models/stan/GLM_Binomial_model.stan
new file mode 100644
index 00000000..db8b6c14
--- /dev/null
+++ b/posterior_database/models/stan/GLM_Binomial_model.stan
@@ -0,0 +1,46 @@
+data {
+  int<lower=0> nyears;          // Number of Years
+  int<lower=0> C[nyears];       // Counts
+  int<lower=0> N[nyears];       // Binomial Totals
+  vector[nyears] year;          // Year covariates
+}
+
+transformed data {
+  vector[nyears] year_squared;
+
+  year_squared = year .* year;
+}
+
+parameters {
+  real alpha;
+  real beta1;
+  real beta2;
+}
+
+transformed parameters {
+  vector[nyears] logit_p;
+
+  // Linear predictor
+  logit_p = alpha
+          + beta1 * year
+          + beta2 * year_squared;
+}
+
+model {
+  // Priors
+  alpha ~ normal(0, 100);
+  beta1 ~ normal(0, 100);
+  beta2 ~ normal(0, 100);
+
+  // Likelihood
+  // Distribution for random part
+  C ~ binomial_logit(N, logit_p);
+}
+
+generated quantities {
+  real<lower=0,upper=1> p[nyears];
+
+  for (i in 1:nyears)
+    p[i] = inv_logit(logit_p[i]);
+}
+
diff --git a/posterior_database/models/stan/GLM_Poisson_model.stan b/posterior_database/models/stan/GLM_Poisson_model.stan
new file mode 100644
index 00000000..d4f1c370
--- /dev/null
+++ b/posterior_database/models/stan/GLM_Poisson_model.stan
@@ -0,0 +1,43 @@
+data {
+  int<lower=0> n;       // Number of years
+  int<lower=0> C[n];    // Count
+  vector[n] year;       // Year
+}
+
+transformed data {
+  vector[n] year_squared;
+  vector[n] year_cubed;
+
+  year_squared = year .* year;
+  year_cubed = year .* year .* year;
+}
+
+parameters {
+  real<lower=-20,upper=20> alpha;
+  real<lower=-10,upper=10> beta1;
+  real<lower=-10,upper=10> beta2;
+  real<lower=-10,upper=10> beta3;
+}
+
+transformed parameters {
+  vector[n] log_lambda;
+
+  log_lambda = alpha
+             + beta1 * year +
+             + beta2 * year_squared +
+             + beta3 * year_cubed;
+}
+
+model {
+  // Implicit uniform priors are used.
+
+  // Likelihood
+  C ~ poisson_log(log_lambda);
+}
+
+generated quantities {
+  vector[n] lambda;
+
+  lambda = exp(log_lambda);
+}
+
diff --git a/posterior_database/models/stan/M0_model.stan b/posterior_database/models/stan/M0_model.stan
new file mode 100644
index 00000000..a04e71d0
--- /dev/null
+++ b/posterior_database/models/stan/M0_model.stan
@@ -0,0 +1,45 @@
+data {
+  int<lower=0> M;               // Size of augumented data set
+  int<lower=0> T;               // Number of sampling occasions
+  int<lower=0,upper=1> y[M, T]; // Capture-history matrix
+}
+
+transformed data {
+  int<lower=0> s[M];            // Totals in each row
+  int<lower=0> C;               // Size of observed data set
+
+  C = 0;
+  for (i in 1:M) {
+    s[i] = sum(y[i]);
+    if (s[i] > 0)
+      C = C + 1;
+  }
+}
+
+parameters {
+  real<lower=0,upper=1> omega;  // Inclusion probability
+  real<lower=0,upper=1> p;      // Detection probability
+}
+
+model {
+  // Priors are imlicitly defined;
+  //  omega ~ uniform(0, 1);
+  //  p ~ uniform(0, 1);
+
+  // Likelihood
+  for (i in 1:M)
+    if (s[i] > 0)
+      // z[i] == 1
+      target += bernoulli_lpmf(1 | omega)
+              + binomial_lpmf(s[i] | T, p);
+    else // s[i] == 0
+      target += log_sum_exp( bernoulli_lpmf(1 | omega)   // z[i] == 1
+                             + binomial_lpmf(0 | T, p),
+                             bernoulli_lpmf(0 | omega)); // z[i] == 0
+}
+
+generated quantities {
+  // prob present given never detected
+  real omega_nd = (omega * (1 - p)^T) / (omega * (1 - p)^T + (1 - omega));
+  int<lower=C, upper=M> N = C + binomial_rng(M - C, omega_nd);
+}
diff --git a/posterior_database/models/stan/Mb_model.stan b/posterior_database/models/stan/Mb_model.stan
new file mode 100644
index 00000000..b552b1b4
--- /dev/null
+++ b/posterior_database/models/stan/Mb_model.stan
@@ -0,0 +1,64 @@
+data {
+  int<lower=0> M;               // Size of augumented data set
+  int<lower=0> T;               // Number of sampling occasions
+  int<lower=0,upper=1> y[M, T]; // Capture-history matrix
+}
+
+transformed data {
+  int<lower=0> s[M];            // Totals in each row
+  int<lower=0> C;               // Size of observed data set
+
+  C = 0;
+  for (i in 1:M) {
+    s[i] = sum(y[i]);
+    if (s[i] > 0)
+      C = C + 1;
+  }
+}
+
+parameters {
+  real<lower=0,upper=1> omega;  // Inclusion probability
+  real<lower=0,upper=1> p;      // Capture probability
+                                //(not captureed during the preceeding occasion)
+  real<lower=0,upper=1> c;      // Capture probability
+                                //(captureed during the preceeding occasion)
+}
+
+transformed parameters {
+  vector<lower=0,upper=1>[T] p_eff[M];
+
+  for (i in 1:M) {
+    // First occasion
+    p_eff[i, 1] = p;
+
+    // All subsequent occasions
+    for (j in 2:T)
+      p_eff[i, j] = (1 - y[i, j - 1]) * p + y[i, j - 1] * c;
+  }
+}
+
+model {
+  // Priors are implicitly define;
+  //  omega ~ uniform(0, 1);
+  //  p ~ uniform(0, 1);
+
+  // Likelihood
+  for (i in 1:M)
+    if (s[i] > 0)
+      // z[i] == 1
+      target += bernoulli_lpmf(1 |  omega)
+              + bernoulli_lpmf(y[i] |  p_eff[i]);
+    else // s[i] == 0
+      target += log_sum_exp(bernoulli_lpmf(1 |  omega)   // z[i] == 1
+                            + bernoulli_lpmf(y[i] | p_eff[i]),
+                            bernoulli_lpmf(0 | omega));  // z[i] == 0
+}
+
+generated quantities {
+  // prob present given never detected
+  // animals never detected have not been detected before, so p.eff == p
+  real omega_nd = (omega * (1 - p)^T) / (omega * (1 - p)^T + (1 - omega));
+  int<lower=C, upper=M> N = C + binomial_rng(M - C, omega_nd);
+  real trap_response = c - p;
+}
+
diff --git a/posterior_database/models/stan/Mh_model.stan b/posterior_database/models/stan/Mh_model.stan
new file mode 100644
index 00000000..a1552230
--- /dev/null
+++ b/posterior_database/models/stan/Mh_model.stan
@@ -0,0 +1,65 @@
+data {
+  int<lower=0> M;               // Size of augumented data set
+  int<lower=0> T;               // Number of sampling occasions
+  int<lower=0,upper=T> y[M];    // Capture-history matrix
+}
+
+transformed data {
+  int<lower=0> C;               // Size of observed data set
+
+  C = 0;
+  for (i in 1:M) {
+    if (y[i] > 0)
+      C = C + 1;
+  }
+}
+
+parameters {
+  real<lower=0,upper=1> omega;      // Inclusion probability
+  real<lower=0,upper=1> mean_p;     // Mean detection probability
+  real<lower=0,upper=5> sigma;
+  // In case a weakly informative prior is used
+  //  real<lower=0> sigma;
+  vector[M] eps_raw;
+}
+
+transformed parameters {
+  vector[M] eps = logit(mean_p) + sigma * eps_raw;
+}
+
+model {
+  // Priors are implicitly defined.
+  //  omega ~ uniform(0, 1);
+  //  mean_p ~ uniform(0, 1);
+  //  sigma ~ uniform(0, 5);
+  // In case a weakly informative is used
+  //  sigma ~ normal(2.5, 1.25);
+  eps_raw ~ normal(0, 1);
+
+  // Likelihood
+  for (i in 1:M)
+    if (y[i] > 0)
+      // z[i] == 1
+      target += bernoulli_lpmf(1 | omega)
+              + binomial_logit_lpmf(y[i] | T, eps[i]);
+    else // y[i] == 0
+      target += log_sum_exp(bernoulli_lpmf(1 | omega)   // z[i] == 1
+                            + binomial_logit_lpmf(0 | T, eps[i]),
+                            bernoulli_lpmf(0 | omega)); // z[i] == 0
+}
+
+generated quantities {
+  int<lower=0,upper=1> z[M];
+  int<lower=C> N;
+
+  for (i in 1:M) {
+    if(y[i] > 0) {  // animal was detected at least once
+      z[i] = 1;
+    } else {        // animal was never detected
+      real qT;
+      qT = (inv_logit(-eps[i]))^T;  // q^T where q = 1 - p; prob never detected given present
+      z[i] = bernoulli_rng(omega * qT / (omega * qT + (1 - omega)));
+    }
+  }
+  N = sum(z);
+}
diff --git a/posterior_database/models/stan/Mt_model.stan b/posterior_database/models/stan/Mt_model.stan
new file mode 100644
index 00000000..80a0bec6
--- /dev/null
+++ b/posterior_database/models/stan/Mt_model.stan
@@ -0,0 +1,48 @@
+data {
+  int<lower=0> M;               // Size of augumented data set
+  int<lower=0> T;               // Number of sampling occasions
+  int<lower=0,upper=1> y[M, T]; // Capture-history matrix
+}
+
+transformed data {
+  int<lower=0> s[M];            // Totals in each row
+  int<lower=0> C;               // Size of observed data set
+
+  C = 0;
+  for (i in 1:M) {
+    s[i] = sum(y[i]);
+    if (s[i] > 0)
+      C = C + 1;
+  }
+}
+
+parameters {
+  real<lower=0,upper=1> omega;  // Inclusion probability
+  vector<lower=0,upper=1>[T] p; // Detection probability
+}
+
+model {
+  // Priors are implicitly defined.
+  //  omega ~ uniform(0, 1);
+  //  p ~ uniform(0, 1);
+
+  // Likelihood
+  for (i in 1:M)
+    if (s[i] > 0)
+      // z[i] == 1
+      target += bernoulli_lpmf(1 | omega)
+              + bernoulli_lpmf(y[i] | p);
+    else // s[i] == 0
+      target += log_sum_exp(bernoulli_lpmf(1 | omega)   // z[i] == 1
+                            + bernoulli_lpmf(y[i] | p),
+                            bernoulli_lpmf(0 | omega)); // z[i] == 0
+}
+
+generated quantities {
+  // prob never captured given present
+  real pr = prod(1 - p);
+  // prob present given never captured; same for all animals
+  real omega_nd = (omega * pr) / (omega * pr + (1 - omega));
+  int<lower=C> N = C + binomial_rng(M - C, omega_nd);
+}
+
diff --git a/posterior_database/models/stan/Mtbh_model.stan b/posterior_database/models/stan/Mtbh_model.stan
new file mode 100644
index 00000000..91e68af4
--- /dev/null
+++ b/posterior_database/models/stan/Mtbh_model.stan
@@ -0,0 +1,83 @@
+data {
+  int<lower=0> M;               // Number of species
+  int<lower=0> T;               // Number of grab occasions
+  int<lower=0,upper=1> y[M, T]; // Grab counts
+}
+
+transformed data {
+  int<lower=0> s[M];            // Detection times for each species
+  int<lower=0> C;               // Number of observed species
+
+  C = 0;
+  for (i in 1:M) {
+    s[i] = sum(y[i]);
+    if (s[i] > 0)
+      C = C + 1;
+  }
+}
+
+parameters {
+  real<lower=0,upper=1> omega;          // Inclusion probability
+  vector<lower=0,upper=1>[T] mean_p;    // Mean detection probability
+  real gamma;
+  real<lower=0,upper=3> sigma;
+  // In case a weakly informative prior is used
+  //  real<lower=0> sigma;
+  vector[M] eps_raw;
+}
+
+transformed parameters {
+  vector[M] eps = sigma * eps_raw;
+  vector[T] alpha = logit(mean_p);
+  matrix[M, T] logit_p;
+
+  // First occasion: no term for recapture (gamma)
+  logit_p[ , 1] = alpha[1] + eps;
+
+  // All subsequent occasions: includes recapture term (gamma)
+  for (i in 1:M)
+    for (j in 2:T)
+      logit_p[i, j] = alpha[j] + eps[i] + gamma * y[i, j - 1];
+}
+
+model {
+  // Priors
+  gamma ~ normal(0, 10);
+  // Uniform priors are implicitly defined.
+  //  omega ~ uniform(0, 1);
+  //  mean_p ~ uniform(0, 1);
+  //  sigma ~ uniform(0, 3);
+  // In case a weakly informative prior is used
+  //  sigma ~ normal(1.5, 0.75);
+  eps_raw ~ normal(0, 1);
+
+  // Likelihood
+  for (i in 1:M)
+    if (s[i] > 0)
+      // z[i] == 1
+      target += bernoulli_lpmf(1 | omega)
+              + bernoulli_logit_lpmf(y[i] | logit_p[i]);
+    else // s[i] == 0
+      target += log_sum_exp(bernoulli_lpmf(1 | omega)   // z[i] == 1
+                            + bernoulli_logit_lpmf(y[i] | logit_p[i]),
+                            bernoulli_lpmf(0 | omega)); // z[i] == 0
+}
+
+generated quantities {
+  matrix<lower=0,upper=1>[M, T] p = inv_logit(logit_p);
+  int<lower=0,upper=1> z[M];
+  int<lower=C> N;
+
+  for (i in 1:M) {
+    if(s[i] > 0) {  // animal was detected at least once
+      z[i] = 1;
+    } else {        // animal never detected
+      // prob never detected given present
+      real pr = prod(rep_vector(1, T) - p[i]');
+      z[i] = bernoulli_rng(omega * pr / (omega * pr + (1 - omega)));
+    }
+  }
+  N = sum(z);
+}
+
+
diff --git a/posterior_database/models/stan/Mth_model.stan b/posterior_database/models/stan/Mth_model.stan
new file mode 100644
index 00000000..810e3a4e
--- /dev/null
+++ b/posterior_database/models/stan/Mth_model.stan
@@ -0,0 +1,75 @@
+data {
+  int<lower=0> M;               // Size of augumented data set
+  int<lower=0> T;               // Number of sampling occasions
+  int<lower=0,upper=1> y[M, T]; // Capture-history matrix
+}
+
+transformed data {
+  int<lower=0,upper=T> s[M];    // Totals in each row
+  int<lower=0,upper=M> C;       // Size of observed data set
+
+  C = 0;
+  for (i in 1:M) {
+    s[i] = sum(y[i]);
+    if (s[i] > 0)
+      C = C + 1;
+  }
+}
+
+parameters {
+  real<lower=0,upper=1> omega;          // Inclusion probability
+  real<lower=0,upper=1> mean_p[T];      // Mean detection probability
+  real<lower=0,upper=5> sigma;
+  // In case a weakly informative prior is used
+  //  real<lower=0> sigma;
+  vector[M] eps_raw;
+}
+
+transformed parameters {
+  vector[M] eps = sigma * eps_raw;    // Random effects
+  real mean_lp[T] = logit(mean_p);
+  matrix[M, T] logit_p;
+
+  for (j in 1:T)
+    logit_p[ , j] = mean_lp[j] + eps;
+}
+
+model {
+  // Priors are implicitly defined.
+  //  omega ~ uniform(0, 1);
+  //  mean_p ~ uniform(0, 1);
+  //  sigma ~ uniform(0, 5);
+  // In case a weakly informative prior is used
+  //  sigma ~ normal(2.5, 1.25);
+  eps_raw ~ normal(0, 1);
+
+  // Likelihood
+  for (i in 1:M) {
+    if (s[i] > 0)
+      // z[i] == 1
+      target += bernoulli_lpmf(1 | omega)
+              + bernoulli_logit_lpmf(y[i] | logit_p[i]);
+    else // s[i] == 0
+      target += log_sum_exp(bernoulli_lpmf(1 | omega)   // z[i] == 1
+                            + bernoulli_logit_lpmf(y[i] | logit_p[i]),
+                            bernoulli_lpmf(0 | omega)); // z[i] == 0
+  }
+}
+
+generated quantities {
+  matrix<lower=0,upper=1>[M, T] p = inv_logit(logit_p);
+  int<lower=0,upper=1> z[M];
+  int<lower=C> N;
+
+  for (i in 1:M) {
+    if(s[i] > 0) {  // animal was detected at least once
+      z[i] = 1;
+    } else {        // animal was never detected
+      // prob never detected given present
+      real pr = prod(rep_vector(1, T) - p[i]');
+      z[i] = bernoulli_rng(omega * pr / (omega * pr + (1 - omega)));
+    }
+  }
+  N = sum(z);
+}
+
diff --git a/posterior_database/models/stan/Rate_1_model.stan b/posterior_database/models/stan/Rate_1_model.stan
new file mode 100644
index 00000000..5254d2d1
--- /dev/null
+++ b/posterior_database/models/stan/Rate_1_model.stan
@@ -0,0 +1,17 @@
+
+// Inferring a Rate
+data { 
+  int<lower=1> n; 
+  int<lower=0> k;
+} 
+parameters {
+  real<lower=0,upper=1> theta;
+} 
+model {
+  // Prior Distribution for Rate Theta
+  theta ~ beta(1, 1);
+  
+  // Observed Counts
+  k ~ binomial(n, theta);
+}
+
diff --git a/posterior_database/models/stan/Rate_2_model.stan b/posterior_database/models/stan/Rate_2_model.stan
new file mode 100644
index 00000000..cbe2dbc9
--- /dev/null
+++ b/posterior_database/models/stan/Rate_2_model.stan
@@ -0,0 +1,25 @@
+
+// Difference Between Two Rates
+data { 
+  int<lower=1> n1; 
+  int<lower=1> n2; 
+  int<lower=0> k1;
+  int<lower=0> k2;
+} 
+parameters {
+  real<lower=0,upper=1> theta1;
+  real<lower=0,upper=1> theta2;
+} 
+transformed parameters {
+  real<lower=-1,upper=1> delta;
+  delta = theta1 - theta2;
+}
+model {
+  // Prior Distribution for Rate Theta
+  theta1 ~ beta(1, 1);
+  theta2 ~ beta(1, 1);
+  // Observed Counts
+  k1 ~ binomial(n1, theta1);
+  k2 ~ binomial(n2, theta2);
+}
+
diff --git a/posterior_database/models/stan/Rate_3_model.stan b/posterior_database/models/stan/Rate_3_model.stan
new file mode 100644
index 00000000..64c5235c
--- /dev/null
+++ b/posterior_database/models/stan/Rate_3_model.stan
@@ -0,0 +1,19 @@
+
+// // Inferring a Common Rate
+data { 
+  int<lower=1> n1; 
+  int<lower=1> n2; 
+  int<lower=0> k1;
+  int<lower=0> k2;
+} 
+parameters {
+  real<lower=0,upper=1> theta;
+} 
+model {
+  // Prior on Single Rate Theta
+  theta ~ beta(1, 1);
+  // Observed Counts
+  k1 ~ binomial(n1, theta);
+  k2 ~ binomial(n2, theta);
+}
+
diff --git a/posterior_database/models/stan/Rate_4_model.stan b/posterior_database/models/stan/Rate_4_model.stan
new file mode 100644
index 00000000..06471d97
--- /dev/null
+++ b/posterior_database/models/stan/Rate_4_model.stan
@@ -0,0 +1,27 @@
+
+// Prior and Posterior Prediction
+data {
+  int<lower=1> n; 
+  int<lower=0> k;
+} 
+parameters {
+  real<lower=0,upper=1> theta;
+  real<lower=0,upper=1> thetaprior;
+}
+model {
+  // Prior on Rate Theta
+  theta ~ beta(1, 1);
+  thetaprior ~ beta(1, 1);
+  // Observed Data
+  k ~ binomial(n, theta);
+}
+generated quantities {
+  int<lower=0> postpredk;
+  int<lower=0> priorpredk;
+    
+  // Posterior Predictive
+  postpredk = binomial_rng(n, theta);
+  // Prior Predictive
+  priorpredk = binomial_rng(n, thetaprior);
+}
+
diff --git a/posterior_database/models/stan/Rate_5_model.stan b/posterior_database/models/stan/Rate_5_model.stan
new file mode 100644
index 00000000..fb4b75f5
--- /dev/null
+++ b/posterior_database/models/stan/Rate_5_model.stan
@@ -0,0 +1,28 @@
+
+// Inferring a Common Rate, With Posterior Predictive
+data { 
+  int<lower=1> n1; 
+  int<lower=1> n2; 
+  int<lower=0> k1;
+  int<lower=0> k2;
+}
+parameters {
+  real<lower=0,upper=1> theta;
+} 
+model {
+  // Prior on Single Rate Theta
+  theta ~ beta(1, 1);
+  
+  // Observed Counts
+  k1 ~ binomial(n1, theta);
+  k2 ~ binomial(n2, theta);
+}
+generated quantities {
+  int<lower=0,upper=n1> postpredk1;
+  int<lower=0,upper=n2> postpredk2;
+    
+  // Posterior Predictive
+  postpredk1 = binomial_rng(n1, theta);
+  postpredk2 = binomial_rng(n2, theta);
+}
+
diff --git a/posterior_database/models/stan/Survey_model.stan b/posterior_database/models/stan/Survey_model.stan
new file mode 100644
index 00000000..14fb56bf
--- /dev/null
+++ b/posterior_database/models/stan/Survey_model.stan
@@ -0,0 +1,48 @@
+
+/*
+ * Notes to Stan model
+ * --------------------
+ * This model code is more difficult to understand in Stan implementation since
+ * Stan is unable to sample discrete parameters. This may change in the future.
+ * For better understanding read Stan manual chapter 'Mixture Modeling' (p.68 in
+ * version 2.4.0) first.
+ */
+
+// Inferring Return Rate and Number of Surveys from Observed Returns
+data {
+  int<lower=0> nmax;
+  int<lower=0> m;
+  int<lower=0,upper=nmax> k[m];
+}
+transformed data {
+  int<lower=0> nmin;  // Minimal possible n
+
+  nmin = max(k);
+}
+parameters {
+  real<lower=0,upper=1> theta;
+}
+transformed parameters {
+  vector[nmax] lp_parts;  // Log probability for each n
+
+  // First part of the trick for mixture model
+  for (n in 1:nmax)
+    if (n < nmin)
+      lp_parts[n] = log(1.0 / nmax) + negative_infinity();  // Zero probability
+    else
+      lp_parts[n] = log(1.0 / nmax) + binomial_lpmf(k | n, theta);
+      // Deprecated: lp_parts[n] = log(1.0 / nmax) + binomial_log(k, n, theta);
+}
+model {
+  // Second part of the trick for mixture model
+  // Deprecated: increment_log_prob(log_sum_exp(lp_parts));
+  target += log_sum_exp(lp_parts);
+}
+generated quantities {
+  int<lower=1,upper=nmax> n;
+  simplex[nmax] prob_n;
+
+  // Transforming lp_parts to probabilities of each n
+  prob_n = softmax(lp_parts);
+  n = categorical_rng(prob_n);
+}
diff --git a/posterior_database/models/stan/bym2_offset_only.stan b/posterior_database/models/stan/bym2_offset_only.stan
new file mode 100644
index 00000000..0d77a4ed
--- /dev/null
+++ b/posterior_database/models/stan/bym2_offset_only.stan
@@ -0,0 +1,49 @@
+// source: https://github.com/stan-dev/example-models/blob/master/knitr/car-iar-poisson/bym2_offset_only.stan
+// use for case study NYC data subset
+data {
+  int<lower=0> N;
+  int<lower=0> N_edges;
+  int<lower=1, upper=N> node1[N_edges];  // node1[i] adjacent to node2[i]
+  int<lower=1, upper=N> node2[N_edges];  // and node1[i] < node2[i]
+
+  int<lower=0> y[N];              // count outcomes
+  vector<lower=0>[N] E;           // exposure
+
+  real<lower=0> scaling_factor; // scales the variance of the spatial effects
+}
+transformed data {
+  vector[N] log_E = log(E);
+}
+parameters {
+  real beta0;                // intercept
+
+  real<lower=0> sigma;        // overall standard deviation
+  real<lower=0, upper=1> rho; // proportion unstructured vs. spatially structured variance
+
+  vector[N] theta;       // heterogeneous effects
+  vector[N] phi;  // spatial effects
+}
+transformed parameters {
+  vector[N] convolved_re;
+  // variance of each component should be approximately equal to 1
+  convolved_re =  sqrt(1 - rho) * theta + sqrt(rho / scaling_factor) * phi;
+}
+model {
+  y ~ poisson_log(log_E + beta0 + convolved_re * sigma);
+
+  target += -0.5 * dot_self(phi[node1] - phi[node2]);
+
+  beta0 ~ normal(0, 1);
+  theta ~ normal(0, 1);
+  sigma ~ normal(0, 1);
+  rho ~ beta(0.5, 0.5);
+  // soft sum-to-zero constraint on phi)
+  sum(phi) ~ normal(0, 0.001 * N);  // equivalent to mean(phi) ~ normal(0,0.001)
+}
+generated quantities {
+  real log_precision = -2.0 * log(sigma);
+  real logit_rho = log(rho / (1.0 - rho));
+  vector[N] eta = log_E + beta0 + convolved_re * sigma;
+  vector[N] mu = exp(eta);
+}
+
diff --git a/posterior_database/models/stan/gpcm_latent_reg_irt.stan b/posterior_database/models/stan/gpcm_latent_reg_irt.stan
new file mode 100644
index 00000000..4f8a32e7
--- /dev/null
+++ b/posterior_database/models/stan/gpcm_latent_reg_irt.stan
@@ -0,0 +1,84 @@
+functions {
+  real pcm(int y, real theta, vector beta) {
+    vector[rows(beta) + 1] unsummed;
+    vector[rows(beta) + 1] probs;
+    unsummed = append_row(rep_vector(0.0, 1), theta - beta);
+    probs = softmax(cumulative_sum(unsummed));
+    return categorical_lpmf(y + 1 | probs);
+  }
+  matrix obtain_adjustments(matrix W) {
+    real min_w;
+    real max_w;
+    int minmax_count;
+    matrix[2, cols(W)] adj;
+    adj[1, 1] = 0;
+    adj[2, 1] = 1;
+    if(cols(W) > 1) {
+      for(k in 2:cols(W)) {                       // remaining columns
+        min_w = min(W[1:rows(W), k]);
+        max_w = max(W[1:rows(W), k]);
+        minmax_count = 0;
+        for(j in 1:rows(W))
+          minmax_count = minmax_count + W[j,k] == min_w || W[j,k] == max_w;
+        if(minmax_count == rows(W)) {       // if column takes only 2 values
+          adj[1, k] = mean(W[1:rows(W), k]);
+          adj[2, k] = (max_w - min_w);
+        } else {                            // if column takes > 2 values
+          adj[1, k] = mean(W[1:rows(W), k]);
+          adj[2, k] = sd(W[1:rows(W), k]) * 2;
+        }
+      }
+    }
+    return adj;
+  }
+}
+data {
+  int<lower=1> I;                // # items
+  int<lower=1> J;                // # persons
+  int<lower=1> N;                // # responses
+  int<lower=1,upper=I> ii[N];    // i for n
+  int<lower=1,upper=J> jj[N];    // j for n
+  int<lower=0> y[N];             // response for n; y = 0, 1 ... m_i
+  int<lower=1> K;                // # person covariates
+  matrix[J,K] W;                 // person covariate matrix
+}
+transformed data {
+  int m[I];                      // # parameters per item
+  int pos[I];                    // first position in beta vector for item
+  matrix[2,K] adj;               // values for centering and scaling covariates
+  matrix[J,K] W_adj;             // centered and scaled covariates
+  m = rep_array(0, I);
+  for(n in 1:N)
+    if(y[n] > m[ii[n]]) m[ii[n]] = y[n];
+  pos[1] = 1;
+  for(i in 2:(I))
+    pos[i] = m[i-1] + pos[i-1];
+  adj = obtain_adjustments(W);
+  for(k in 1:K) for(j in 1:J)
+      W_adj[j,k] = (W[j,k] - adj[1,k]) / adj[2,k];
+}
+parameters {
+  vector<lower=0>[I] alpha;
+  vector[sum(m)-1] beta_free;
+  vector[J] theta;
+  vector[K] lambda_adj;
+}
+transformed parameters {
+  vector[sum(m)] beta;
+  beta[1:(sum(m)-1)] = beta_free;
+  beta[sum(m)] = -1*sum(beta_free);
+}
+model {
+  alpha ~ lognormal(1, 1);
+  target += normal_lpdf(beta | 0, 3);
+  theta ~ normal(W_adj*lambda_adj, 1);
+  lambda_adj ~ student_t(3, 0, 1);
+  for (n in 1:N)
+    target += pcm(y[n], theta[jj[n]].*alpha[ii[n]],
+                  segment(beta, pos[ii[n]], m[ii[n]]));
+}
+generated quantities {
+  vector[K] lambda;
+  lambda[2:K] = lambda_adj[2:K] ./ to_vector(adj[2,2:K]);
+  lambda[1] = W_adj[1, 1:K]*lambda_adj[1:K] - W[1, 2:K]*lambda[2:K];
+}
diff --git a/posterior_database/models/stan/grsm_latent_reg_irt.stan b/posterior_database/models/stan/grsm_latent_reg_irt.stan
new file mode 100644
index 00000000..405175cc
--- /dev/null
+++ b/posterior_database/models/stan/grsm_latent_reg_irt.stan
@@ -0,0 +1,80 @@
+functions {
+  real rsm(int y, real theta, real beta, vector kappa) {
+    vector[rows(kappa) + 1] unsummed;
+    vector[rows(kappa) + 1] probs;
+    unsummed = append_row(rep_vector(0, 1), theta - beta - kappa);
+    probs = softmax(cumulative_sum(unsummed));
+    return categorical_lpmf(y + 1 | probs);
+  }
+  matrix obtain_adjustments(matrix W) {
+    real min_w;
+    real max_w;
+    int minmax_count;
+    matrix[2, cols(W)] adj;
+    adj[1, 1] = 0;
+    adj[2, 1] = 1;
+    if(cols(W) > 1) {
+      for(k in 2:cols(W)) {                       // remaining columns
+        min_w = min(W[1:rows(W), k]);
+        max_w = max(W[1:rows(W), k]);
+        minmax_count = 0;
+        for(j in 1:rows(W))
+          minmax_count = minmax_count + W[j,k] == min_w || W[j,k] == max_w;
+        if(minmax_count == rows(W)) {       // if column takes only 2 values
+          adj[1, k] = mean(W[1:rows(W), k]);
+          adj[2, k] = (max_w - min_w);
+        } else {                            // if column takes > 2 values
+          adj[1, k] = mean(W[1:rows(W), k]);
+          adj[2, k] = sd(W[1:rows(W), k]) * 2;
+        }
+      }
+    }
+    return adj;
+  }
+}
+data {
+  int<lower=1> I;                // # items
+  int<lower=1> J;                // # persons
+  int<lower=1> N;                // # responses
+  int<lower=1,upper=I> ii[N];    // i for n
+  int<lower=1,upper=J> jj[N];    // j for n
+  int<lower=0> y[N];             // response for n; y in {0 ... m_i}
+  int<lower=1> K;                // # person covariates
+  matrix[J,K] W;                 // person covariate matrix
+}
+transformed data {
+  int m;                         // # steps
+  matrix[2,K] adj;               // values for centering and scaling covariates
+  matrix[J,K] W_adj;             // centered and scaled covariates
+  m = max(y);
+  adj = obtain_adjustments(W);
+  for(k in 1:K) for(j in 1:J)
+      W_adj[j,k] = (W[j,k] - adj[1,k]) / adj[2,k];
+}
+parameters {
+  vector<lower=0>[I] alpha;
+  vector[I-1] beta_free;
+  vector[m-1] kappa_free;
+  vector[J] theta;
+  vector[K] lambda_adj;
+}
+transformed parameters {
+  vector[I] beta;
+  vector[m] kappa;
+  beta = append_row(beta_free, rep_vector(-1*sum(beta_free), 1));
+  kappa = append_row(kappa_free, rep_vector(-1*sum(kappa_free), 1));
+}
+model {
+  alpha ~ lognormal(1, 1);
+  target += normal_lpdf(beta | 0, 3);
+  target += normal_lpdf(kappa | 0, 3);
+  theta ~ normal(W_adj*lambda_adj, 1);
+  lambda_adj ~ student_t(3, 0, 1);
+  for (n in 1:N)
+    target += rsm(y[n], theta[jj[n]] .* alpha[ii[n]], beta[ii[n]], kappa);
+}
+generated quantities {
+  vector[K] lambda;
+  lambda[2:K] = lambda_adj[2:K] ./ to_vector(adj[2,2:K]);
+  lambda[1] = W_adj[1, 1:K]*lambda_adj[1:K] - W[1, 2:K]*lambda[2:K];
+}
diff --git a/posterior_database/models/stan/hier_2pl.stan b/posterior_database/models/stan/hier_2pl.stan
index a056d139..fafb0780 100644
--- a/posterior_database/models/stan/hier_2pl.stan
+++ b/posterior_database/models/stan/hier_2pl.stan
@@ -30,7 +30,7 @@ model {
   matrix[2,2] L_Sigma;
   L_Sigma = diag_pre_multiply(tau, L_Omega);
   for (i in 1:I)
-    xi[i] ~ multi_normal_cholesky(mu, L_Sigma);
+    target +=  multi_normal_cholesky_lpdf(xi[i] |mu, L_Sigma);
   theta ~ normal(0, 1);
   L_Omega ~ lkj_corr_cholesky(4);
   mu[1] ~ normal(0,1);
diff --git a/posterior_database/models/stan/hierarchical_gp.stan b/posterior_database/models/stan/hierarchical_gp.stan
new file mode 100644
index 00000000..bfdb3e46
--- /dev/null
+++ b/posterior_database/models/stan/hierarchical_gp.stan
@@ -0,0 +1,152 @@
+data {
+  int<lower=1> N;
+  int<lower=1> N_states;
+  int<lower=1> N_regions;
+  int<lower=1> N_years_obs;
+  int<lower=1> N_years;
+  int<lower=1> state_region_ind[N_states];
+  int<lower=1,upper=50> state_ind[N];
+  int<lower=1,upper=10> region_ind[N];
+  int<lower=1> year_ind[N];
+  //vector<lower=0>[N] turnout_weight;
+  vector<lower=0,upper=1>[N] y;
+}
+transformed data {
+  real years[N_years];
+  vector[17] counts;
+
+  for (t in 1:N_years)
+    years[t] = t;
+  for (i in 1:17)
+    counts[i] = 2;
+}
+parameters {
+  matrix[N_years,N_regions] GP_region_std;
+  matrix[N_years,N_states] GP_state_std;
+  vector[N_years_obs] year_std;
+  vector[N_states] state_std;
+  vector[N_regions] region_std;
+  real<lower=0> tot_var;
+  simplex[17] prop_var;
+  real mu;
+
+
+  real<lower=0> length_GP_region_long;
+  real<lower=0> length_GP_state_long;
+  real<lower=0> length_GP_region_short;
+  real<lower=0> length_GP_state_short;
+}
+transformed parameters {
+  matrix[N_years,N_regions] GP_region;
+  matrix[N_years,N_states] GP_state;
+
+  vector[N_years_obs] year_re;
+  vector[N_states] state_re;
+  vector[N_regions] region_re;
+  vector[17] vars;
+
+  real sigma_year;
+  real sigma_region;
+  vector[10] sigma_state;
+
+  real sigma_error_state_2;
+
+  real sigma_GP_region_long;
+  real sigma_GP_state_long;
+  real sigma_GP_region_short;
+  real sigma_GP_state_short;
+
+  vars = 17 * prop_var * tot_var;
+  sigma_year = sqrt(vars[1]);
+  sigma_region = sqrt(vars[2]);
+  for (i in 1:10)
+    sigma_state[i] = sqrt(vars[i + 2]);
+
+  sigma_GP_region_long = sqrt(vars[13]);
+  sigma_GP_state_long = sqrt(vars[14]);
+  sigma_GP_region_short = sqrt(vars[15]);
+  sigma_GP_state_short = sqrt(vars[16]);
+  sigma_error_state_2 = sqrt(vars[17]);
+
+  region_re = sigma_region * region_std;
+  year_re = sigma_year * year_std;
+  state_re = sigma_state[state_region_ind] .* state_std;
+
+  {
+    matrix[N_years, N_years] cov_region;
+    matrix[N_years, N_years] cov_state;
+    matrix[N_years, N_years] L_cov_region;
+    matrix[N_years, N_years] L_cov_state;
+    // replace cov_exp_quad with gp_exp_quad_cov. What is the difference?
+    cov_region = cov_exp_quad(years, sigma_GP_region_long,
+                                  length_GP_region_long)
+               + cov_exp_quad(years, sigma_GP_region_short,
+                                  length_GP_region_short);
+    cov_state = cov_exp_quad(years, sigma_GP_state_long,
+                                  length_GP_state_long)
+               + cov_exp_quad(years, sigma_GP_state_short,
+                                  length_GP_state_short);
+    for (year in 1:N_years) {
+      cov_region[year, year] = cov_region[year, year] + 1e-6;
+      cov_state[year, year] = cov_state[year, year] + 1e-6;
+    }
+
+    L_cov_region = cholesky_decompose(cov_region);
+    L_cov_state = cholesky_decompose(cov_state);
+    GP_region = L_cov_region * GP_region_std;
+    GP_state = L_cov_state * GP_state_std;
+  }
+}
+model {
+  vector[N] obs_mu;
+
+  for (n in 1:N) {
+    obs_mu[n] = mu + year_re[year_ind[n]]
+              + state_re[state_ind[n]]
+              + region_re[region_ind[n]]
+              + GP_region[year_ind[n],region_ind[n]]
+              + GP_state[year_ind[n],state_ind[n]];
+  }
+  y ~ normal(obs_mu, sigma_error_state_2); //* turnout_weight);
+
+  to_vector(GP_region_std) ~ normal(0, 1);
+  to_vector(GP_state_std) ~ normal(0, 1);
+  year_std ~ normal(0, 1);
+  state_std ~ normal(0, 1);
+  region_std ~ normal(0, 1);
+  mu ~ normal(.5, .5);
+  tot_var ~ gamma(3, 3);
+  prop_var ~ dirichlet(counts);
+  length_GP_region_long ~ weibull(30,8);
+  length_GP_state_long ~ weibull(30,8);
+  length_GP_region_short ~ weibull(30,3);
+  length_GP_state_short ~ weibull(30,3);
+}
+generated quantities {
+  matrix[N_years,N_states] y_new;
+  matrix[N_years,N_states] y_new_pred;
+
+  {
+    real level;
+    level = normal_rng(0.5, sigma_year);
+    for (state in 1:N_states) {
+      for (t in 1:N_years) {
+        if (t < 12) {
+          y_new[t,state] = state_re[state]
+                         + region_re[state_region_ind[state]]
+                         + GP_state[t,state]
+                         + GP_region[t,state_region_ind[state]]
+                         + (mu + year_re[t]);
+        } else {
+          y_new[t,state] = state_re[state]
+                         + region_re[state_region_ind[state]]
+                         + GP_state[t,state]
+                         + GP_region[t,state_region_ind[state]]
+                         + level;
+        }
+        y_new_pred[t,state] = normal_rng(y_new[t,state],
+                                         sigma_error_state_2);
+      }
+    }
+  }
+}
diff --git a/posterior_database/models/stan/hmm_gaussian.stan b/posterior_database/models/stan/hmm_gaussian.stan
new file mode 100644
index 00000000..ff883478
--- /dev/null
+++ b/posterior_database/models/stan/hmm_gaussian.stan
@@ -0,0 +1,132 @@
+// source: https://github.com/luisdamiano/stancon18/blob/master/stan/hmm_gaussian.stan
+
+functions {
+  vector normalize(vector x) {
+    return x / sum(x);
+  }
+}
+
+data {
+  int<lower=1> T;                   // number of observations (length)
+  int<lower=1> K;                   // number of hidden states
+  real y[T];                        // observations
+}
+
+parameters {
+  // Discrete state model
+  simplex[K] pi1;                   // initial state probabilities
+  simplex[K] A[K];                  // transition probabilities
+                                    // A[i][j] = p(z_t = j | z_{t-1} = i)
+
+  // Continuous observation model
+  ordered[K] mu;                    // observation means
+  real<lower=0> sigma[K];           // observation standard deviations
+}
+
+transformed parameters {
+  vector[K] logalpha[T];
+
+  { // Forward algorithm log p(z_t = j | x_{1:t})
+    real accumulator[K];
+
+    logalpha[1] = log(pi1) + normal_lpdf(y[1] | mu, sigma);
+
+    for (t in 2:T) {
+      for (j in 1:K) { // j = current (t)
+        for (i in 1:K) { // i = previous (t-1)
+                         // Murphy (2012) Eq. 17.48
+                         // belief state      + transition prob + local evidence at t
+          accumulator[i] = logalpha[t-1, i] + log(A[i, j]) + normal_lpdf(y[t] | mu[j], sigma[j]);
+        }
+        logalpha[t, j] = log_sum_exp(accumulator);
+      }
+    }
+  } // Forward
+}
+
+model {
+  target += log_sum_exp(logalpha[T]); // Note: update based only on last logalpha
+}
+
+generated quantities {
+  vector[K] logbeta[T];
+  vector[K] loggamma[T];
+
+  vector[K] alpha[T];
+  vector[K] beta[T];
+  vector[K] gamma[T];
+
+  int<lower=1, upper=K> zstar[T];
+  real logp_zstar;
+
+  { // Forward algortihm
+    for (t in 1:T)
+      alpha[t] = softmax(logalpha[t]);
+  } // Forward
+
+  { // Backward algorithm log p(x_{t+1:T} | z_t = j)
+    real accumulator[K];
+
+    for (j in 1:K)
+      logbeta[T, j] = 1;
+
+    for (tforward in 0:(T-2)) {
+      int t;
+      t = T - tforward;
+
+      for (j in 1:K) { // j = previous (t-1)
+        for (i in 1:K) { // i = next (t)
+                         // Murphy (2012) Eq. 17.58
+                         // backwards t    + transition prob + local evidence at t
+          accumulator[i] = logbeta[t, i] + log(A[j, i]) + normal_lpdf(y[t] | mu[i], sigma[i]);
+          }
+        logbeta[t-1, j] = log_sum_exp(accumulator);
+      }
+    }
+
+    for (t in 1:T)
+      beta[t] = softmax(logbeta[t]);
+  } // Backward
+
+  { // Forwards-backwards algorithm log p(z_t = j | x_{1:T})
+    for(t in 1:T) {
+        loggamma[t] = alpha[t] .* beta[t];
+    }
+
+    for(t in 1:T)
+      gamma[t] = normalize(loggamma[t]);
+  } // Forwards-backwards
+
+  { // Viterbi algorithm
+    int bpointer[T, K];             // backpointer to the most likely previous state on the most probable path
+    real delta[T, K];               // max prob for the seq up to t
+                                    // with final output from state k for time t
+
+    for (j in 1:K)
+      delta[1, K] = normal_lpdf(y[1] | mu[j], sigma[j]);
+
+    for (t in 2:T) {
+      for (j in 1:K) { // j = current (t)
+        delta[t, j] = negative_infinity();
+        for (i in 1:K) { // i = previous (t-1)
+          real logp;
+          logp = delta[t-1, i] + log(A[i, j]) + normal_lpdf(y[t] | mu[j], sigma[j]);
+          if (logp > delta[t, j]) {
+            bpointer[t, j] = i;
+            delta[t, j] = logp;
+          }
+        }
+      }
+    }
+
+    logp_zstar = max(delta[T]);
+
+    for (j in 1:K)
+      if (delta[T, j] == logp_zstar)
+        zstar[T] = j;
+
+    for (t in 1:(T - 1)) {
+      zstar[T - t] = bpointer[T - t + 1, zstar[T - t + 1]];
+    }
+  }
+}
diff --git a/posterior_database/models/stan/iohmm_reg.stan b/posterior_database/models/stan/iohmm_reg.stan
new file mode 100644
index 00000000..2613ebbb
--- /dev/null
+++ b/posterior_database/models/stan/iohmm_reg.stan
@@ -0,0 +1,191 @@
+// source: https://github.com/luisdamiano/stancon18/blob/master/stan/iohmm_reg.stan
+
+functions {
+  vector normalize(vector x) {
+    return x / sum(x);
+  }
+}
+
+data {
+  int<lower=1> T;                   // number of observations (length)
+  int<lower=1> K;                   // number of hidden states
+
+  int<lower=1> M;                   // size of the input vector
+  real y[T];                        // output (scalar)
+  vector[M] u[T];                   // input (vector)
+}
+
+parameters {
+  // Discrete state model
+  simplex[K] pi1;                   // initial state probabilities
+  vector[M] w[K];                   // state regressors
+
+  // Continuous observation model
+  vector[M] b[K];                   // mean regressors
+  real<lower=0> sigma[K];           // residual standard deviations
+}
+
+transformed parameters {
+  vector[K] logalpha[T];
+
+  vector[K] unA[T];
+  vector[K] A[T];
+  vector[K] logA[T];
+
+  vector[K] logoblik[T];
+
+  { // Transition probability matrix p(z_t = j | z_{t-1} = i, u)
+    unA[1] = pi1;           // Filler
+    A[1] = pi1;             // Filler x2
+    logA[1] = log(A[1]);    // Filler x3
+
+    for (t in 2:T) {
+      for (j in 1:K) { // j = current (t)
+        unA[t][j] = u[t]' * w[j];
+      }
+      A[t] = softmax(unA[t]);
+      logA[t] = log(A[t]);
+    }
+  }
+
+  { // Observation likelihood
+    for(t in 1:T) {
+      for(j in 1:K) {
+        logoblik[t][j] = normal_lpdf(y[t] | u[t]'* b[j], sigma[j]);
+      }
+    }
+  }
+
+  { // Forward algorithm log p(z_t = j | x_{1:t})
+    real accumulator[K];
+
+    for(j in 1:K)
+      logalpha[1][j] = log(pi1[j]) + logoblik[1][j];
+
+    for (t in 2:T) {
+      for (j in 1:K) { // j = current (t)
+        for (i in 1:K) { // i = previous (t-1)
+                         // Murphy (2012) Eq. 17.48
+                         // belief state + transition prob + local evidence at t
+          accumulator[i] = logalpha[t-1, i] + logA[t][i] + logoblik[t][j];
+        }
+        logalpha[t, j] = log_sum_exp(accumulator);
+      }
+    }
+  } // Forward
+}
+
+model {
+  for(j in 1:K) {
+    w[j] ~ normal(0, 5);
+    b[j] ~ normal(0, 5);
+    sigma[j] ~ normal(0, 3);
+  }
+
+  target += log_sum_exp(logalpha[T]); // Note: update based only on last logalpha
+}
+
+generated quantities {
+  vector[K] logbeta[T];
+  vector[K] loggamma[T];
+
+  vector[K] alpha[T];
+  vector[K] beta[T];
+  vector[K] gamma[T];
+
+  vector[K] hatpi[T];
+  int<lower=1, upper=K> hatz[T];
+  real haty[T];
+
+  int<lower=1, upper=K> zstar[T];
+  real logp_zstar;
+
+  { // Forward algorithm log p(z_t = j | x_{1:t})
+    for (t in 1:T)
+      alpha[t] = softmax(logalpha[t]);
+  } // Forward
+
+  { // Backward algorithm log p(x_{t+1:T} | z_t = j)
+    real accumulator[K];
+    int tbackwards;
+
+    for (j in 1:K)
+      logbeta[T, j] = 1;
+
+    for (tforwards in 0:(T-2)) {
+      tbackwards = T - tforwards;
+
+      for (j in 1:K) { // j = previous (t-1)
+        for (i in 1:K) { // i = next (t)
+                         // Murphy (2012) Eq. 17.58
+                         // backwards t  + transition prob + local evidence at t
+          accumulator[i] = logbeta[tbackwards, i] + logA[tbackwards][i] + logoblik[tbackwards][i];
+          }
+        logbeta[tbackwards-1, j] = log_sum_exp(accumulator);
+      }
+    }
+
+    for (t in 1:T)
+      beta[t] = softmax(logbeta[t]);
+  } // Backward
+
+  { // Forwards-backwards algorithm log p(z_t = j | x_{1:T})
+    for(t in 1:T)
+      loggamma[t] = alpha[t] .* beta[t];
+
+    for(t in 1:T)
+      gamma[t] = normalize(loggamma[t]);
+  } // Forwards-backwards
+
+  { // Fitted state
+    vector[K] reg[T];
+    for(t in 1:T) {
+      for(j in 1:K) {
+        reg[t, j] = u[t]' * to_vector(w[j]);
+      }
+      hatpi[t] = softmax(reg[t]);
+      hatz[t] = categorical_rng(hatpi[t]);
+    }
+  }
+
+  { // Fitted output
+    real reg[T];
+    for(t in 1:T) {
+      reg[t] = u[t]' * b[hatz[t]];
+      haty[t] = normal_rng(reg[t], sigma[hatz[t]]);
+    }
+  }
+
+  { // Viterbi decoding
+    int bpointer[T, K];             // backpointer to the source of the link
+    real delta[T, K];               // max prob for the seq up to t
+                                    // with final output from state k for time t
+
+    for (j in 1:K)
+      delta[1, K] = logoblik[1][j];
+
+    for (t in 2:T) {
+      for (j in 1:K) {
+        delta[t, j] = negative_infinity();
+        for (i in 1:K) {
+          real logp;
+          logp = delta[t-1, i] + logA[t][i] + logoblik[t][j];
+          if (logp > delta[t, j]) {
+            bpointer[t, j] = i;
+            delta[t, j] = logp;
+          }
+        }
+      }
+    }
+
+    logp_zstar = max(delta[T]);
+
+    for (j in 1:K)
+      if (delta[T, j] == logp_zstar)
+        zstar[T] = j;
+
+    for (t in 1:(T - 1)) {
+      zstar[T - t] = bpointer[T - t + 1, zstar[T - t + 1]];
+    }
+  }
+}
diff --git a/posterior_database/models/stan/kronecker_gp.stan b/posterior_database/models/stan/kronecker_gp.stan
new file mode 100644
index 00000000..d5bacad3
--- /dev/null
+++ b/posterior_database/models/stan/kronecker_gp.stan
@@ -0,0 +1,86 @@
+functions {
+ // return (A \otimes B) v where:
+ // A is n1 x n1, B = n2 x n2, V = n2 x n1 = reshape(v,n2,n1)
+ matrix kron_mvprod(matrix A, matrix B, matrix V) {
+   return transpose(A * transpose(B * V));
+ }
+ // A is a length n1 vector, B is a length n2 vector.
+ // Treating them as diagonal matrices, this calculates:
+ // v = (A \otimes B + sigma2)ˆ{-1}
+ // and returns the n1 x n2 matrix V = reshape(v,n1,n2)
+ matrix calculate_eigenvalues(vector A, vector B, int n1, int n2, real sigma2) {
+   matrix[n1,n2] e;
+   for(i in 1:n1) {
+    for(j in 1:n2) {
+      e[i,j] = (A[i] * B[j] + sigma2);
+   } }
+   return(e);
+ }
+}
+data {
+ int<lower=1> n1;
+ int<lower=1> n2; // categories for learning cross-type correlations
+ vector[n2] x1; // observation locations (e.g. timestamps)
+ matrix[n2,n1] y; // NB: this should be reshape(y, n2, n1),
+}
+transformed data {
+ matrix[n1, n1] xd;
+
+// where y corresponds to expand.grid(x2,x1). // To double-check, make sure that y[i,j] is // the observation from category x2[i]
+// at location x1[j]
+ for (i in 1:n1) {
+   xd[i, i] = 0;
+   for (j in (i+1):n1) {
+    xd[i, j] = -((x1[i]-x1[j]) ^ 2);
+    xd[j, i] = xd[i, j];
+   }
+  }
+}
+parameters {
+ real<lower=0> var1; // signal variance
+ real<lower=0> bw1; // this is equivalent to 1/sqrt(length-scale)
+
+ cholesky_factor_corr[n2] L;
+ real<lower=0.00001> sigma1;
+}
+
+transformed parameters {
+ matrix[n1, n1] Sigma1;
+ matrix[n1, n1] Q1;
+ vector[n1] R1;
+ matrix[n2, n2] Q2;
+ vector[n2] R2;
+ matrix<lower=0>[n2,n1] eigenvalues;
+ matrix[n2, n2] Lambda = multiply_lower_tri_self_transpose(L);
+
+ Sigma1 = var1 * exp(xd * bw1);
+
+ for(i in 1:n1)
+   Sigma1[i,i] = Sigma1[i,i] + .00001;
+
+ Q1 = eigenvectors_sym(Sigma1);
+ R1 = eigenvalues_sym(Sigma1);
+ Q2 = eigenvectors_sym(Lambda);
+ R2 = eigenvalues_sym(Lambda);
+ eigenvalues = calculate_eigenvalues(R2,R1,n2,n1,sigma1);
+}
+
+model {
+ var1 ~ lognormal(0,1);
+ bw1 ~ cauchy(0,2.5);
+ sigma1 ~ lognormal(0,1);
+ L ~ lkj_corr_cholesky(2);
+
+  target +=
+   -0.5 * sum(y .* kron_mvprod(Q1,Q2, // calculates -0.5 * y’ (K1 \otimes K2) y
+          kron_mvprod(transpose(Q1),transpose(Q2),y) ./ eigenvalues))
+     -0.5 * sum(log(eigenvalues)); // calculates logdet(K1 \otimes K2)
+}
+generated quantities{
+  //real test = -0.5 * sum(y .* kron_mvprod(Q1,Q2, // calculates -0.5 * y’ (K1 \otimes K2) y
+  //         kron_mvprod(transpose(Q1),transpose(Q2),y) ./ eigenvalues))
+  //    -0.5 * sum(log(eigenvalues));
+}
+
+
+// how do you sample cmdstanr? generate quantities
diff --git a/posterior_database/models/stan/ldaK2.stan b/posterior_database/models/stan/ldaK2.stan
index cb9e6d1b..97a2e73f 100644
--- a/posterior_database/models/stan/ldaK2.stan
+++ b/posterior_database/models/stan/ldaK2.stan
@@ -21,7 +21,7 @@ parameters {
 model {
   for (m in 1:M)
     theta[m] ~ dirichlet(alpha);  // prior
-  for (k in 1:5)
+  for (k in 1:K)
     phi[k] ~ dirichlet(beta);     // prior
   for (n in 1:N) {
     real gamma[K];
diff --git a/posterior_database/models/stan/losscurve_sislob.stan b/posterior_database/models/stan/losscurve_sislob.stan
new file mode 100644
index 00000000..acb1db31
--- /dev/null
+++ b/posterior_database/models/stan/losscurve_sislob.stan
@@ -0,0 +1,120 @@
+functions {
+    real growth_factor_weibull(real t, real omega, real theta) {
+        return 1 - exp(-(t/theta)^omega);
+    }
+
+    real growth_factor_loglogistic(real t, real omega, real theta) {
+        real pow_t_omega = t^omega;
+        return pow_t_omega / (pow_t_omega + theta^omega);
+    }
+}
+
+data {
+    int<lower=0,upper=1> growthmodel_id;
+
+    int n_data;
+    int n_time;
+    int n_cohort;
+
+    int cohort_id[n_data];
+    int t_idx[n_data];
+
+    int cohort_maxtime[n_cohort];
+
+    vector<lower=0>[n_time] t_value;
+
+    vector[n_cohort] premium;
+    vector[n_data]   loss;
+}
+
+parameters {
+    real<lower=0> omega;
+    real<lower=0> theta;
+
+    vector<lower=0>[n_cohort] LR;
+
+    real mu_LR;
+    real<lower=0> sd_LR;
+
+    real<lower=0> loss_sd;
+}
+
+transformed parameters {
+    vector[n_time] gf;
+    vector[n_data] lm;
+
+    for(i in 1:n_time) {
+        gf[i] = growthmodel_id == 1 ?
+            growth_factor_weibull    (t_value[i], omega, theta) :
+            growth_factor_loglogistic(t_value[i], omega, theta);
+    }
+
+    for (i in 1:n_data) {
+        lm[i] = LR[cohort_id[i]] * premium[cohort_id[i]] * gf[t_idx[i]];
+    }
+}
+
+model {
+    mu_LR ~ normal(0, 0.5);
+    sd_LR ~ lognormal(0, 0.5);
+
+    LR ~ lognormal(mu_LR, sd_LR);
+
+    loss_sd ~ lognormal(0, 0.7);
+
+    omega ~ lognormal(0, 0.5);
+    theta ~ lognormal(0, 0.5);
+
+    loss ~ normal(lm, (loss_sd * premium)[cohort_id]);
+}
+
+
+generated quantities {
+    vector<lower=0>[n_time] loss_sample[n_cohort];
+    vector<lower=0>[n_time] loss_prediction[n_cohort];
+    vector<lower=0>[n_time] step_ratio[n_cohort];
+
+    real mu_LR_exp;
+
+    real<lower=0> ppc_minLR;
+    real<lower=0> ppc_maxLR;
+    real<lower=0> ppc_EFC;
+
+    for(i in 1:n_cohort) {
+        step_ratio[i]  = rep_vector(1, n_time);
+        loss_sample[i] = LR[i] * premium[i] * gf;
+    }
+
+
+
+    mu_LR_exp = exp(mu_LR);
+
+    for(i in 1:n_data) {
+        loss_prediction[cohort_id[i], t_idx[i]] = loss[i];
+    }
+
+    for(i in 1:n_cohort) {
+        for(j in 2:n_time) {
+            step_ratio[i, j] = gf[t_idx[j]] / gf[t_idx[j-1]];
+        }
+    }
+
+    for(i in 1:n_cohort) {
+        for(j in (cohort_maxtime[i]+1):n_time) {
+            loss_prediction[i,j] = loss_prediction[i,j-1] * step_ratio[i,j];
+        }
+    }
+
+
+    // Create PPC distributions for the max/min of LR
+    ppc_minLR = min(LR);
+    ppc_maxLR = max(LR);
+
+
+    // Create total reserve PPC
+    ppc_EFC = 0;
+
+    for(i in 1:n_cohort) {
+        ppc_EFC = ppc_EFC + loss_prediction[i, n_time] - loss_prediction[i, cohort_maxtime[i]];
+    }
+}
diff --git a/posterior_database/models/stan/multi_occupancy.stan b/posterior_database/models/stan/multi_occupancy.stan
index c7d0e877..17454aac 100644
--- a/posterior_database/models/stan/multi_occupancy.stan
+++ b/posterior_database/models/stan/multi_occupancy.stan
@@ -61,7 +61,8 @@ model {
   beta ~ cauchy(0, 2.5);
   sigma_uv ~ cauchy(0, 2.5);
   (rho_uv + 1) / 2 ~ beta(2, 2);
-  uv ~ multi_normal(rep_vector(0, 2), cov_matrix_2d(sigma_uv, rho_uv));
+  // Parse warnings: uv ~ multi_normal(rep_vector(0, 2), cov_matrix_2d(sigma_uv, rho_uv));
+  target += multi_normal_lpdf(uv | rep_vector(0, 2), cov_matrix_2d(sigma_uv, rho_uv));
   Omega ~ beta(2,2);
 
   // likelihood
diff --git a/posterior_database/models/stan/soil_incubation.stan b/posterior_database/models/stan/soil_incubation.stan
index 82fa8c05..54695769 100644
--- a/posterior_database/models/stan/soil_incubation.stan
+++ b/posterior_database/models/stan/soil_incubation.stan
@@ -90,8 +90,8 @@ functions {
     theta[3] = alpha21;
     theta[4] = alpha12;
 
-    C_hat = integrate_ode(two_pool_feedback,
-                           C_t0, t0, ts, theta, x_r, x_i);
+    C_hat = integrate_ode_rk45(two_pool_feedback,
+                               C_t0, t0, ts, theta, x_r, x_i);
 
     for (t in 1:N_t)
       eCO2_hat[t] = totalC_t0 - sum(C_hat[t]);
@@ -109,10 +109,12 @@ data {
 
   real<lower=0> eCO2mean[N_t]; // measured cumulative evolved carbon
 }
+
 transformed data {
   real x_r[0];                 // no real data for ODE system
   int x_i[0];                  // no integer data for ODE system
 }
+
 parameters {
   real<lower=0> k1;            // pool 1 decomposition rate
   real<lower=0> k2;            // pool 2 decomposition rate
@@ -124,11 +126,13 @@ parameters {
 
   real<lower=0> sigma;         // observation std dev
 }
+
 transformed parameters {
   real eCO2_hat[N_t];
   eCO2_hat = evolved_CO2(N_t, t0, ts, gamma, totalC_t0,
                           k1, k2, alpha21, alpha12, x_r, x_i);
 }
+
 model {
   // priors
   gamma ~ beta(10,1);         // identifies pools
diff --git a/posterior_database/models/stan/state_space_stochastic_level_stochastic_seasonal.stan b/posterior_database/models/stan/state_space_stochastic_level_stochastic_seasonal.stan
new file mode 100644
index 00000000..fee26b70
--- /dev/null
+++ b/posterior_database/models/stan/state_space_stochastic_level_stochastic_seasonal.stan
@@ -0,0 +1,30 @@
+// stochastic level and seasonal fig07_02.stan
+data {
+  int<lower=1> n;
+  vector[n] y;
+  vector[n] x;
+  vector[n] w;
+}
+parameters {
+  vector<lower=mean(y)-3*sd(y), upper=mean(y)+3*sd(y)>[n] mu;
+  vector[n] seasonal;
+  real beta;
+  real lambda;
+
+  positive_ordered[3] sigma;
+}
+transformed parameters {
+  vector[n] yhat;
+  yhat = mu + beta * x + lambda * w;
+}
+model {
+  for(t in 12:n)
+    seasonal[t] ~ normal(- sum(seasonal[t-11:t-1]), sigma[1]);
+
+  for(t in 2:n)
+    mu[t] ~ normal(mu[t-1], sigma[2]);
+
+  y ~ normal(yhat + seasonal, sigma[3]);
+  
+  sigma ~ student_t(4, 0, 1);
+}
diff --git a/posterior_database/posteriors/GLMM_Poisson_data-GLMM_Poisson_model.json b/posterior_database/posteriors/GLMM_Poisson_data-GLMM_Poisson_model.json
new file mode 100644
index 00000000..20587915
--- /dev/null
+++ b/posterior_database/posteriors/GLMM_Poisson_data-GLMM_Poisson_model.json
@@ -0,0 +1,21 @@
+{
+  "keywords": ["GLMM_Poisson", "Population"],
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.06",
+  "references": "kery2011population",
+  "dimensions": {
+    "alpha": 1,
+    "beta_1": 1,
+    "beta_2": 1,
+    "beta_3": 1,
+    "eps": 40,
+    "sigma": 1,
+    "log_lambda": 40,
+    "lambda": 40
+  },
+  "reference_posterior_name": null,
+  "added_date": "2021-06-29",
+  "added_by": "Kane Lindsay",
+  "name": "GLMM_Poisson_data-GLMM_Poisson_model",
+  "model_name": "GLMM_Poisson_model",
+  "data_name": "GLMM_Poisson_data"
+}
diff --git a/posterior_database/posteriors/GLMM_data-GLMM1_model.json b/posterior_database/posteriors/GLMM_data-GLMM1_model.json
new file mode 100644
index 00000000..6034e942
--- /dev/null
+++ b/posterior_database/posteriors/GLMM_data-GLMM1_model.json
@@ -0,0 +1,18 @@
+{
+  "keywords": "GLMM",
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.06",
+  "references": "kery2011population",
+  "dimensions": {
+    "alpha": 235,
+    "mu_alpha": 1,
+    "sd_alpha": 1,
+    "log_lambda": 2115,
+    "mis": 43
+  },
+  "reference_posterior_name": null,
+  "added_date": "2021-06-25",
+  "added_by": "Kane Lindsay",
+  "name": "GLMM_data-GLMM1_model",
+  "model_name": "GLMM1_model",
+  "data_name": "GLMM_data"
+}
diff --git a/posterior_database/posteriors/GLM_Binomial_data-GLM_Binomial_model.json b/posterior_database/posteriors/GLM_Binomial_data-GLM_Binomial_model.json
new file mode 100644
index 00000000..f70e57d9
--- /dev/null
+++ b/posterior_database/posteriors/GLM_Binomial_data-GLM_Binomial_model.json
@@ -0,0 +1,18 @@
+{
+  "keywords": ["GLM_Binomial", "Success", "Peregrine"],
+  "urls": "https://github.com/stan-dev/example-models/tree/master/BPA/Ch.03",
+  "references": "kery2011population",
+  "dimensions": {
+    "alpha": 1,
+    "beta1": 1,
+    "beta2": 1,
+    "logit_p": 40,
+    "p": 40
+  },
+  "reference_posterior_name": null,
+  "added_date": "2021-07-01",
+  "added_by": "Kane Lindsay",
+  "name": "GLM_Binomial_data-GLM_Binomial_model",
+  "model_name": "GLM_Binomial_model",
+  "data_name": "GLM_Binomial_data"
+}
diff --git a/posterior_database/posteriors/GLM_Poisson_Data-GLM_Poisson_model.json b/posterior_database/posteriors/GLM_Poisson_Data-GLM_Poisson_model.json
new file mode 100644
index 00000000..ba2ec27d
--- /dev/null
+++ b/posterior_database/posteriors/GLM_Poisson_Data-GLM_Poisson_model.json
@@ -0,0 +1,19 @@
+{
+  "keywords": ["GLM_Poisson", "Population"],
+  "urls": "https://github.com/stan-dev/example-models/tree/master/BPA/Ch.03",
+  "references": "kery2011population",
+  "dimensions": {
+    "alpha": 1,
+    "beta1": 1,
+    "beta2": 1,
+    "beta3": 1,
+    "log_lambda": 40,
+    "lambda": 40
+  },
+  "reference_posterior_name": null,
+  "added_date": "2021-07-01",
+  "added_by": "Kane Lindsay",
+  "name": "GLM_Poisson_Data-GLM_Poisson_model",
+  "model_name": "GLM_Poisson_model",
+  "data_name": "GLM_Poisson_Data"
+}
diff --git a/posterior_database/posteriors/M0_data-M0_model.json b/posterior_database/posteriors/M0_data-M0_model.json
new file mode 100644
index 00000000..4c2a6680
--- /dev/null
+++ b/posterior_database/posteriors/M0_data-M0_model.json
@@ -0,0 +1,17 @@
+{
+  "keywords": ["M0", "Constant Detection Probability", "Population"],
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.06",
+  "references": "kery2011population",
+  "dimensions": {
+    "omega": 1,
+    "p": 1,
+    "omega_nd": 1,
+    "N": 1
+  },
+  "reference_posterior_name": null,
+  "added_date": "2021-06-24",
+  "added_by": "Kane Lindsay",
+  "name": "M0_data-M0_model",
+  "model_name": "M0_model",
+  "data_name": "M0_data"
+}
diff --git a/posterior_database/posteriors/Mb_data-Mb_model.json b/posterior_database/posteriors/Mb_data-Mb_model.json
new file mode 100644
index 00000000..10bff101
--- /dev/null
+++ b/posterior_database/posteriors/Mb_data-Mb_model.json
@@ -0,0 +1,20 @@
+{
+  "keywords": ["Mb", "Trap-Response", "BPA"],
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.06",
+  "references": "kery2011population",
+  "dimensions": {
+    "omega": 1,
+    "p": 1,
+    "c": 1,
+    "p_eff": 1590,
+    "omega_nd": 1,
+    "N": 1,
+    "trap_response": 1
+  },
+  "reference_posterior_name": null,
+  "added_date": "2021-06-25",
+  "added_by": "Kane Lindsay",
+  "name": "Mb_data-Mb_model",
+  "model_name": "Mb_model",
+  "data_name": "Mb_data"
+}
diff --git a/posterior_database/posteriors/Mh_data-Mh_model.json b/posterior_database/posteriors/Mh_data-Mh_model.json
new file mode 100644
index 00000000..beb766ed
--- /dev/null
+++ b/posterior_database/posteriors/Mh_data-Mh_model.json
@@ -0,0 +1,20 @@
+{
+  "keywords": ["Mh", "heterogeneity model", "Logistic-Normal", "Logistic", "Normal"],
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.06",
+  "references": "kery2011population",
+  "dimensions": {
+    "omega": 1,
+    "mean_p": 1,
+    "sigma": 1,
+    "eps_raw": 385,
+    "eps": 385,
+    "z": 385,
+    "N": 1
+  },
+  "reference_posterior_name": null,
+  "added_date": "2021-06-25",
+  "added_by": "Kane Lindsay",
+  "name": "Mh_data-Mh_model",
+  "model_name": "Mh_model",
+  "data_name": "Mh_data"
+}
diff --git a/posterior_database/posteriors/Mt_data-Mt_model.json b/posterior_database/posteriors/Mt_data-Mt_model.json
new file mode 100644
index 00000000..24161795
--- /dev/null
+++ b/posterior_database/posteriors/Mt_data-Mt_model.json
@@ -0,0 +1,18 @@
+{
+  "keywords": ["Mt", "occasion", "Capture-Recapture"],
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.06",
+  "references": "kery2011population",
+  "dimensions": {
+    "omega": 1,
+    "p": 3,
+    "pr": 1,
+    "omega_nd": 1,
+    "N": 1
+  },
+  "reference_posterior_name": null,
+  "added_date": "2021-06-25",
+  "added_by": "Kane Lindsay",
+  "name": "Mt_data-Mt_model",
+  "model_name": "Mt_model",
+  "data_name": "Mt_data"
+}
diff --git a/posterior_database/posteriors/Mtbh_data-Mtbh_model.json b/posterior_database/posteriors/Mtbh_data-Mtbh_model.json
new file mode 100644
index 00000000..b3d5de2b
--- /dev/null
+++ b/posterior_database/posteriors/Mtbh_data-Mtbh_model.json
@@ -0,0 +1,24 @@
+{
+  "keywords": ["Mtbh", "occasion", "heterogeneity", "behaviour", "Capture-Recapture", "population"],
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.06",
+  "references": "kery2011population",
+  "dimensions": {
+    "omega": 1,
+    "mean_p": 5,
+    "gamma": 1,
+    "sigma": 1,
+    "eps_raw": 146,
+    "eps": 146,
+    "alpha": 5,
+    "logit_p": 730,
+    "p": 730,
+    "z": 146,
+    "N": 1
+  },
+  "reference_posterior_name": null,
+  "added_date": "2021-06-25",
+  "added_by": "Kane Lindsay",
+  "name": "Mtbh_data-Mtbh_model",
+  "model_name": "Mtbh_model",
+  "data_name": "Mtbh_data"
+}
diff --git a/posterior_database/posteriors/Mth_data-Mth_model.json b/posterior_database/posteriors/Mth_data-Mth_model.json
new file mode 100644
index 00000000..70bcb573
--- /dev/null
+++ b/posterior_database/posteriors/Mth_data-Mth_model.json
@@ -0,0 +1,23 @@
+{
+  "keywords": ["Mth", "occasion", "heterogeneity", "Capture-Recapture"],
+  "urls": "https://github.com/stan-dev/example-models/blob/master/BPA/Ch.06",
+  "references": "kery2011population",
+  "dimensions": {
+    "omega": 1,
+    "mean_p": 5,
+    "sigma": 1,
+    "eps_raw": 387,
+    "eps": 387,
+    "mean_lp": 5,
+    "logit_p": 1935,
+    "p": 1935,
+    "z": 387,
+    "N": 1
+  },
+  "reference_posterior_name": null,
+  "added_date": "2021-06-25",
+  "added_by": "Kane Lindsay",
+  "name": "Mth_data-Mth_model",
+  "model_name": "Mth_model",
+  "data_name": "Mth_data"
+}
diff --git a/posterior_database/posteriors/Rate_1_data-Rate_1_model.json b/posterior_database/posteriors/Rate_1_data-Rate_1_model.json
new file mode 100644
index 00000000..0cc23441
--- /dev/null
+++ b/posterior_database/posteriors/Rate_1_data-Rate_1_model.json
@@ -0,0 +1,14 @@
+{
+  "keywords": "Correct Answer Rate",
+  "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/GettingStarted",
+  "references": "lee2013cognitive",
+  "dimensions": {
+    "theta": 1
+  },
+  "reference_posterior_name": null,
+  "added_date": "2021-06-30",
+  "added_by": "Kane Lindsay",
+  "name": "Rate_1_data-Rate_1_model",
+  "model_name": "Rate_1_model",
+  "data_name": "Rate_1_data"
+}
diff --git a/posterior_database/posteriors/Rate_2_data-Rate_2_model.json b/posterior_database/posteriors/Rate_2_data-Rate_2_model.json
new file mode 100644
index 00000000..e85ac786
--- /dev/null
+++ b/posterior_database/posteriors/Rate_2_data-Rate_2_model.json
@@ -0,0 +1,16 @@
+{
+  "keywords": ["Success Rate", "Difference"],
+  "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/ParameterEstimation/Binomial",
+  "references": "lee2013cognitive",
+  "dimensions": {
+    "theta1": 1,
+    "theta2": 1,
+    "delta": 1
+  },
+  "reference_posterior_name": null,
+  "added_date": "2021-06-30",
+  "added_by": "Kane Lindsay",
+  "name": "Rate_2_data-Rate_2_model",
+  "model_name": "Rate_2_model",
+  "data_name": "Rate_2_data"
+}
diff --git a/posterior_database/posteriors/Rate_3_data-Rate_3_model.json b/posterior_database/posteriors/Rate_3_data-Rate_3_model.json
new file mode 100644
index 00000000..68d4c5df
--- /dev/null
+++ b/posterior_database/posteriors/Rate_3_data-Rate_3_model.json
@@ -0,0 +1,14 @@
+{
+  "keywords": ["Success Rate", "Common Rate"],
+  "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/ParameterEstimation/Binomial",
+  "references": "lee2013cognitive",
+  "dimensions": {
+    "theta": 1
+  },
+  "reference_posterior_name": null,
+  "added_date": "2021-06-30",
+  "added_by": "Kane Lindsay",
+  "name": "Rate_3_data-Rate_3_model",
+  "model_name": "Rate_3_model",
+  "data_name": "Rate_3_data"
+}
diff --git a/posterior_database/posteriors/Rate_4_data-Rate_4_model.json b/posterior_database/posteriors/Rate_4_data-Rate_4_model.json
new file mode 100644
index 00000000..f44221bc
--- /dev/null
+++ b/posterior_database/posteriors/Rate_4_data-Rate_4_model.json
@@ -0,0 +1,17 @@
+{
+  "keywords": ["Success Rate", "Prior Inference", "Posterior Inference"],
+  "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/ParameterEstimation/Binomial",
+  "references": "lee2013cognitive",
+  "dimensions": {
+    "theta": 1,
+    "thetaprior": 1,
+    "postpredk": 1,
+    "priorpredk": 1
+  },
+  "reference_posterior_name": null,
+  "added_date": "2021-06-30",
+  "added_by": "Kane Lindsay",
+  "name": "Rate_4_data-Rate_4_model",
+  "model_name": "Rate_4_model",
+  "data_name": "Rate_4_data"
+}
diff --git a/posterior_database/posteriors/Rate_5_data-Rate_5_model.json b/posterior_database/posteriors/Rate_5_data-Rate_5_model.json
new file mode 100644
index 00000000..02d7f318
--- /dev/null
+++ b/posterior_database/posteriors/Rate_5_data-Rate_5_model.json
@@ -0,0 +1,16 @@
+{
+  "keywords": ["Rate_5", "Success Rate", "Common Rate"],
+  "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/ParameterEstimation/Binomial",
+  "references": "lee2013cognitive",
+  "dimensions": {
+    "theta": 1,
+    "postpredk1": 1,
+    "postpredk2": 1
+  },
+  "reference_posterior_name": null,
+  "added_date": "2021-06-30",
+  "added_by": "Kane Lindsay",
+  "name": "Rate_5_data-Rate_5_model",
+  "model_name": "Rate_5_model",
+  "data_name": "Rate_5_data"
+}
diff --git a/posterior_database/posteriors/Survey_data-Survey_model.json b/posterior_database/posteriors/Survey_data-Survey_model.json
new file mode 100644
index 00000000..3166fb2a
--- /dev/null
+++ b/posterior_database/posteriors/Survey_data-Survey_model.json
@@ -0,0 +1,17 @@
+{
+  "keywords": ["Survey", "Return Rate", "Joint"],
+  "urls": "https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling/ParameterEstimation/Binomial",
+  "references": "lee2013cognitive",
+  "dimensions": {
+    "theta": 1,
+    "lp_parts": 500,
+    "n": 1,
+    "prob_n": 500
+  },
+  "reference_posterior_name": null,
+  "added_date": "2021-06-30",
+  "added_by": "Kane Lindsay",
+  "name": "Survey_data-Survey_model",
+  "model_name": "Survey_model",
+  "data_name": "Survey_data"
+}
diff --git a/posterior_database/posteriors/bball_drive_event_0-hmm_drive_0.json b/posterior_database/posteriors/bball_drive_event_0-hmm_drive_0.json
index 5becddb7..7d868512 100644
--- a/posterior_database/posteriors/bball_drive_event_0-hmm_drive_0.json
+++ b/posterior_database/posteriors/bball_drive_event_0-hmm_drive_0.json
@@ -5,7 +5,6 @@
   "model_name": "hmm_drive_0",
   "data_name": "bball_drive_event_0",
   "reference_posterior_name": "bball_drive_event_0-hmm_drive_0",
-  "references": "",
   "dimensions": {
     "theta1": 2,
     "theta2": 2,
diff --git a/posterior_database/posteriors/bball_drive_event_1-hmm_drive_1.json b/posterior_database/posteriors/bball_drive_event_1-hmm_drive_1.json
index fd3eddd0..208f6738 100644
--- a/posterior_database/posteriors/bball_drive_event_1-hmm_drive_1.json
+++ b/posterior_database/posteriors/bball_drive_event_1-hmm_drive_1.json
@@ -5,7 +5,7 @@
   "model_name": "hmm_drive_1",
   "data_name": "bball_drive_event_1",
   "reference_posterior_name": "bball_drive_event_1-hmm_drive_1",
-  "references": "",
+  "references": null,
   "dimensions": {
     "theta1": 2,
     "theta2": 2,
diff --git a/posterior_database/posteriors/fims_Aus_Jpn_irt-2pl_latent_reg_irt.json b/posterior_database/posteriors/fims_Aus_Jpn_irt-2pl_latent_reg_irt.json
new file mode 100644
index 00000000..1c331bec
--- /dev/null
+++ b/posterior_database/posteriors/fims_Aus_Jpn_irt-2pl_latent_reg_irt.json
@@ -0,0 +1,14 @@
+{
+  "name": "fims_Aus_Jpn_irt-2pl_latent_reg_irt",
+  "model_name": "2pl_latent_reg_irt",
+  "data_name": "fims_Aus_Jpn_irt",
+  "reference_posterior_name": null,
+  "dimensions": {
+    "alpha": 14,
+    "beta_free": 13,
+    "theta": 500,
+    "lambda_adj": 4
+  },
+  "added_by": "Mans Magnusson",
+  "added_date": "2021-09-08"
+}
diff --git a/posterior_database/posteriors/hmm_example-hmm_example.json b/posterior_database/posteriors/hmm_example-hmm_example.json
index e758d6c3..f16da89b 100644
--- a/posterior_database/posteriors/hmm_example-hmm_example.json
+++ b/posterior_database/posteriors/hmm_example-hmm_example.json
@@ -5,7 +5,7 @@
   "model_name": "hmm_example",
   "data_name": "hmm_example",
   "reference_posterior_name": "hmm_example-hmm_example",
-  "references": "",
+  "references": null,
   "dimensions": {
     "theta1": 2,
     "theta2": 2,
diff --git a/posterior_database/posteriors/hmm_gaussian_simulated-hmm_gaussian.json b/posterior_database/posteriors/hmm_gaussian_simulated-hmm_gaussian.json
new file mode 100644
index 00000000..bac90058
--- /dev/null
+++ b/posterior_database/posteriors/hmm_gaussian_simulated-hmm_gaussian.json
@@ -0,0 +1,14 @@
+{
+  "name": "hmm_gaussian_simulated-hmm_gaussian",
+  "model_name": "hmm_gaussian",
+  "data_name": "hmm_gaussian_simulated",
+  "reference_posterior_name": null,
+  "dimensions": {
+    "pi1": 2,
+    "A": [3, 2],
+    "mu": 3,
+    "sigma": 3
+  },
+  "added_by": "Mans Magnusson",
+  "added_date": "2021-09-08"
+}
diff --git a/posterior_database/posteriors/iohmm_reg_simulated-iohmm_reg.json b/posterior_database/posteriors/iohmm_reg_simulated-iohmm_reg.json
new file mode 100644
index 00000000..4bc205fc
--- /dev/null
+++ b/posterior_database/posteriors/iohmm_reg_simulated-iohmm_reg.json
@@ -0,0 +1,14 @@
+{
+  "name": "iohmm_reg_simulated-iohmm_reg",
+  "model_name": "iohmm_reg",
+  "data_name": "iohmm_reg_simulated",
+  "reference_posterior_name": null,
+  "dimensions": {
+    "pi1": 2,
+    "w": [3, 4],
+    "b": [3, 4],
+    "sigma": 3
+  },
+  "added_by": "Mans Magnusson",
+  "added_date": "2021-09-08"
+}
diff --git a/posterior_database/posteriors/loss_curves-losscurve_sislob.json b/posterior_database/posteriors/loss_curves-losscurve_sislob.json
new file mode 100644
index 00000000..3272434a
--- /dev/null
+++ b/posterior_database/posteriors/loss_curves-losscurve_sislob.json
@@ -0,0 +1,16 @@
+{
+  "name": "loss_curves-losscurve_sislob",
+  "model_name": "losscurve_sislob",
+  "data_name": "loss_curves",
+  "reference_posterior_name": null,
+  "dimensions": {
+    "omega": 1,
+    "theta": 1,
+    "LR": 10,
+    "mu_LR": 1,
+    "sd_LR": 1,
+    "loss_sd": 1
+  },
+  "added_by": "Mans Magnusson",
+  "added_date": "2021-09-08"
+}
diff --git a/posterior_database/posteriors/low_dim_gauss_mix_collapse.json b/posterior_database/posteriors/low_dim_gauss_mix_collapse.json
deleted file mode 100644
index a7b47d7f..00000000
--- a/posterior_database/posteriors/low_dim_gauss_mix_collapse.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-  "name": "low_dim_gauss_mix_collapse-low_dim_gauss_mix_collapse",
-  "keywords": [
-    "stan_benchmark"
-  ],
-  "urls": [],
-  "model_name": "low_dim_gauss_mix_collapse",
-  "data_name": "low_dim_gauss_mix_collapse",
-  "reference_posterior_name": null,
-  "references": [],
-  "dimensions": {
-    "mu": 2,
-    "sigma": 2,
-    "theta": 1
-  },
-  "added_date": "2019-11-20",
-  "added_by": "Mans Magnusson"
-}
diff --git a/posterior_database/posteriors/normal_2-normal_mixture.json b/posterior_database/posteriors/normal_2-normal_mixture.json
index d383ec4a..0d504aba 100644
--- a/posterior_database/posteriors/normal_2-normal_mixture.json
+++ b/posterior_database/posteriors/normal_2-normal_mixture.json
@@ -5,7 +5,7 @@
   "model_name": "normal_mixture",
   "data_name": "normal_2",
   "reference_posterior_name": null,
-  "references": "",
+  "references": null,
   "dimensions": {
     "theta": 1,
     "mu": 2
diff --git a/posterior_database/posteriors/normal_5-normal_mixture_k.json b/posterior_database/posteriors/normal_5-normal_mixture_k.json
index 21ff275b..82b99c23 100644
--- a/posterior_database/posteriors/normal_5-normal_mixture_k.json
+++ b/posterior_database/posteriors/normal_5-normal_mixture_k.json
@@ -5,7 +5,7 @@
   "model_name": "normal_mixture_k",
   "data_name": "normal_5",
   "reference_posterior_name": null,
-  "references": "",
+  "references": null,
   "dimensions": {
     "theta": 5,
     "mu": 5,
diff --git a/posterior_database/posteriors/prideprejustice_chapter-ldaK5.json b/posterior_database/posteriors/prideprejudice_chapter-ldaK5.json
similarity index 59%
rename from posterior_database/posteriors/prideprejustice_chapter-ldaK5.json
rename to posterior_database/posteriors/prideprejudice_chapter-ldaK5.json
index e0cc6b94..fe0bb09e 100644
--- a/posterior_database/posteriors/prideprejustice_chapter-ldaK5.json
+++ b/posterior_database/posteriors/prideprejudice_chapter-ldaK5.json
@@ -1,11 +1,9 @@
 {
-  "name": "prideprejustice_chapter-ldaK5",
-  "keywords": [
-    "multimodal"
-  ],
+  "name": "prideprejudice_chapter-ldaK5",
+  "keywords": "multimodal",
   "model_name": "ldaK5",
   "reference_posterior_name": null,
-  "data_name": "prideprejustice_chapter",
+  "data_name": "prideprejudice_chapter",
   "dimensions": {
     "theta": 244,
     "phi": 7470
diff --git a/posterior_database/posteriors/prideprejustice_paragraph-ldaK5.json b/posterior_database/posteriors/prideprejudice_paragraph-ldaK5.json
similarity index 59%
rename from posterior_database/posteriors/prideprejustice_paragraph-ldaK5.json
rename to posterior_database/posteriors/prideprejudice_paragraph-ldaK5.json
index 6d748420..55bc3438 100644
--- a/posterior_database/posteriors/prideprejustice_paragraph-ldaK5.json
+++ b/posterior_database/posteriors/prideprejudice_paragraph-ldaK5.json
@@ -1,11 +1,9 @@
 {
-  "name": "prideprejustice_paragraph-ldaK5",
-  "keywords": [
-    "multimodal"
-  ],
+  "name": "prideprejudice_paragraph-ldaK5",
+  "keywords": "multimodal",
   "model_name": "ldaK5",
   "reference_posterior_name": null,
-  "data_name": "prideprejustice_paragraph",
+  "data_name": "prideprejudice_paragraph",
   "dimensions": {
     "theta": 8100,
     "phi": 7470
diff --git a/posterior_database/posteriors/science_irt-grsm_latent_reg_irt.json b/posterior_database/posteriors/science_irt-grsm_latent_reg_irt.json
new file mode 100644
index 00000000..2f116e25
--- /dev/null
+++ b/posterior_database/posteriors/science_irt-grsm_latent_reg_irt.json
@@ -0,0 +1,15 @@
+{
+  "name": "science_irt-grsm_latent_reg_irt",
+  "model_name": "grsm_latent_reg_irt",
+  "data_name": "science_irt",
+  "reference_posterior_name": null,
+  "dimensions": {
+    "alpha": 7,
+    "beta_free": 6,
+    "kappa_free": 2,
+    "theta": 392,
+    "lambda_adj": 1
+  },
+  "added_by": "Mans Magnusson",
+  "added_date": "2021-09-08"
+}
diff --git a/posterior_database/posteriors/state_wide_presidential_votes-hierarchical_gp.json b/posterior_database/posteriors/state_wide_presidential_votes-hierarchical_gp.json
new file mode 100644
index 00000000..189e0b10
--- /dev/null
+++ b/posterior_database/posteriors/state_wide_presidential_votes-hierarchical_gp.json
@@ -0,0 +1,22 @@
+{
+  "name": "state_wide_presidential_votes-hierarchical_gp",
+  "model_name": "hierarchical_gp",
+  "data_name": "state_wide_presidential_votes",
+  "reference_posterior_name": null,
+  "dimensions": {
+    "GP_region_std": [14, 10],
+    "GP_state_std": [14, 50],
+    "year_std": 11,
+    "state_std": 50,
+    "region_std": 10,
+    "tot_var": 1,
+    "prop_var": 16,
+    "mu": 1,
+    "length_GP_region_long": 1,
+    "length_GP_state_long": 1,
+    "length_GP_region_short": 1,
+    "length_GP_state_short": 1
+  },
+  "added_by": "Mans Magnusson",
+  "added_date": "2021-09-08"
+}
diff --git a/posterior_database/posteriors/synthetic_grid_RBF_kernels-kronecker_gp.json b/posterior_database/posteriors/synthetic_grid_RBF_kernels-kronecker_gp.json
new file mode 100644
index 00000000..9e2c553e
--- /dev/null
+++ b/posterior_database/posteriors/synthetic_grid_RBF_kernels-kronecker_gp.json
@@ -0,0 +1,14 @@
+{
+  "name": "synthetic_grid_RBF_kernels-kronecker_gp",
+  "model_name": "kronecker_gp",
+  "data_name": "synthetic_grid_RBF_kernels",
+  "reference_posterior_name": null,
+  "dimensions": {
+    "var1": 1,
+    "bw1": 1,
+    "L": 435,
+    "sigma1": 1
+  },
+  "added_by": "Mans Magnusson",
+  "added_date": "2021-09-08"
+}
diff --git a/posterior_database/posteriors/timssAusTwn_irt-gpcm_latent_reg_irt.json b/posterior_database/posteriors/timssAusTwn_irt-gpcm_latent_reg_irt.json
new file mode 100644
index 00000000..6c3dde58
--- /dev/null
+++ b/posterior_database/posteriors/timssAusTwn_irt-gpcm_latent_reg_irt.json
@@ -0,0 +1,14 @@
+{
+  "name": "timssAusTwn_irt-gpcm_latent_reg_irt",
+  "model_name": "gpcm_latent_reg_irt",
+  "data_name": "timssAusTwn_irt",
+  "reference_posterior_name": null,
+  "dimensions": {
+    "alpha": 11,
+    "beta_free": 14,
+    "theta": 500,
+    "lambda_adj": 5
+  },
+  "added_by": "Mans Magnusson",
+  "added_date": "2021-09-08"
+}
diff --git a/posterior_database/posteriors/traffic_accident_nyc-bym2_offset_only.json b/posterior_database/posteriors/traffic_accident_nyc-bym2_offset_only.json
new file mode 100644
index 00000000..519d8f43
--- /dev/null
+++ b/posterior_database/posteriors/traffic_accident_nyc-bym2_offset_only.json
@@ -0,0 +1,15 @@
+{
+  "name": "traffic_accident_nyc-bym2_offset_only",
+  "model_name": "bym2_offset_only",
+  "data_name": "traffic_accident_nyc",
+  "reference_posterior_name": null,
+  "dimensions": {
+    "beta0": 1,
+    "sigma": 1,
+    "rho": 1,
+    "theta": 1921,
+    "phi": 1921
+  },
+  "added_by": "Mans Magnusson",
+  "added_date": "2021-09-08"
+}
diff --git a/posterior_database/posteriors/uk_drivers-state_space_stochastic_level_stochastic_seasonal.json b/posterior_database/posteriors/uk_drivers-state_space_stochastic_level_stochastic_seasonal.json
new file mode 100644
index 00000000..cd0d196e
--- /dev/null
+++ b/posterior_database/posteriors/uk_drivers-state_space_stochastic_level_stochastic_seasonal.json
@@ -0,0 +1,15 @@
+{
+  "name": "uk_drivers-state_space_stochastic_level_stochastic_seasonal",
+  "model_name": "state_space_stochastic_level_stochastic_seasonal",
+  "data_name": "uk_drivers",
+  "reference_posterior_name": null,
+  "dimensions": {
+    "mu": 192,
+    "seasonal": 192,
+    "beta": 1,
+    "lambda": 1,
+    "sigma": 3
+  },
+  "added_by": "Mans Magnusson",
+  "added_date": "2021-09-08"
+}
diff --git a/python/.coveragerc b/python/.coveragerc
deleted file mode 100644
index 6608a233..00000000
--- a/python/.coveragerc
+++ /dev/null
@@ -1,6 +0,0 @@
-[report]
-show_missing = True
-exclude_lines =
-    \#\s*pragma: no cover
-    ^\s*raise NotImplementedError\b
-    ^\s*return NotImplemented\b
diff --git a/python/.gitignore b/python/.gitignore
deleted file mode 100644
index 6cdaa0aa..00000000
--- a/python/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.env
-__pycache__
-*.egg-info
-.tox
-.mypy_cache
diff --git a/python/LICENSE b/python/LICENSE
deleted file mode 100644
index f288702d..00000000
--- a/python/LICENSE
+++ /dev/null
@@ -1,674 +0,0 @@
-                    GNU GENERAL PUBLIC LICENSE
-                       Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-                            Preamble
-
-  The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
-  The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works.  By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users.  We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors.  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
-  To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights.  Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received.  You must make sure that they, too, receive
-or can get the source code.  And you must show them these terms so they
-know their rights.
-
-  Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
-  For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software.  For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
-  Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so.  This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software.  The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable.  Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products.  If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
-  Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary.  To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-
-                       TERMS AND CONDITIONS
-
-  0. Definitions.
-
-  "This License" refers to version 3 of the GNU General Public License.
-
-  "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
-  "The Program" refers to any copyrightable work licensed under this
-License.  Each licensee is addressed as "you".  "Licensees" and
-"recipients" may be individuals or organizations.
-
-  To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy.  The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
-  A "covered work" means either the unmodified Program or a work based
-on the Program.
-
-  To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy.  Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
-  To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies.  Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
-  An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License.  If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
-  1. Source Code.
-
-  The "source code" for a work means the preferred form of the work
-for making modifications to it.  "Object code" means any non-source
-form of a work.
-
-  A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
-  The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form.  A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
-  The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities.  However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work.  For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
-  The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
-  The Corresponding Source for a work in source code form is that
-same work.
-
-  2. Basic Permissions.
-
-  All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met.  This License explicitly affirms your unlimited
-permission to run the unmodified Program.  The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work.  This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
-  You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force.  You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright.  Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
-  Conveying under any other circumstances is permitted solely under
-the conditions stated below.  Sublicensing is not allowed; section 10
-makes it unnecessary.
-
-  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
-  No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
-  When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
-  4. Conveying Verbatim Copies.
-
-  You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
-  You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
-  5. Conveying Modified Source Versions.
-
-  You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
-    a) The work must carry prominent notices stating that you modified
-    it, and giving a relevant date.
-
-    b) The work must carry prominent notices stating that it is
-    released under this License and any conditions added under section
-    7.  This requirement modifies the requirement in section 4 to
-    "keep intact all notices".
-
-    c) You must license the entire work, as a whole, under this
-    License to anyone who comes into possession of a copy.  This
-    License will therefore apply, along with any applicable section 7
-    additional terms, to the whole of the work, and all its parts,
-    regardless of how they are packaged.  This License gives no
-    permission to license the work in any other way, but it does not
-    invalidate such permission if you have separately received it.
-
-    d) If the work has interactive user interfaces, each must display
-    Appropriate Legal Notices; however, if the Program has interactive
-    interfaces that do not display Appropriate Legal Notices, your
-    work need not make them do so.
-
-  A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit.  Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
-  6. Conveying Non-Source Forms.
-
-  You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
-    a) Convey the object code in, or embodied in, a physical product
-    (including a physical distribution medium), accompanied by the
-    Corresponding Source fixed on a durable physical medium
-    customarily used for software interchange.
-
-    b) Convey the object code in, or embodied in, a physical product
-    (including a physical distribution medium), accompanied by a
-    written offer, valid for at least three years and valid for as
-    long as you offer spare parts or customer support for that product
-    model, to give anyone who possesses the object code either (1) a
-    copy of the Corresponding Source for all the software in the
-    product that is covered by this License, on a durable physical
-    medium customarily used for software interchange, for a price no
-    more than your reasonable cost of physically performing this
-    conveying of source, or (2) access to copy the
-    Corresponding Source from a network server at no charge.
-
-    c) Convey individual copies of the object code with a copy of the
-    written offer to provide the Corresponding Source.  This
-    alternative is allowed only occasionally and noncommercially, and
-    only if you received the object code with such an offer, in accord
-    with subsection 6b.
-
-    d) Convey the object code by offering access from a designated
-    place (gratis or for a charge), and offer equivalent access to the
-    Corresponding Source in the same way through the same place at no
-    further charge.  You need not require recipients to copy the
-    Corresponding Source along with the object code.  If the place to
-    copy the object code is a network server, the Corresponding Source
-    may be on a different server (operated by you or a third party)
-    that supports equivalent copying facilities, provided you maintain
-    clear directions next to the object code saying where to find the
-    Corresponding Source.  Regardless of what server hosts the
-    Corresponding Source, you remain obligated to ensure that it is
-    available for as long as needed to satisfy these requirements.
-
-    e) Convey the object code using peer-to-peer transmission, provided
-    you inform other peers where the object code and Corresponding
-    Source of the work are being offered to the general public at no
-    charge under subsection 6d.
-
-  A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
-  A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling.  In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage.  For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product.  A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
-  "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source.  The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
-  If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information.  But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
-  The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed.  Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
-  Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
-  7. Additional Terms.
-
-  "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law.  If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
-  When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it.  (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.)  You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
-  Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
-    a) Disclaiming warranty or limiting liability differently from the
-    terms of sections 15 and 16 of this License; or
-
-    b) Requiring preservation of specified reasonable legal notices or
-    author attributions in that material or in the Appropriate Legal
-    Notices displayed by works containing it; or
-
-    c) Prohibiting misrepresentation of the origin of that material, or
-    requiring that modified versions of such material be marked in
-    reasonable ways as different from the original version; or
-
-    d) Limiting the use for publicity purposes of names of licensors or
-    authors of the material; or
-
-    e) Declining to grant rights under trademark law for use of some
-    trade names, trademarks, or service marks; or
-
-    f) Requiring indemnification of licensors and authors of that
-    material by anyone who conveys the material (or modified versions of
-    it) with contractual assumptions of liability to the recipient, for
-    any liability that these contractual assumptions directly impose on
-    those licensors and authors.
-
-  All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10.  If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term.  If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
-  If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
-  Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
-  8. Termination.
-
-  You may not propagate or modify a covered work except as expressly
-provided under this License.  Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
-  However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
-  Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
-  Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License.  If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
-  9. Acceptance Not Required for Having Copies.
-
-  You are not required to accept this License in order to receive or
-run a copy of the Program.  Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance.  However,
-nothing other than this License grants you permission to propagate or
-modify any covered work.  These actions infringe copyright if you do
-not accept this License.  Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
-  10. Automatic Licensing of Downstream Recipients.
-
-  Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License.  You are not responsible
-for enforcing compliance by third parties with this License.
-
-  An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations.  If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
-  You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License.  For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
-  11. Patents.
-
-  A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based.  The
-work thus licensed is called the contributor's "contributor version".
-
-  A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version.  For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
-  Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
-  In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement).  To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
-  If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients.  "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
-  If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
-  A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License.  You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
-  Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
-  12. No Surrender of Others' Freedom.
-
-  If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all.  For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
-  13. Use with the GNU Affero General Public License.
-
-  Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work.  The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
-  14. Revised Versions of this License.
-
-  The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-  Each version is given a distinguishing version number.  If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation.  If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
-  If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
-  Later license versions may give you additional or different
-permissions.  However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
-  15. Disclaimer of Warranty.
-
-  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. Limitation of Liability.
-
-  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
-  17. Interpretation of Sections 15 and 16.
-
-  If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
-                     END OF TERMS AND CONDITIONS
-
-            How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This program is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <https://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
-  If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
-    <program>  Copyright (C) <year>  <name of author>
-    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
-  You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<https://www.gnu.org/licenses/>.
-
-  The GNU General Public License does not permit incorporating your program
-into proprietary programs.  If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library.  If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.  But first, please read
-<https://www.gnu.org/licenses/why-not-lgpl.html>.
diff --git a/python/MANIFEST.in b/python/MANIFEST.in
deleted file mode 100644
index 7d43f806..00000000
--- a/python/MANIFEST.in
+++ /dev/null
@@ -1,2 +0,0 @@
-include *.md
-include LICENSE
diff --git a/python/README.md b/python/README.md
deleted file mode 100644
index 818d2c6a..00000000
--- a/python/README.md
+++ /dev/null
@@ -1,211 +0,0 @@
-## Python versions
-
-Currently only python 3.6+ is supported. Python 3.5+ support can be added if needed. We don't plan to support python 2.
-
-## Installation
-
-Installation from PyPI is recommended.
-
-```bash
-pip install posteriordb
-```
-
-Installing from the local clone.
-
-```bash
-git clone https://github.com/MansMeg/posteriordb
-cd posteriordb
-pip install python/
-```
-
-## Using the posterior database from python
-
-The included database contains convenience functions to access data, model code and information for individual posteriors.
-
-First we create the posterior database to use, here the cloned posterior database.
-
-```python
->>> from posteriordb import PosteriorDatabase
->>> import os
->>> pdb_path = os.path.join(os.getcwd(), "posterior_database")
->>> my_pdb = PosteriorDatabase(pdb_path)
-```
-The above code requires that your working directory is in the main folder of your copy
-of this project. Alternatively, you can specify the path to the folder directly.
-
-Online database can be used with the `PosteriorDatabaseGithub` class. Remember to create and set `GITHUB_PAT` environmental variable.
-It's recommended that users create a read-only (no extra permissions) [GitHub Personal Access Token (PAT)](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) for `posteriordb` use. It's also recommended that the
-`GITHUB_PAT` environmental variable is added to user environmental variables and it is not shown in Python script as in the example below.
-
-
-If not explicitly defined, `PosteriorDatabase` and `PosteriorDatabaseGithub` will create a new (or use old database) located at `POSTERIOR_DB_PATH` if it's
-defined. `PosteriorDatabaseGithub` will finally use `$HOME/.posteriordb/posterior_database` as a fallback location if no environmental variables have been set.
-Each model and data is only downloaded and cached when needed.
-
-```python
->>> from posteriordb import PosteriorDatabaseGithub
->>> import os
->>> # It is recommended that GITHUB_PAT is added to the user environmental variables
->>> # outside python and not in a python script as shown in this example code
->>> os.environ["GITHUB_PAT"] = "token-string-here"
->>> my_pdb = PosteriorDatabaseGithub()
-```
-
-To list the posteriors available, use `posterior_names`.
-
-```python
->>> pos = my_pdb.posterior_names()
->>> pos[:5]
-
-['roaches-roaches_negbin',
- 'syn_gmK2D1n200-gmm_diagonal_nonordered',
- 'radon_mn-radon_variable_intercept_centered',
- 'syn_gmK3D2n300-gmm_nonordered',
- 'radon-radon_hierarchical_intercept_centered']
-
-```
-
-In the same fashion, we can list data and models included in the database as
-
-```python
->>> mn = my_pdb.model_names()
->>> mn[:5]
-
-['gmm_diagonal_nonordered',
- 'radon_pool',
- 'radon_partial_pool_noncentered',
- 'blr',
- 'radon_hierarchical_intercept_noncentered']
-
-
->>> dn = my_pdb.dataset_names()
->>> dn[:5]
-
-['radon_mn',
- 'wells_centered',
- 'radon',
- 'wells_centered_educ4_interact',
- 'wells_centered_educ4']
-
-
-```
-
-The posterior's name is made up of the data and model fitted
-to the data. Together, these two uniquely define a posterior distribution.
-To access a posterior object we can use the posterior name.
-
-```python
->>> posterior = my_pdb.posterior("eight_schools-eight_schools_centered")
-```
-
-From the posterior we can access the dataset and the model
-
-```python
->>> model = posterior.model
->>> data = posterior.data
-```
-
-We can also access the names of posteriors, models and datasets.
-
-```python
->>> posterior.name
-"eight_schools-eight_schools_centered"
-
->>> model.name
-"eight_schools_centered"
-
->>> data.name
-"eight_schools"
-
-```
-
-We can access the same model and dataset also directly from the posterior database
-```python
->>> model = my_pdb.model("eight_schools_centered")
->>> data = my_pdb.data("eight_schools")
-```
-
-From the model we can access model code and information about the model
-
-```python
->>> model.code("stan")
-data {
-  int <lower=0> J; // number of schools
-  real y[J]; // estimated treatment
-  real<lower=0> sigma[J]; // std of estimated effect
-}
-parameters {
-  real theta[J]; // treatment effect in school j
-  real mu; // hyper-parameter of mean
-  real<lower=0> tau; // hyper-parameter of sdv
-}
-model {
-  tau ~ cauchy(0, 5); // a non-informative prior
-  theta ~ normal(mu, tau);
-  y ~ normal(theta , sigma);
-  mu ~ normal(0, 5);
-}
-
->>> model.code_file_path("stan")
-'/home/eero/posterior_database/content/models/stan/eight_schools_centered.stan'
-
->>> model.information
-{'keywords': ['bda3_example', 'hiearchical'],
- 'description': 'A centered hiearchical model for the 8 schools example of Rubin (1981)',
- 'urls': ['http://www.stat.columbia.edu/~gelman/arm/examples/schools'],
- 'title': 'A centered hiearchical model for 8 schools',
- 'references': ['rubin1981estimation', 'gelman2013bayesian'],
- 'added_by': 'Mans Magnusson',
- 'added_date': '2019-08-12'}
-```
-Note that the references are referencing to BibTeX items that can be found in `content/references/references.bib`.
-
-From the dataset we can access the data values and information about it
-
-```python
->>> data.values()
-{'J': 8,
- 'y': [28, 8, -3, 7, -1, 1, 18, 12],
- 'sigma': [15, 10, 16, 11, 9, 11, 10, 18]}
-
->>> data.file_path()
-'/tmp/tmpx16edu0w'
-
->>> data.information
-{'keywords': ['bda3_example'],
- 'description': 'A study for the Educational Testing Service to analyze the effects of\nspecial coaching programs on test scores. See Gelman et. al. (2014), Section 5.5 for details.',
- 'urls': ['http://www.stat.columbia.edu/~gelman/arm/examples/schools'],
- 'title': 'The 8 schools dataset of Rubin (1981)',
- 'references': ['rubin1981estimation', 'gelman2013bayesian'],
- 'added_by': 'Mans Magnusson',
- 'added_date': '2019-08-12'}
-```
-
-To access gold standard posterior draws we can use `reference_draws` as follows.
-
-```python
->>> posterior.reference_draws_info()
-{'name': 'eight_schools-eight_schools_noncentered',
- 'inference': {'method': 'stan_sampling',
-  'method_arguments': {'chains': 10,
-   'iter': 20000,
-   'warmup': 10000,
-   'thin': 10,
-   'seed': 4711,
-   'control': {'adapt_delta': 0.95}}},
- 'diagnostics': {'diagnostic_information': {'names': ['mu',
-    'tau',
-    'theta[1]',
-    ...
-
->>> gs = posterior.reference_draws()
->>> import pandas as pd
->>> pd.DataFrame(gs)
-
-	theta[1]	                                        theta[2]
-0	[10.6802773011458, 6.45383910854259, -2.241629...	[9.71770681295263, 4.41030824418493, 0.7617047...
-1	[5.70891361633589, 10.3012059848039, 4.2439533...	[-2.32310565394337, 14.8121789773659, 6.517256...
-2	[7.23747096507585, -0.427831558524343, 9.14782...	[7.35425759420389, 8.69579738064637, 8.9058764...
-3	[4.44915522912766, 2.34711393762556, 17.680378...	[2.4368039319606, 5.89809320808632, 8.63031558...
-...
-```
diff --git a/python/mypy.ini b/python/mypy.ini
deleted file mode 100644
index 976ba029..00000000
--- a/python/mypy.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[mypy]
-ignore_missing_imports = True
diff --git a/python/setup.py b/python/setup.py
deleted file mode 100644
index f2b48604..00000000
--- a/python/setup.py
+++ /dev/null
@@ -1,40 +0,0 @@
-import os
-import re
-from setuptools import setup
-
-PROJECT_ROOT = os.path.dirname(os.path.realpath(__file__))
-VERSION_FILE = os.path.join(PROJECT_ROOT, "src", "posteriordb", "__init__.py")
-README_FILE = os.path.join(PROJECT_ROOT, "README.md")
-
-
-def get_long_description():
-    with open(README_FILE, "rt") as buff:
-        return buff.read()
-
-
-def get_version():
-    lines = open(VERSION_FILE, "rt").readlines()
-    version_regex = r"^__version__ = ['\"]([^'\"]*)['\"]"
-    for line in lines:
-        mo = re.search(version_regex, line, re.M)
-        if mo:
-            return mo.group(1)
-    raise RuntimeError("Unable to find version in %s." % (VERSION_FILE,))
-
-
-setup(
-    name="posteriordb",
-    version=get_version(),
-    description="python interface to posterior database",
-    url="https://github.com/MansMeg/posteriordb",
-    author="Eero Linna",
-    author_email="eero.linna@aalto.fi",
-    license="GPL",
-    long_description=get_long_description(),
-    long_description_content_type="text/markdown",
-    packages=["posteriordb"],
-    package_dir={"": "src"},
-    install_requires=["requests"],
-    zip_safe=False,
-    include_package_data=True,
-)
diff --git a/python/src/posteriordb/__init__.py b/python/src/posteriordb/__init__.py
deleted file mode 100644
index 11d2526d..00000000
--- a/python/src/posteriordb/__init__.py
+++ /dev/null
@@ -1,4 +0,0 @@
-from .posterior_database import PosteriorDatabase
-from .posterior_database_github import PosteriorDatabaseGithub
-
-__version__ = "0.2.0"
diff --git a/python/src/posteriordb/dataset.py b/python/src/posteriordb/dataset.py
deleted file mode 100644
index 8aaeb0d0..00000000
--- a/python/src/posteriordb/dataset.py
+++ /dev/null
@@ -1,43 +0,0 @@
-import json
-import os
-import tempfile
-from typing import Union
-from zipfile import ZipFile
-
-from .posterior_database import PosteriorDatabase
-from .posterior_database_github import PosteriorDatabaseGithub
-from .util import drop_keys
-
-
-class Dataset:
-    def __init__(
-        self, name: str, posterior_db: Union[PosteriorDatabase, PosteriorDatabaseGithub]
-    ):
-        self.name = name
-        self.posterior_db = posterior_db
-        full_information = self.posterior_db.get_data_info(name=self.name)
-        self.information = drop_keys(full_information, "data_file")
-
-    def file_path(self):
-        data = self.values()
-        # make a temp file with unzipped data
-        with tempfile.NamedTemporaryFile(mode="w", delete=False) as f:
-            json.dump(data, f)
-            file_name = f.name
-        return file_name
-
-    def values(self):
-        # unzip the file on the fly
-        # return contents
-        path = self.posterior_db.get_dataset_path(self.name)
-        with ZipFile(path) as zipfile:
-            namelist = zipfile.namelist()
-            n_archives = len(namelist)
-            if n_archives != 1:
-                raise ValueError(
-                    f"Expected a zip archive that contains one file, {path} has {n_archives} files in it"
-                )
-            archive_file_name = namelist[0]
-            with zipfile.open(archive_file_name) as f:
-                data = json.load(f)
-        return data
diff --git a/python/src/posteriordb/model.py b/python/src/posteriordb/model.py
deleted file mode 100644
index 680fc256..00000000
--- a/python/src/posteriordb/model.py
+++ /dev/null
@@ -1,52 +0,0 @@
-import os
-from typing import Union
-
-from .posterior_database import PosteriorDatabase
-from .posterior_database_github import PosteriorDatabaseGithub
-from .pymc3_model_implementation import PyMC3ModelImplementation
-from .stan_model_implementation import StanModelImplementation
-from .util import drop_keys
-
-implementations = {"stan": StanModelImplementation, "pymc3": PyMC3ModelImplementation}
-
-
-class Model:
-    def __init__(
-        self, name: str, posterior_db: Union[PosteriorDatabase, PosteriorDatabaseGithub]
-    ):
-        self.name = name
-        self.posterior_db = posterior_db
-        full_model_info = self.posterior_db.get_model_info(name=self.name)
-        self.information = drop_keys(full_model_info, "model_implementations")
-        self._implementations = full_model_info["model_implementations"]
-
-    def code_file_path(self, framework: str):
-        """
-        Returns filepath to model code file for `framework`
-        """
-        # TODO assert that framework is a valid framework for this model
-        return self.posterior_db.get_model_code_path(self.name, framework)
-
-    def code(self, framework: str):
-        """
-        Returns model code for `framework` as a string
-        """
-        file_path = self.code_file_path(framework)
-        with open(file_path) as f:
-            contents = f.read()
-
-        return contents
-
-    def stan_code(self):
-        return self.code("stan")
-
-    def stan_code_file_path(self):
-        return self.code_file_path("stan")
-
-    def implementation(self, framework):
-        implementation_info = self._implementations[framework]
-        implementation_class = implementations[framework]
-        implementation_obj = implementation_class(
-            self.posterior_db, **implementation_info
-        )
-        return implementation_obj
diff --git a/python/src/posteriordb/model_implementation_base.py b/python/src/posteriordb/model_implementation_base.py
deleted file mode 100644
index d04c85ab..00000000
--- a/python/src/posteriordb/model_implementation_base.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from abc import ABC
-from abc import abstractmethod
-
-
-class ModelImplementationBase(ABC):
-    @abstractmethod
-    def load(self):
-        pass
diff --git a/python/src/posteriordb/posterior.py b/python/src/posteriordb/posterior.py
deleted file mode 100644
index 33d44f38..00000000
--- a/python/src/posteriordb/posterior.py
+++ /dev/null
@@ -1,43 +0,0 @@
-import json
-from typing import Union
-from zipfile import ZipFile
-
-from .dataset import Dataset
-from .model import Model
-from .posterior_database import PosteriorDatabase
-from .posterior_database_github import PosteriorDatabaseGithub
-from .util import drop_keys
-
-
-class Posterior:
-    def __init__(
-        self, name: str, posterior_db: Union[PosteriorDatabase, PosteriorDatabaseGithub]
-    ):
-        self.name = name
-
-        assert name in posterior_db.posterior_names()
-
-        self.posterior_db = posterior_db
-
-        self.posterior_info = posterior_db.get_posterior_info(name)
-
-        self.model = Model(self.posterior_info["model_name"], posterior_db)
-
-        self.data = Dataset(self.posterior_info["data_name"], posterior_db)
-
-        self.information = drop_keys(
-            self.posterior_info,
-            ["name", "model_name", "data_name", "reference_posterior_name"],
-        )
-
-    def reference_draws_info(self):
-        return self.posterior_db.get_reference_draws_info(self.name)
-
-    def reference_draws_file_path(self):
-        return self.posterior_db.get_reference_draws_path(self.name)
-
-    def reference_draws(self):
-        reference_name = self.reference_draws_info()["name"]
-        with ZipFile(self.reference_draws_file_path() + ".zip", "r") as z:
-            with z.open(reference_name + ".json", "r") as f:
-                return json.load(f)
diff --git a/python/src/posteriordb/posterior_database.py b/python/src/posteriordb/posterior_database.py
deleted file mode 100644
index 7340ca31..00000000
--- a/python/src/posteriordb/posterior_database.py
+++ /dev/null
@@ -1,146 +0,0 @@
-import json
-import os
-from pathlib import Path
-
-
-def load_json_file(filepath):
-    with open(filepath, encoding="utf-8") as f:
-        return json.load(f)
-
-
-def load_info(path, assertion_function):
-    info = load_json_file(path)
-    assertion_function(info)
-    return info
-
-
-def temporary_no_assertions(x):
-    return x
-
-
-def filename(path):
-    """Given a full file path return just the filename without extension """
-    # with_suffix is needed in case the file has multiple extensions
-    return path.with_suffix("").stem
-
-
-def filenames_in_dir_no_extension(directory, extension):
-    path = Path(directory)
-
-    filenames = [filename(p) for p in path.glob("*" + extension)]
-    return filenames
-
-
-class PosteriorDatabase:
-    def __init__(self, path: str = None):
-        if path is None:
-            path = os.environ.get("POSTERIOR_DB_PATH")
-        self.path = str(path)
-        # TODO assert that path is a valid posterior database
-
-    def full_path(self, path: str):
-        return os.path.join(self.path, path)
-
-    def posterior(self, name):
-        # inline import needed to avoid import loop
-        from .posterior import Posterior
-
-        return Posterior(name, self)
-
-    def model(self, name):
-        # inline import needed to avoid import loop
-        from .model import Model
-
-        return Model(name, self)
-
-    def data(self, name):
-        # inline import needed to avoid import loop
-        from .dataset import Dataset
-
-        return Dataset(name, self)
-
-    def posterior_info_path(self, name: str):
-        file_path = os.path.join(self.path, "posteriors", name + ".json")
-        return file_path
-
-    def get_posterior_info(self, name: str):
-        file_path = self.posterior_info_path(name)
-        return load_info(file_path, temporary_no_assertions)
-
-    def get_model_info(self, name: str):
-        # load from the correct path
-        file_name = name + ".info.json"
-        file_path = os.path.join(self.path, "models", "info", file_name)
-
-        return load_info(file_path, temporary_no_assertions)
-
-    def get_data_info(self, name: str):
-        file_name = name + ".info.json"
-        file_path = os.path.join(self.path, "data", "info", file_name)
-
-        return load_info(file_path, temporary_no_assertions)
-
-    def get_reference_draws_path(self, name: str):
-        reference_root = os.path.join(self.path, "reference_posteriors/draws/draws")
-        reference_name = self.get_posterior_info(name)["reference_posterior_name"]
-        assert reference_name is not None
-        file_path = os.path.join(reference_root, reference_name + ".json")
-        return file_path
-
-    def get_reference_draws_info(self, name: str):
-        reference_root = os.path.join(self.path, "reference_posteriors/draws/info")
-        reference_name = self.get_posterior_info(name)["reference_posterior_name"]
-        assert reference_name is not None
-        file_path = os.path.join(reference_root, reference_name + ".info.json")
-        return load_info(file_path, temporary_no_assertions)
-
-    def get_model_code_path(self, name, framework):
-        model_info = self.get_model_info(name)
-        path_within_posterior_db = model_info["model_implementations"][framework][
-            "model_code"
-        ]
-        full_path = os.path.join(self.path, path_within_posterior_db)
-        return full_path
-
-    def get_dataset_path(self, name):
-        data_info = self.get_data_info(name)
-        path = os.path.join(self.path, data_info["data_file"] + ".zip")
-        return path
-
-    def posterior_names(self):
-        directory = os.path.join(self.path, "posteriors")
-        # walk directory, find json files
-        # strip file extension
-        return filenames_in_dir_no_extension(directory, ".json")
-
-    def model_names(self):
-        directory = os.path.join(self.path, "models", "info")
-        return filenames_in_dir_no_extension(directory, ".info.json")
-
-    def dataset_names(self):
-        directory = os.path.join(self.path, "data", "info")
-        return filenames_in_dir_no_extension(directory, ".info.json")
-
-    def posteriors(self):
-        names = self.posterior_names()
-        # inline import needed to avoid import loop
-        from .posterior import Posterior
-
-        for name in names:
-            yield Posterior(name, self)
-
-    def models(self):
-        names = self.model_names()
-        # inline import needed to avoid import loop
-        from .model import Model
-
-        for name in names:
-            yield Model(name, self)
-
-    def datasets(self):
-        names = self.dataset_names()
-        # inline import needed to avoid import loop
-        from .dataset import Dataset
-
-        for name in names:
-            yield Dataset(name, self)
diff --git a/python/src/posteriordb/posterior_database_github.py b/python/src/posteriordb/posterior_database_github.py
deleted file mode 100644
index 8478be67..00000000
--- a/python/src/posteriordb/posterior_database_github.py
+++ /dev/null
@@ -1,362 +0,0 @@
-import hashlib
-import json
-import os
-import tempfile
-from pathlib import Path
-import requests
-
-
-def temporary_no_assertions(x):
-    return x
-
-
-def get_requests(*args, n=3, **kwargs):
-    for _ in range(n):
-        try:
-            response = requests.get(*args, **kwargs)
-            if response.ok:
-                break
-        except Exception as e:
-            print(e)
-            continue
-    else:
-        print("response:", response.json())
-        raise ValueError("response was not successful")
-    return response
-
-
-def github_pat():
-    GITHUB_PAT = os.environ.get("GITHUB_PAT")
-    headers = {}
-    if GITHUB_PAT is not None:
-        headers["Authorization"] = "token {}".format(GITHUB_PAT)
-    else:
-        print(
-            "GitHub access token was not defined (env GITHUB_PAT not defined), using limited API rate limit."
-        )
-    return headers
-
-
-def get_content(url, path=None, headers=None):
-    """Download contents assuming GitHub API v3"""
-
-    if headers is None:
-        headers = github_pat()
-    if path is not None:
-        path = Path(path)
-    verify = os.environ.get("REQUESTS_VERIFY", True)
-    if str(verify).lower() in ("0", "false"):
-        verify = False
-    verify = bool(verify)
-
-    response = get_requests(url, verify=verify, headers=headers)
-    contents = {}
-
-    for content in response.json():
-        try:
-            if content["type"] == "dir":
-                contents.update(
-                    get_content(content["_links"]["self"], path=path, headers=headers)
-                )
-            else:
-                if path:
-                    key = path / content["path"]
-                else:
-                    key = content["path"]
-                contents[key] = content
-        except Exception as e:
-            print("Invalid content:", content, "Exception was raised (and ignored):", e)
-            continue
-    return contents
-
-
-def download_file(url, path, overwrite=False, sha=None):
-    """Download file with a requests.
-
-    To manually disable requests verify
-    set environmental variable REQUESTS_VERIFY to false.
-    """
-    if (not overwrite) and path.exists():
-        return True
-    if overwrite and (sha is not None) and path.exists():
-        if sha == get_sha1_hash(path):
-            return True
-
-    verify = os.environ.get("REQUESTS_VERIFY", True)
-    if str(verify).lower() in ("0", "false"):
-        verify = False
-    verify = bool(verify)
-
-    headers = github_pat()
-    try:
-        response = get_requests(url, verify=verify, headers=headers)
-
-        path.parent.mkdir(parents=True, exist_ok=True)
-
-        with path.open(mode="wb") as f:
-            f.write(response.content)
-    except Exception as e:
-        print("Exception was raised (and ignored):", e)
-        return False
-    return True
-
-
-def get_sha1_hash(path):
-    sha1_hash = hashlib.sha1()
-    size = path.stat().st_size
-    with path.open("rb") as f:
-        sha1_hash.update(bytes("blob {}".format(size), encoding="utf-8") + b"\0")
-        for byte_block in iter(lambda: f.read(4096), b""):
-            sha1_hash.update(byte_block)
-    return sha1_hash.hexdigest()
-
-
-def load_json_file(path, metadata, overwrite=False):
-    if not path.exists():
-        if metadata is not None:
-            download_file(metadata["download_url"], path)
-        else:
-            raise TypeError("File was not found in GitHub")
-    elif overwrite:
-        if metadata is not None:
-            download_file(metadata["download_url"], path, sha=metadata["sha"])
-    with path.open(encoding="utf-8") as f:
-        data = json.load(f)
-    return data
-
-
-def load_info(path, assertion_function, metadata, overwrite=False):
-    info = load_json_file(path, metadata, overwrite=overwrite)
-    assertion_function(info)
-    return info
-
-
-def filenames_in_dir_no_extension(directory, gh_directory, extension):
-    path = Path(directory)
-
-    filenames = [p.with_suffix("").stem for p in path.glob("*" + extension)]
-    gh_filenames = [p.with_suffix("").stem for p in gh_directory]
-    return sorted(set(filenames + gh_filenames))
-
-
-class PosteriorDatabaseGithub:
-    def __init__(
-        self,
-        path: str = None,
-        repo="MansMeg/posteriordb",
-        ref="master",
-        refresh=True,
-        overwrite=False,
-    ):
-        if path is None:
-            path = os.environ.get("POSTERIOR_DB_PATH")
-            if path is None:
-                path = Path.home() / ".posteriordb" / "posterior_database"
-                path.mkdir(parents=True, exist_ok=True)
-        self.path = Path(path)
-
-        self.overwrite = overwrite
-        self._repo = repo
-        self._ref = ref
-
-        self.refresh_url()
-
-        self._progressbar_width = 30
-        self._progressbar_marker = b"\xe2\x96\xa0".decode("utf-8")
-
-        if refresh:
-            self.refresh_github()
-        else:
-            self._links = {}
-
-        # TODO assert that path is a valid posterior database
-
-    def refresh_url(self, repo=None, ref=None):
-        if repo is not None:
-            self._repo = repo
-        if ref is not None:
-            self._ref = ref
-
-        self._url = "https://api.github.com/repos/{repo}/contents/posterior_database?ref={ref}".format(
-            repo=self._repo, ref=self._ref
-        )
-
-    def refresh_github(self):
-        self._links = get_content(self._url, path=self.path.parent)
-
-    def download_all(self, refresh=False, overwrite=None, show_progress=True):
-        """Download all files for database."""
-        if refresh:
-            self.refresh_github()
-        if overwrite is None:
-            overwrite = self.overwrite
-        n = len(self._links)
-        for i, (path, metadata) in enumerate(self._links.items(), 1):
-            print(
-                "\rDownloading {:<30} ({}/{})".format(
-                    self._progressbar_marker * int(i / n * self._progressbar_width),
-                    i,
-                    n,
-                ),
-                end="",
-                flush=True,
-            )
-            download_file(
-                metadata["download_url"], path, overwrite=overwrite, sha=metadata["sha"]
-            )
-
-    def full_path(self, path: str):
-        return self.path / path
-
-    def posterior(self, name):
-        # inline import needed to avoid import loop
-        from .posterior import Posterior
-
-        return Posterior(name, self)
-
-    def model(self, name):
-        # inline import needed to avoid import loop
-        from .model import Model
-
-        return Model(name, self)
-
-    def data(self, name):
-        # inline import needed to avoid import loop
-        from .dataset import Dataset
-
-        return Dataset(name, self)
-
-    def posterior_info_path(self, name: str):
-        path = self.path / "posteriors" / (name + ".json")
-        return path
-
-    def get_posterior_info(self, name: str):
-        path = self.posterior_info_path(name)
-        return load_info(
-            path,
-            temporary_no_assertions,
-            self._links.get(path),
-            overwrite=self.overwrite,
-        )
-
-    def get_model_info(self, name: str):
-        # load from the correct path
-        file_name = name + ".info.json"
-        path = self.path / "models" / "info" / file_name
-
-        return load_info(
-            path,
-            temporary_no_assertions,
-            self._links.get(path),
-            overwrite=self.overwrite,
-        )
-
-    def get_data_info(self, name: str):
-        file_name = name + ".info.json"
-        path = self.path / "data" / "info" / file_name
-
-        return load_info(
-            path,
-            temporary_no_assertions,
-            self._links.get(path),
-            overwrite=self.overwrite,
-        )
-
-    def get_reference_draws_path(self, name: str):
-        reference_root = self.path / "reference_posteriors" / "draws" / "draws"
-        reference_name = self.get_posterior_info(name).get("reference_posterior_name")
-        assert reference_name is not None
-        path = reference_root / (reference_name + ".json")
-        return path
-
-    def get_reference_draws_info(self, name: str):
-        reference_root = self.path / "reference_posteriors" / "draws" / "info"
-        reference_name = self.get_posterior_info(name).get("reference_posterior_name")
-        assert reference_name is not None
-        path = reference_root / (reference_name + ".info.json")
-        return load_info(
-            path,
-            temporary_no_assertions,
-            self._links.get(path, None),
-            overwrite=self.overwrite,
-        )
-
-    def get_model_code_path(self, name, framework):
-        model_info = self.get_model_info(name)
-        path_within_posterior_db = model_info["model_implementations"][framework][
-            "model_code"
-        ]
-        path = self.path / path_within_posterior_db
-
-        # download model code
-        if not path.exists() or self.overwrite:
-            download_file(
-                self._links[path]["download_url"],
-                path,
-                overwrite=self.overwrite,
-                sha=self._links[path]["sha"],
-            )
-
-        return path
-
-    def get_dataset_path(self, name):
-        data_info = self.get_data_info(name)
-        path = self.path / (data_info["data_file"] + ".zip")
-
-        # download model code
-        if not path.exists() or self.overwrite:
-            download_file(
-                self._links[path]["download_url"],
-                path,
-                overwrite=self.overwrite,
-                sha=self._links[path]["sha"],
-            )
-
-        return path
-
-    def posterior_names(self):
-        directory = self.path / "posteriors"
-        # walk directory, find json files
-        # strip file extension
-        gh_directory = [
-            key for key in self._links if str(directory.resolve()) in str(key.resolve())
-        ]
-        return filenames_in_dir_no_extension(directory, gh_directory, ".json")
-
-    def model_names(self):
-        directory = self.path / "models" / "info"
-        gh_directory = [
-            key for key in self._links if str(directory.resolve()) in str(key.resolve())
-        ]
-        return filenames_in_dir_no_extension(directory, gh_directory, ".info.json")
-
-    def dataset_names(self):
-        directory = self.path / "data" / "info"
-        gh_directory = [
-            key for key in self._links if str(directory.resolve()) in str(key.resolve())
-        ]
-        return filenames_in_dir_no_extension(directory, gh_directory, ".info.json")
-
-    def posteriors(self):
-        names = self.posterior_names()
-        # inline import needed to avoid import loop
-        from .posterior import Posterior
-
-        for name in names:
-            yield Posterior(name, self)
-
-    def models(self):
-        names = self.model_names()
-        # inline import needed to avoid import loop
-        from .model import Model
-
-        for name in names:
-            yield Model(name, self)
-
-    def datasets(self):
-        names = self.dataset_names()
-        # inline import needed to avoid import loop
-        from .dataset import Dataset
-
-        for name in names:
-            yield Dataset(name, self)
diff --git a/python/src/posteriordb/pymc3_model_implementation.py b/python/src/posteriordb/pymc3_model_implementation.py
deleted file mode 100644
index 7f179344..00000000
--- a/python/src/posteriordb/pymc3_model_implementation.py
+++ /dev/null
@@ -1,41 +0,0 @@
-import os
-import sys
-
-from .model_implementation_base import ModelImplementationBase
-
-
-class add_path:
-    def __init__(self, path):
-        self.path = path
-
-    def __enter__(self):
-        sys.path.insert(0, self.path)
-
-    def __exit__(self, exc_type, exc_value, traceback):
-        try:
-            sys.path.remove(self.path)
-        except ValueError:
-            pass
-
-
-class PyMC3ModelImplementation(ModelImplementationBase):
-    def __init__(self, posterior_db, *, model_code):
-        self.posterior_db = posterior_db
-        self.model_code = model_code
-
-    def load(self):
-        try:
-            import pymc3
-        except ImportError:
-            raise ValueError("pymc3 needs to be installed")
-        import importlib
-
-        model_code_file = self.posterior_db.full_path(self.model_code)
-        model_code_directory = os.path.dirname(model_code_file)
-        with add_path(model_code_directory):
-            model_code_module_name, _ = os.path.splitext(
-                os.path.basename(model_code_file)
-            )
-            module = importlib.import_module(model_code_module_name)
-
-        return module.model
diff --git a/python/src/posteriordb/stan_model_implementation.py b/python/src/posteriordb/stan_model_implementation.py
deleted file mode 100644
index 86676022..00000000
--- a/python/src/posteriordb/stan_model_implementation.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from .model_implementation_base import ModelImplementationBase
-
-
-class StanModelImplementation(ModelImplementationBase):
-    def __init__(self, posterior_db, *, model_code):
-        self.posterior_db = posterior_db
-        self.model_code = model_code
-
-    def load(self):
-        try:
-            import pystan
-        except ImportError:
-            raise ValueError("`pystan` needs to be installed")
-        model_code_file = self.posterior_db.full_path(self.model_code)
-        stan_model = pystan.StanModel(file=model_code_file)
-        return stan_model
diff --git a/python/src/posteriordb/util.py b/python/src/posteriordb/util.py
deleted file mode 100644
index 4abd6a25..00000000
--- a/python/src/posteriordb/util.py
+++ /dev/null
@@ -1,7 +0,0 @@
-def drop_keys(dct, keys_to_drop):
-    if not isinstance(keys_to_drop, list):
-        keys_to_drop = [keys_to_drop]
-
-    new_dct = {k: v for (k, v) in dct.items() if k not in keys_to_drop}
-
-    return new_dct
diff --git a/python/tox.ini b/python/tox.ini
deleted file mode 100644
index b77f302b..00000000
--- a/python/tox.ini
+++ /dev/null
@@ -1,42 +0,0 @@
-# tox (https://tox.readthedocs.io/) is a tool for running tests
-# in multiple virtualenvs. This configuration file will run the
-# test suite on all supported python versions. To use it, "pip install tox"
-# and then run "tox" from this directory.
-
-[tox]
-envlist = py36, py37, py38, py39
-
-[testenv]
-deps =
-    pytest
-    pytest-cov
-commands =
-    pytest --cov=posteriordb --cov-append {posargs:-vv} --cov-report=term
-depends =
-    {py36, py37, py38, py39}: clean-coverage
-    report-coverage: py36, py37, py38, py39
-
-[testenv:clean-coverage]
-skip_install = true
-deps = coverage
-commands = coverage erase
-
-[testenv:report-coverage]
-skip_install = true
-deps = coverage
-commands =
-    coverage html
-    coverage report
-
-[testenv:linting]
-skip_install = True
-basepython = python3
-deps = pre-commit>=1.11.0
-commands = pre-commit run --all-files --show-diff-on-failure
-
-[gh-actions]
-python =
-    3.6: py36
-    3.7: py37
-    3.8: py38
-    3.9: py39
diff --git a/rpackage/.Rbuildignore b/rpackage/.Rbuildignore
deleted file mode 100644
index e6992356..00000000
--- a/rpackage/.Rbuildignore
+++ /dev/null
@@ -1,6 +0,0 @@
-^.*\.Rproj$
-^\.Rproj\.user$
-^data-raw$
-README.Rmd
-README.md
-^appveyor\.yml$
diff --git a/rpackage/DESCRIPTION b/rpackage/DESCRIPTION
deleted file mode 100644
index 33150860..00000000
--- a/rpackage/DESCRIPTION
+++ /dev/null
@@ -1,32 +0,0 @@
-Package: posteriordb
-Type: Package
-Title: The Posterior Database R functionality
-Version: 0.2.2
-Date: 2021-03-05
-Authors@R: c(person("Mans", "Magnusson", email = "mans.magnusson@gmail.com",
-                    role = c("cre", "aut")),
-             person("Paul-Christian", "Bürkner", email = "paul.buerkner@gmail.com",
-                    role = c("aut")))
-Maintainer: Mans Magnusson <mans.magnusson@gmail.com>
-Description: R functionality of easy access of different posteriors.
-License: BSD_3_clause + file LICENSE
-RoxygenNote: 7.1.1
-Encoding: UTF-8
-Depends:
-  R (>= 3.5.0)
-Imports:
-  checkmate,
-  jsonlite
-Suggests:
-    dplyr,
-    posterior,
-    httr,
-    gh,
-    git2r,
-    remotes,
-    rstan,
-    testthat,
-    bibtex,
-    digest,
-    yaml,
-    covr
diff --git a/rpackage/LICENSE b/rpackage/LICENSE
deleted file mode 100644
index 77d8533e..00000000
--- a/rpackage/LICENSE
+++ /dev/null
@@ -1,1 +0,0 @@
-Copyright (c) 2020 Stan Developers and their Assignees; Trustees of Columbia University; Måns Magnusson; Aki Vehtari;
diff --git a/rpackage/NAMESPACE b/rpackage/NAMESPACE
deleted file mode 100644
index 4456b9d1..00000000
--- a/rpackage/NAMESPACE
+++ /dev/null
@@ -1,162 +0,0 @@
-# Generated by roxygen2: do not edit by hand
-
-S3method("framework<-",character)
-S3method("framework<-",pdb_model_code)
-S3method(as.data.frame,pdb_posterior)
-S3method(as.data.frame,pdb_posteriors)
-S3method(assert_checked_reference_posterior_draws,pdb_reference_posterior_draws)
-S3method(assert_checked_reference_posterior_draws,pdb_reference_posterior_info)
-S3method(assert_checked_summary_statistics_draws,pdb_reference_posterior_draws)
-S3method(assert_checked_summary_statistics_draws,pdb_reference_posterior_info)
-S3method(assert_checked_summary_statistics_draws,pdb_reference_posterior_summary_statistic)
-S3method(check_reference_posterior_draws,character)
-S3method(check_reference_posterior_draws,pdb_posterior)
-S3method(check_reference_posterior_draws,pdb_reference_posterior_draws)
-S3method(check_summary_statistics_draws,character)
-S3method(check_summary_statistics_draws,pdb_posterior)
-S3method(check_summary_statistics_draws,pdb_reference_posterior_draws)
-S3method(data_file_path,character)
-S3method(data_file_path,pdb_data_info)
-S3method(data_file_path,pdb_posterior)
-S3method(data_info,character)
-S3method(data_info,list)
-S3method(data_info,pdb_posterior)
-S3method(data_names,pdb_github)
-S3method(data_names,pdb_local)
-S3method(framework,pdb_model_code)
-S3method(get_data,character)
-S3method(get_data,list)
-S3method(get_data,pdb_data_info)
-S3method(get_data,pdb_posterior)
-S3method(model_code,character)
-S3method(model_code,pdb_model_info)
-S3method(model_code,pdb_posterior)
-S3method(model_code,stanmodel)
-S3method(model_code_file_path,character)
-S3method(model_code_file_path,pdb_model_info)
-S3method(model_code_file_path,pdb_posterior)
-S3method(model_info,character)
-S3method(model_info,list)
-S3method(model_info,pdb_posterior)
-S3method(model_names,pdb_github)
-S3method(model_names,pdb_local)
-S3method(pdb,character)
-S3method(pdb,default)
-S3method(pdb,pdb_model_code)
-S3method(pdb_cache_rm,pdb_data)
-S3method(pdb_cache_rm,pdb_reference_posterior_draws)
-S3method(pdb_version,pdb_github)
-S3method(pdb_version,pdb_local)
-S3method(posterior,character)
-S3method(posterior,list)
-S3method(print,pdb)
-S3method(print,pdb_data)
-S3method(print,pdb_data_info)
-S3method(print,pdb_github)
-S3method(print,pdb_model_code)
-S3method(print,pdb_model_info)
-S3method(print,pdb_posterior)
-S3method(print,pdb_reference_posterior_draws)
-S3method(print,pdb_reference_posterior_info)
-S3method(print,pdb_reference_posterior_summary_statistic)
-S3method(reference_posterior_draws,character)
-S3method(reference_posterior_draws,draws_list)
-S3method(reference_posterior_draws,pdb_posterior)
-S3method(reference_posterior_draws,pdb_reference_posterior_info)
-S3method(reference_posterior_draws,stanfit)
-S3method(reference_posterior_draws_file_path,character)
-S3method(reference_posterior_draws_file_path,pdb_posterior)
-S3method(reference_posterior_draws_file_path,pdb_reference_posterior_info)
-S3method(reference_posterior_info,character)
-S3method(reference_posterior_info,list)
-S3method(reference_posterior_info,pdb_posterior)
-S3method(reference_posterior_names,pdb_github)
-S3method(reference_posterior_names,pdb_local)
-S3method(reference_posterior_summary_statistic,character)
-S3method(reference_posterior_summary_statistic,list)
-S3method(reference_posterior_summary_statistic,pdb_posterior)
-S3method(reference_posterior_summary_statistic,pdb_reference_posterior_info)
-S3method(reference_posterior_summary_statistics,character)
-S3method(reference_posterior_summary_statistics,pdb_posterior)
-S3method(remove_pdb,character)
-S3method(remove_pdb,pdb_data)
-S3method(remove_pdb,pdb_data_info)
-S3method(remove_pdb,pdb_model_code)
-S3method(remove_pdb,pdb_model_info)
-S3method(remove_pdb,pdb_posterior)
-S3method(remove_pdb,pdb_reference_posterior_draws)
-S3method(remove_pdb,pdb_reference_posterior_info)
-S3method(remove_pdb,pdb_reference_posterior_summary_statistic)
-S3method(subset,pdb_reference_posterior_draws)
-S3method(summary,pdb_reference_posterior_draws)
-S3method(write_pdb,pdb_data)
-S3method(write_pdb,pdb_data_info)
-S3method(write_pdb,pdb_model_code)
-S3method(write_pdb,pdb_model_info)
-S3method(write_pdb,pdb_posterior)
-S3method(write_pdb,pdb_reference_posterior_draws)
-S3method(write_pdb,pdb_reference_posterior_info)
-S3method(write_pdb,pdb_reference_posterior_summary_statistic)
-S3method(write_pdb,stanmodel)
-export("framework<-")
-export(alias_names)
-export(assert_checked_reference_posterior_draws)
-export(assert_checked_summary_statistics_draws)
-export(assert_reference_posterior_draws)
-export(bibliography)
-export(check_pdb_posterior)
-export(check_reference_posterior_draws)
-export(check_summary_statistics_draws)
-export(compute_reference_posterior_draws)
-export(compute_reference_posterior_summary_statistic)
-export(compute_summary_statistic)
-export(data_file_path)
-export(data_info)
-export(data_names)
-export(filter_posteriors)
-export(framework)
-export(get_data)
-export(github_pat)
-export(github_ref)
-export(info)
-export(model_code)
-export(model_code_file_path)
-export(model_info)
-export(model_names)
-export(pdb)
-export(pdb_bibliography)
-export(pdb_config)
-export(pdb_data)
-export(pdb_data_info)
-export(pdb_default)
-export(pdb_github)
-export(pdb_local)
-export(pdb_model_code)
-export(pdb_model_info)
-export(pdb_posterior)
-export(pdb_reference_posterior_draws)
-export(pdb_reference_posterior_draws_info)
-export(pdb_reference_posterior_info)
-export(pdb_reference_posterior_summary_statistic)
-export(pdb_reference_posterior_summary_statistics)
-export(pdb_stan_code)
-export(pdb_version)
-export(posterior)
-export(posterior_name)
-export(posterior_names)
-export(posteriors_tbl_df)
-export(reference_posterior_draws)
-export(reference_posterior_draws_file_path)
-export(reference_posterior_draws_info)
-export(reference_posterior_info)
-export(reference_posterior_names)
-export(reference_posterior_summary_statistic)
-export(reference_posterior_summary_statistics)
-export(remove_pdb)
-export(stan_code)
-export(stan_code_file_path)
-export(stan_data)
-export(stan_data_file_path)
-export(thin_draws.pdb_reference_posterior_draws)
-export(write_pdb)
-importFrom(utils,unzip)
diff --git a/rpackage/R/aliases.R b/rpackage/R/aliases.R
deleted file mode 100644
index f3230122..00000000
--- a/rpackage/R/aliases.R
+++ /dev/null
@@ -1,45 +0,0 @@
-#' Get all existing alias names from a posterior database
-#'
-#' @param pdb a \code{pdb} object.
-#' @param type type of alias names. Cureently only posteriors.
-#'
-#' @export
-alias_names <- function(type, pdb = pdb_default()){
-  names(pdb_aliases(type, pdb))
-}
-
-#' Extract aliases list from posterior database
-#'
-#' @inheritParams alias_names
-#'
-pdb_aliases <- function(type, pdb){
-  checkmate::assert_choice(type, supported_alias_types())
-  a <- read_json_from_pdb(paste0(type, ".json"), path = "alias", pdb)
-  class(a) <- c(paste0("pdb_",type,"_aliases"), paste0("pdb_aliases"))
-  assert_pdb_aliases(a)
-  a
-}
-
-#' Return the name that the alias points to
-#'
-#' @inheritParams alias_names
-#' @param x a name to lookup in alias list
-#'
-handle_aliases <- function(x, type, pdb){
-  checkmate::assert_string(x)
-  checkmate::assert_choice(type, supported_alias_types())
-  checkmate::assert_class(pdb, "pdb")
-
-  a <- pdb_aliases(type, pdb)
-  nm <- a[[x]]
-  if(is.null(nm)) nm <- x
-
-  return(nm)
-}
-
-assert_pdb_aliases <- function(x){
-  checkmate::assert_class(x, "pdb_aliases")
-  checkmate::assert_named(x)
-}
-
-supported_alias_types <- function() c("posteriors")
diff --git a/rpackage/R/assert_checked_draws.R b/rpackage/R/assert_checked_draws.R
deleted file mode 100644
index 0b58ad98..00000000
--- a/rpackage/R/assert_checked_draws.R
+++ /dev/null
@@ -1,63 +0,0 @@
-#' Assert that all checks of the reference posterior draws
-#' are true
-#'
-#' @details
-#' This functionasserts that the reference posterior draws comply
-#' with the criterias of the reference posterior draws.
-#'
-#' See \url{https://github.com/stan-dev/posteriordb/blob/master/doc/REFERENCE_POSTERIOR_DEFINITION.md} for details.
-#'
-#' @param x a [pdb_reference_posterior_draws] object
-#'
-#' @export
-assert_checked_reference_posterior_draws <- function(x){
-  UseMethod("assert_checked_reference_posterior_draws")
-}
-
-#' @rdname assert_checked_reference_posterior_draws
-#' @export
-assert_checked_reference_posterior_draws.pdb_reference_posterior_draws <- function(x){
-  rpi <- info(x)
-  assert_checked_reference_posterior_draws(rpi)
-}
-
-#' @rdname assert_checked_reference_posterior_draws
-#' @export
-assert_checked_reference_posterior_draws.pdb_reference_posterior_info <- function(x){
-  checkmate::assert_true(x$checks_made$ndraws_is_10k)
-  checkmate::assert_true(x$checks_made$nchains_is_gte_4)
-  checkmate::assert_true(x$checks_made$ess_within_bounds)
-  checkmate::assert_true(x$checks_made$r_hat_below_1_01)
-  checkmate::assert_true(x$checks_made$efmi_above_0_2)
-}
-
-
-#' @rdname assert_checked_reference_posterior_draws
-#' @export
-assert_checked_summary_statistics_draws <- function(x){
-  UseMethod("assert_checked_summary_statistics_draws")
-}
-
-#' @rdname assert_checked_reference_posterior_draws
-#' @export
-assert_checked_summary_statistics_draws.pdb_reference_posterior_draws <- function(x){
-  rpi <- info(x)
-  assert_checked_summary_statistics_draws(rpi)
-}
-
-#' @rdname assert_checked_reference_posterior_draws
-#' @export
-assert_checked_summary_statistics_draws.pdb_reference_posterior_summary_statistic <- function(x){
-  rpi <- info(x)
-  assert_checked_summary_statistics_draws(rpi)
-}
-
-#' @rdname assert_checked_reference_posterior_draws
-#' @export
-assert_checked_summary_statistics_draws.pdb_reference_posterior_info <- function(x){
-  checkmate::assert_true(x$checks_made$ndraws_is_gte_10k)
-  checkmate::assert_true(x$checks_made$nchains_is_gte_4)
-  checkmate::assert_true(x$checks_made$ess_within_bounds)
-  checkmate::assert_true(x$checks_made$r_hat_below_1_01)
-  checkmate::assert_true(x$checks_made$efmi_above_0_2)
-}
diff --git a/rpackage/R/bibliography.R b/rpackage/R/bibliography.R
deleted file mode 100644
index 131e04f3..00000000
--- a/rpackage/R/bibliography.R
+++ /dev/null
@@ -1,16 +0,0 @@
-#' Get the bibliography of a posterior database
-#'
-#' @param pdb a posterior database connection
-#' @param ... further arguments passed to [bibtex::read.bib]
-#'
-#' @export
-bibliography <- function(pdb, ...){
-  checkmate::assert_class(pdb, "pdb")
-  fp <- file.path("bibliography/references.bib")
-  pfn <- pdb_cached_local_file_path(pdb, path = fp)
-  bibtex::read.bib(pfn, ...)
-}
-
-#' @rdname bibliography
-#' @export
-pdb_bibliography <- bibliography
diff --git a/rpackage/R/check_pdb.R b/rpackage/R/check_pdb.R
deleted file mode 100644
index 3fc3aa29..00000000
--- a/rpackage/R/check_pdb.R
+++ /dev/null
@@ -1,260 +0,0 @@
-#' Check the content a posterior database
-#'
-#' @param pdb a \code{pdb} object
-#' @param posterior_idx an index vector indicating what posteriors to check.
-#' @param posterior_list a list of \code{pdb_posterior} objects.
-#' @param po a \code{pdb_posterior} object.
-#'
-#' @details
-#' [check_pdb()] checks that the content exists as specified
-#' [check_pdb_run_stan()] test to run all posteriors with stan models.
-#' [check_pdb_stan_syntax()] check that all stan model code files can be parsed.
-#' [check_pdb_read_posteriors()] check that posteriors can be read.
-#' [check_pdb_aliases()] check that all alias are correct.
-#' [check_pdb_read_model_code()] check that posteriors can be read.
-#' [check_pdb_posteriors()] check a vector of posterior names.
-#' [check_pdb_references()] check that all references in posteriors also exist in bibtex.
-#' [check_pdb_all_models_have_posterior()] check that all models belong to a posterior
-#' [check_pdb_all_data_have_posterior()] check that all datasets belong to a posterior
-#' [check_pdb_all_reference_posteriors_have_posterior()] check that all reference posteriors belong to a posterior
-#'
-#' @return a boolean indicating if the pdb works as it should.
-#'
-check_pdb <- function(pdb, posterior_idx = NULL) {
-  checkmate::assert_class(pdb, "pdb")
-  checkmate::assert_integerish(posterior_idx, null.ok = TRUE)
-
-  message("Checking posterior database...")
-
-  pl <- check_pdb_read_posteriors(pdb, posterior_idx)
-  message("- All posteriors can be read.")
-
-  check_pdb_read_model_code(pl)
-  message("- All model_code can be read.")
-
-  check_pdb_read_data(pl)
-  message("- All data can be read.")
-
-  check_pdb_read_reference_posterior_draws(pl)
-  message("- All reference_posteriors_draws can be read.")
-
-  check_pdb_aliases(pdb)
-  message("- Aliases are ok.")
-
-  if(is.null(posterior_idx)){
-    suppressMessages(check_pdb_references(pdb))
-    message("- References and bibliography are ok.")
-
-    check_pdb_all_models_have_posterior(pdb)
-    check_pdb_all_data_have_posterior(pdb)
-    check_pdb_all_reference_posteriors_have_posterior(pdb)
-    message("- All data, models and reference posteriors are part of a posterior.")
-  }
-
-  message("\nPosterior database is ok.\n")
-  invisible(TRUE)
-}
-
-#' @rdname check_pdb
-check_pdb_read_posteriors <- function(pdb, posterior_idx = NULL){
-  checkmate::assert_class(pdb, "pdb")
-  checkmate::assert_integerish(posterior_idx, null.ok = TRUE)
-
-  pns <- posterior_names(pdb)
-  if(!is.null(posterior_idx)) pns <- pns[posterior_idx]
-  pl <- list()
-  for (i in seq_along(pns)) {
-    pl[[i]] <- posterior(pns[i], pdb = pdb)
-  }
-  return(invisible(pl))
-}
-
-#' @rdname check_pdb
-check_pdb_read_model_code <- function(posterior_list){
-  pl <- lapply(posterior_list, checkmate::assert_class, classes = "pdb_posterior")
-  for (i in seq_along(pl)) {
-    model_info(pl[[i]])
-    stan_code(pl[[i]])
-  }
-}
-
-#' @rdname check_pdb
-check_pdb_aliases <- function(pdb){
-  a <- pdb_aliases("posteriors", pdb)
-  checkmate::assert_character(names(a), unique = TRUE)
-  pn <- unname(unlist(a))
-  pdb_posterior_names <- posterior_names(pdb)
-  checkmate::assert_subset(pn, pdb_posterior_names)
-  checkmate::assert_true(all(!names(a) %in% pdb_posterior_names))
-}
-
-#' @rdname check_pdb
-check_pdb_read_data <- function(posterior_list){
-  pl <- lapply(posterior_list, checkmate::assert_class, classes = "pdb_posterior")
-  for (i in seq_along(pl)) {
-    data_info(x = pl[[i]])
-    sd <- stan_data(x = pl[[i]])
-    pdb_cache_rm(sd, pl$pdb[[i]])
-  }
-}
-
-#' @rdname check_pdb
-check_pdb_read_reference_posterior_draws <- function(posterior_list){
-  pl <- lapply(posterior_list, checkmate::assert_class, classes = "pdb_posterior")
-  for (i in seq_along(pl)) {
-    if(is.null(pl[[i]]$reference_posterior_name)) next
-    rp <- reference_posterior_draws(x = pl[[i]])
-    pdb_cache_rm(rp, pl$pdb[[i]])
-  }
-}
-
-#' @rdname check_pdb
-check_pdb_run_stan <- function(pdb, posterior_idx = NULL) {
-  checkmate::assert_class(pdb, "pdb")
-
-  message("Check that stan can be run for all models ...")
-  pns <- posterior_names(pdb)
-  if(!is.null(posterior_idx)) pns <- pns[posterior_idx]
-  pl <- list()
-  for (i in seq_along(pns)) {
-    pl[[i]] <- posterior(pns[i], pdb = pdb)
-  }
-
-  try_list <- list()
-  for(i in seq_along(pl)){
-    try_list[[i]] <- try(suppressWarnings(so <- utils::capture.output(run_stan(pl[[i]], stan_args = list(iter = 2, warmup = 1, chains = 1)))))
-    if(inherits(try_list[[i]], "try-error")){
-      message("'", pl[[i]]$name, "' cannot be run with stan.")
-    } else {
-      message("'", pl[[i]]$name, "' is working with stan.")
-    }
-  }
-  message("All posteriors with stan code can be run.")
-
-}
-
-#' @rdname check_pdb
-check_pdb_posterior_run_stan <- function(po) {
-  checkmate::assert_class(po, "pdb_posterior")
-  suppressWarnings(so <- utils::capture.output(run_stan(po, stan_args = list(iter = 2, warmup = 1, chains = 1))))
-  so
-}
-
-
-#' @rdname check_pdb
-check_pdb_stan_syntax <- function(pdb, posterior_idx = NULL) {
-  checkmate::assert_class(pdb, "pdb")
-
-  message("Checking stan syntax...")
-  pns <- posterior_names(pdb)
-  if(!is.null(posterior_idx)) pns <- pns[posterior_idx]
-  pl <- list()
-  for (i in seq_along(pns)) {
-    pl[[i]] <- posterior(pns[i], pdb = pdb)
-  }
-
-  for(i in seq_along(pl)){
-    check_posterior_stan_syntax(pl[[i]])
-  }
-  message("All posteriors with stan code has correct stan syntax.")
-}
-
-check_posterior_stan_syntax <- function(po) {
-  checkmate::assert_class(po, "pdb_posterior")
-  suppressWarnings(sp <- rstan::stanc(model_code = stan_code(po), model_name = po$model_name))
-  sp
-}
-
-
-#' @rdname check_pdb
-check_pdb_references <- function(pdb, posterior_idx = NULL) {
-  checkmate::assert_class(pdb, "pdb")
-
-  message("Checking references...")
-  pns <- posterior_names(pdb)
-  if(!is.null(posterior_idx)) pns <- pns[posterior_idx]
-  refs <- list()
-  for (i in seq_along(pns)) {
-    po <- posterior(pns[i], pdb = pdb)
-    refs[[length(refs) + 1]] <- po$references
-    refs[[length(refs) + 1]] <- model_info(po)$references
-    refs[[length(refs) + 1]] <- data_info(po)$references
-  }
-  refs <- unique(unlist(refs))
-  refs <- refs[nchar(refs) > 0]
-
-  bib <- bibliography(pdb)
-  bibnms <- names(bib)
-
-  ref_in_bib <- refs %in% bibnms
-  if(any(!ref_in_bib)){
-    stop("Reference '", refs[!ref_in_bib], "' exist in database but not in the bibliography.", call. = FALSE)
-  }
-
-  bib_in_ref <- bibnms %in% refs
-  if(any(!bib_in_ref)){
-    stop("Reference '", bibnms[!bib_in_ref], "' in bibliography but not in any posterior, data or model.", call. = FALSE)
-  }
-
-  message("All references are correct...")
-}
-
-#' @rdname check_pdb
-check_pdb_all_models_have_posterior <- function(pdb){
-  checkmate::assert_class(pdb, "pdb")
-  pn <- posterior_names(pdb)
-  mnp <- character(length(pn))
-  pl <- list()
-  for (i in seq_along(pn)) {
-    pl[[i]] <- posterior(pn[i], pdb = pdb)
-    mnp[i] <- model_info(pl[[i]])$name
-  }
-
-  mns <- model_names(pdb)
-
-  model_bool <- mns %in% mnp
-  if(!all(model_bool)){
-    stop("Model(s) " , paste0(mns[!model_bool], collapse = ", "), " is missing in posteriors.", call. = FALSE)
-  }
-}
-
-#' @rdname check_pdb
-check_pdb_all_data_have_posterior <- function(pdb){
-  checkmate::assert_class(pdb, "pdb")
-  pn <- posterior_names(pdb)
-  dnp <- character(length(pn))
-  pl <- list()
-  for (i in seq_along(pn)) {
-    pl[[i]] <- posterior(pn[i], pdb = pdb)
-    dnp[i] <- data_info(pl[[i]])$name
-  }
-  dns <- data_names(pdb)
-
-  data_bool <- dns %in% dnp
-  if(!all(data_bool)){
-    stop("Data " , paste0(dns[!data_bool], collapse = ", "), " is missing in posteriors.", call. = FALSE)
-  }
-
-}
-
-#' @rdname check_pdb
-check_pdb_all_reference_posteriors_have_posterior <- function(pdb){
-  checkmate::assert_class(pdb, "pdb")
-  pn <- posterior_names(pdb)
-  rpnp <- character(length(pn))
-  pl <- list()
-  for (i in seq_along(pn)) {
-    pl[[i]] <- posterior(pn[i], pdb = pdb)
-    tc <- try(rp <- reference_posterior_draws_info(pl[[i]]), silent = TRUE)
-    if(!inherits(tc, "try-error")){
-      rpnp[i] <- rp$name
-    }
-  }
-
-  rpns <- reference_posterior_names(pdb, "draws")
-
-  rp_bool <- rpns %in% rpnp
-  if(!all(rp_bool)){
-    stop("Reference posteriors " , paste0(rpns[!rp_bool], collapse = ", "), " is missing in posteriors.", call. = FALSE)
-  }
-}
diff --git a/rpackage/R/check_posterior.R b/rpackage/R/check_posterior.R
deleted file mode 100644
index 7d766513..00000000
--- a/rpackage/R/check_posterior.R
+++ /dev/null
@@ -1,44 +0,0 @@
-#' Test a posterior
-#'
-#' @details
-#' The function checks a posterior is consistent.
-#'
-#' @param po a [pdb_posterior] to check.
-#' @param run_stan_code_checks should checks using Rstan be run?
-#' @param verbose should check results be printed?
-#'
-#' @export
-check_pdb_posterior <- function(po, run_stan_code_checks = TRUE, verbose = TRUE) {
-  checkmate::assert_class(po, "pdb_posterior")
-
-  if(verbose) message("Checking posterior '", po$name,"' ...")
-
-  po <- pdb_posterior(po$name, pdb = pdb(po))
-  if(verbose) message("- Posterior can be read.")
-
-  check_pdb_read_model_code(list(po))
-  if(verbose) message("- The model_code can be read.")
-
-  check_pdb_read_data(list(po))
-  if(verbose) message("- The data can be read.")
-
-  check_pdb_read_reference_posterior_draws(list(po))
-  if(verbose) message("- The reference_posteriors_draws can be read (if it exists).")
-
-  check_pdb_aliases(pdb(po))
-  if(verbose) message("- Aliases are ok.")
-
-  if(run_stan_code_checks){
-    check_posterior_stan_syntax(po)
-    if(verbose) message("- Stan syntax is ok.")
-
-    check_pdb_posterior_run_stan(po)
-    if(verbose) message("- Stan can be run for the posterior.")
-  }
-
-  suppressMessages(check_pdb_references(pdb(po)))
-  if(verbose) message("- References and bibliography are ok.")
-
-  if(verbose) message("\nPosterior is ok.\n")
-  invisible(TRUE)
-}
diff --git a/rpackage/R/compute_reference_posterior_draws_stan_sampling.R b/rpackage/R/compute_reference_posterior_draws_stan_sampling.R
deleted file mode 100644
index 93695f1e..00000000
--- a/rpackage/R/compute_reference_posterior_draws_stan_sampling.R
+++ /dev/null
@@ -1,123 +0,0 @@
-#' Compute a Reference Posteriors for a reference posterior info object
-#'
-#' @param rpi a [reference_posterior_info] object.
-#' @param pdb a [pdb] object.
-#'
-#' @export
-compute_reference_posterior_draws <- function(rpi, pdb = pdb_default()){
-  checkmate::assert_class(pdb, "pdb")
-  assert_reference_posterior_info(x = rpi)
-  if(rpi$inference$method == "stan_sampling"){
-    rp <- compute_reference_posterior_draws_stan_sampling(rpi, pdb)
-  } else {
-    stop("Currently not implemented")
-  }
-  rp
-}
-
-#' Compute a Reference Posteriors using Rstan
-#'
-#' @param rpi a [reference_posterior_info] object.
-#' @param pdb a [pdb] object.
-#'
-compute_reference_posterior_draws_stan_sampling <- function(rpi, pdb){
-  checkmate::assert_class(pdb, "pdb")
-  assert_reference_posterior_info(x = rpi)
-  po <- posterior(rpi$name, pdb = pdb)
-  pdn <- posterior_dimension_names(x = po$dimensions)
-
-  stan_object <- run_stan(po,
-                          stan_args = rpi$inference$method_arguments)
-
-  # Compute the diagnostics from the stan object and add it to the slot
-  rpi$diagnostics <- compute_stan_sampling_diagnostics(x = stan_object, keep_dimensions = pdn)
-
-  # Create rpd object
-  rpd <- reference_posterior_draws(x = stan_object, info = rpi)
-
-  # Subset to relevant parameters (that are used)
-  rpd <- subset(rpd, variable = pdn)
-
-  rpd
-}
-
-
-
-
-#' @rdname reference_posterior_draws
-#' @export
-reference_posterior_draws.stanfit <- function(x, info, pdb = pdb_default(), ...){
-  checkmate::assert_class(info, "pdb_reference_posterior_info")
-  draws <- posterior::as_draws_list(posterior::as_draws(x))
-  reference_posterior_draws(draws)
-}
-
-
-#' Extract diagnostics
-#'
-#' @description
-#' The function extracts and computes the relevant diagnostics
-#'
-#' @param x a [stanfit] object.
-#' @param keep_dimensions a regular expression to choose dimensions to keep
-#'
-#' @keywords internal
-#' @noRd
-compute_stan_sampling_diagnostics <- function(x, keep_dimensions ){
-  checkmate::assert_character(keep_dimensions)
-
-  d <- list()
-  pd <- posterior::as_draws(x)
-  pds <- posterior::summarise_draws(pd)
-  checkmate::assert_subset(keep_dimensions, pds$variable)
-
-  keep_idx <- pds$variable %in% keep_dimensions
-
-
-  # diagnostic_information
-  d$diagnostic_information <- list(names = pds$variable[keep_idx])
-
-  # ndraws
-  d$ndraws <- posterior::ndraws(pd)
-
-  # nchains
-  d$nchains <- posterior::nchains(pd)
-
-  # ESS bulk
-  d$effective_sample_size_bulk <- pds$ess_bulk[keep_idx]
-
-  # ESS tail
-  d$effective_sample_size_tail <- pds$ess_tail[keep_idx]
-
-  # r_hat
-  d$r_hat <- pds$rhat[keep_idx]
-
-  # divergent_transitions
-  hmc_params <- rstan::get_sampler_params(x, inc_warmup = FALSE)
-  d$divergent_transitions <- unlist(lapply(hmc_params, function(x) sum(x[, "divergent__"])))
-
-  # expected_fraction_of_missing_information
-  d$expected_fraction_of_missing_information <- rstan::get_bfmi(x)
-
-  d
-}
-
-
-#' Construct dimension names from a posterior dimension list
-#'
-#' @param x a dimensions slot from a [pdb_posterior]
-posterior_dimension_names <- function(x){
-  checkmate::assert_list(x)
-  checkmate::assert_named(x)
-  for(i in seq_along(x)) checkmate::assert_int(x[[i]])
-
-  dn <- list()
-  for(i in seq_along(x)){
-    if(x[[i]] > 1L){
-      dn[[i]] <- paste0(names(x)[i], "[", 1:x[[i]], "]")
-    } else {
-      dn[[i]] <- names(x)[i]
-    }
-  }
-  return(unlist(dn))
-}
diff --git a/rpackage/R/compute_summary_statistics.R b/rpackage/R/compute_summary_statistics.R
deleted file mode 100644
index 8cca7812..00000000
--- a/rpackage/R/compute_summary_statistics.R
+++ /dev/null
@@ -1,34 +0,0 @@
-#' Compute Summary statistics from a reference posterior
-#'
-#' @param rpd a [reference_posterior_summary_statistic] object
-#' @param summary_statistic summary statistic to compute
-#'
-#' @export
-compute_reference_posterior_summary_statistic <- function(rpd, summary_statistic = "mean"){
-  checkmate::assert_class(rpd, classes = "pdb_reference_posterior_draws")
-  rpi <- info(rpd)
-  checkmate::assert_class(rpi, classes = "pdb_reference_posterior_info")
-  checkmate::assert_choice(summary_statistic, supported_summary_statistic_types())
-  assert_checked_summary_statistics_draws(rpd)
-
-  if(summary_statistic == "mean"){
-    res <- posterior::summarise_draws(rpd, "mean", "mcse_mean")
-    res <- as.list(res)
-    names(res)[1] <- "names"
-    rpi$versions$r_summary_statistic <- paste0("posterior R package, version ", utils::packageVersion("posterior"))
-  } else if (summary_statistic == "sd"){
-    res <- posterior::summarise_draws(rpd, "sd", "mcse_sd")
-    res <- as.list(res)
-    names(res)[1] <- "names"
-    rpi$versions$r_summary_statistic <- paste0("posterior R package, version ", utils::packageVersion("posterior"))
-  } else {
-    stop("Summary statistic is not implemented.")
-  }
-
-  rpss <- reference_posterior_summary_statistic(res, rpi, summary_statistic)
-  rpss
-}
-
-#' @rdname compute_reference_posterior_summary_statistic
-#' @export
-compute_summary_statistic <- compute_reference_posterior_summary_statistic
diff --git a/rpackage/R/data.R b/rpackage/R/data.R
deleted file mode 100644
index f5151336..00000000
--- a/rpackage/R/data.R
+++ /dev/null
@@ -1,112 +0,0 @@
-#' Posterior Data Sets
-#'
-#' @param x an object to access data from.
-#' @param pdb a \code{pdb} object.
-#' @param info a \code{pdb_data_info} object.
-#' @param ... Currently not used.
-#'
-#' @export
-get_data <- function(x, ...) {
-  UseMethod("get_data")
-}
-
-#' @rdname get_data
-#' @export
-get_data.pdb_posterior <- function(x, ...) {
-  get_data(x$data_name, pdb = pdb(x), ...)
-}
-
-#' @rdname get_data
-#' @export
-get_data.character <- function(x, pdb = pdb_default(), ...) {
-  checkmate::assert_string(x)
-  sdfp <- data_file_path(x, pdb = pdb)
-  dat <- jsonlite::read_json(sdfp, simplifyVector = TRUE)
-  class(dat) <- c("pdb_data", "list")
-  info(dat) <- data_info(x, pdb)
-  pdb(dat) <- pdb
-  assert_data(dat)
-  dat
-}
-
-#' @rdname get_data
-#' @export
-get_data.pdb_data_info <- function(x, pdb = pdb_default(), ...){
-  get_data(x$name, pdb)
-}
-
-#' @rdname get_data
-#' @export
-get_data.list <- function(x, info, ...){
-  checkmate::assert_class(info, "pdb_data_info")
-  class(x) <- c("pdb_data", "list")
-  info(x) <- info
-  assert_data(x)
-  x
-}
-
-#' @rdname get_data
-#' @export
-pdb_data <- get_data
-
-#' Extract data for posterior
-#'
-#' @inheritParams model_code_file_path
-#' @export
-data_file_path <- function(x, ...) {
-  UseMethod("data_file_path")
-}
-
-#' @inheritParams model_code_file_path
-#' @export
-data_file_path.pdb_posterior <- function(x, ...) {
-  fp <- pdb_cached_local_file_path(pdb = pdb(x), path = x$data_info$data_file, unzip = TRUE)
-  checkmate::assert_file_exists(fp)
-  fp
-}
-
-#' @inheritParams model_code_file_path
-#' @export
-data_file_path.character <- function(x, pdb = pdb_default(), ...) {
-  checkmate::assert_string(x)
-  fn <- paste0(x, ".json")
-  fp <- pdb_cached_local_file_path(pdb = pdb, path = file.path("data", "data", fn), unzip = TRUE)
-  checkmate::assert_file_exists(fp)
-  fp
-}
-
-#' @inheritParams model_code_file_path
-#' @export
-data_file_path.pdb_data_info <- function(x, pdb = pdb_default(), ...) {
-  data_file_path(x$name, pdb = pdb, ...)
-}
-
-#' @rdname data_file_path
-#' @export
-stan_data_file_path <- function(x, ...) {
-  data_file_path(x, ...)
-}
-
-#' @rdname data_file_path
-#' @export
-stan_data <- function(x) {
-  get_data(x)
-}
-
-#' Assert the data format
-#' @noRd
-#' @keywords internal
-assert_data <- function(x){
-  checkmate::assert_list(x)
-  checkmate::assert_class(x, "pdb_data")
-  checkmate::assert_named(x, type = "unique")
-  checkmate::assert_class(info(x), "pdb_data_info")
-}
-
-#' @export
-print.pdb_data <- function(x, ...) {
-  attr(x, "info") <- NULL
-  attr(x, "pdb") <- NULL
-  x <- unclass(x)
-  NextMethod("print")
-}
diff --git a/rpackage/R/data_info.R b/rpackage/R/data_info.R
deleted file mode 100644
index 78518eb2..00000000
--- a/rpackage/R/data_info.R
+++ /dev/null
@@ -1,65 +0,0 @@
-#' @rdname model_info
-#' @export
-data_info <- function(x, ...) {
-  UseMethod("data_info")
-}
-
-#' @rdname model_info
-#' @export
-data_info.pdb_posterior <- function(x, ...) {
-  x$data_info
-}
-
-#' @rdname model_info
-#' @export
-data_info.character <- function(x, pdb = pdb_default(), ...) {
-  checkmate::assert_string(x)
-  read_data_info(x, pdb)
-}
-
-#' @rdname model_info
-#' @export
-data_info.list <- function(x, pdb = NULL, ...) {
-  class(x) <- "pdb_data_info"
-  checkmate::assert_string(x$name)
-  if(is.null(x$data_file)) x$data_file <- paste0("data/data/", x$name, ".json")
-  assert_data_info(x)
-  x
-}
-
-#' @rdname model_info
-#' @export
-pdb_data_info <- data_info
-
-
-
-# read data info from the data base
-read_data_info <- function(x, pdb = NULL, ...) {
-  data_info <- read_info_json(x, path = "data/info", pdb = pdb, ...)
-  class(data_info) <- "pdb_data_info"
-  assert_data_info(data_info)
-  data_info
-}
-
-#' @export
-print.pdb_data_info <- function(x, ...) {
-  cat0("Data: ", x$name, "\n")
-  cat0(x$title, "\n")
-  invisible(x)
-}
-
-assert_data_info <- function(x){
-  checkmate::assert_names(names(x),
-                          subset.of = c("name", "data_file", "title", "added_by", "added_date", "references", "description", "urls", "keywords"),
-                          must.include = c("name", "data_file", "title", "added_by", "added_date"))
-  checkmate::assert_string(x$name)
-  checkmate::assert_set_equal(x$data_file, y = paste0("data/data/", x$name, ".json"))
-  checkmate::assert_string(x$title)
-  checkmate::assert_string(x$added_by)
-  checkmate::assert_date(x$added_date)
-
-  checkmate::assert_character(x$references, null.ok = TRUE)
-  checkmate::assert_string(x$description, null.ok = TRUE)
-  checkmate::assert_character(x$urls, null.ok = TRUE)
-  checkmate::assert_character(x$keywords, null.ok = TRUE)
-}
diff --git a/rpackage/R/filter.R b/rpackage/R/filter.R
deleted file mode 100644
index e68a9931..00000000
--- a/rpackage/R/filter.R
+++ /dev/null
@@ -1,40 +0,0 @@
-#' Filter Posteriors in Database
-#'
-#' @details
-#' Filter posteriors in the database and return list of
-#' posteriors/models/data to work with as a list.
-#'
-#' The function is built upon the dplyr filter function and
-#' follows the exact same syntax. All elements in the
-#' `posteriors/[posterior_name].json`, `models/info/[model_name].json`
-#' and `data/info/[data_name].json` can be used to filter the
-#' posterior database. See examples below.
-#'
-#' @param pdb a \code{pdb} object.
-#' @param ... further arguments to supply to \code{dplyr::filter()}
-#' @export
-filter_posteriors <- function(pdb = pdb_default(), ...){
-  pdb_filter(path = "posteriors", pdb = pdb, ...)
-}
-
-#' Internal filter function
-#'
-#' Works for filtering models, data and posteriors.
-#'
-#' @keywords internal
-#' @param pdb a pdb connection
-pdb_filter <- function(path, pdb, ...){
-  checkmate::assert_class(pdb, "pdb")
-  checkmate::assert_choice(path, c("posteriors", "models/info", "data/info"))
-
-  dat <- pdb_tibble(pdb, path)
-
-  dat_tbl <- dplyr::filter(dat, ...)
-
-  nms <- unique(dat_tbl$name)
-  obj_list <- list()
-  for(i in seq_along(nms)) {
-    obj_list[[i]] <- posterior(nms[i], pdb = pdb)
-  }
-  obj_list
-}
diff --git a/rpackage/R/generics.R b/rpackage/R/generics.R
deleted file mode 100644
index 09fe8dbd..00000000
--- a/rpackage/R/generics.R
+++ /dev/null
@@ -1,19 +0,0 @@
-#' Extract information from a pdb object
-#'
-#' @param x a [pdb_data], [pdb_model_code] and [pdb_reference_posterior]
-#' @param info a [pdb_]
-#'
-#' @export
-info <- function(x) {
-  attr(x, "info")
-}
-
-#' Set information to a pdb object
-#'
-#' @inheritParams info
-#' @param value an info object
-#'
-`info<-` <- function(x, value){
-  attr(x, "info") <- value
-  x
-}
diff --git a/rpackage/R/model_code.R b/rpackage/R/model_code.R
deleted file mode 100644
index 5a378859..00000000
--- a/rpackage/R/model_code.R
+++ /dev/null
@@ -1,162 +0,0 @@
-#' Extract file paths to model code from posterior object
-#'
-#' @param x an object to access file path to.
-#' @param framework model code framework (e.g. \code{stan}).
-#' @param pdb a \code{pdb} object.
-#' @param info a \code{pdb_model_info} object.
-#' @param ... further arguments supplied to methods.
-#'
-#' @seealso framework()
-#'
-#' @export
-model_code <- function(x, ...) {
-  UseMethod("model_code")
-}
-
-#' @rdname model_code
-#' @export
-model_code.pdb_posterior <- function(x, framework, ...) {
-  model_code(x$model_name, framework, pdb = pdb(x), ...)
-}
-
-#' @rdname model_code
-#' @export
-model_code.character <- function(x, framework, pdb = pdb_default(), ...) {
-  checkmate::assert_string(x)
-  scfp <- model_code_file_path(x, framework, pdb, ...)
-  out <- paste0(readLines(scfp), collapse = "\n")
-  class(out) <- c("pdb_model_code", "character")
-  framework(out) <- framework
-  info(out) <- model_info(x, pdb = pdb)
-  pdb(out) <- pdb
-  assert_model_code(out)
-  out
-}
-
-#' @rdname model_code
-#' @export
-model_code.pdb_model_info <- function(x, framework, pdb = pdb_default(), ...) {
-  model_code(x$name, framework, pdb, ...)
-}
-
-#' @rdname model_code
-#' @export
-model_code.stanmodel <- function(x, info, ...){
-  mc <- x@model_code
-  class(mc) <- "pdb_model_code"
-  framework(mc) <- "stan"
-  info(mc) <- info
-  assert_model_code(mc)
-  mc
-}
-
-#' @rdname model_code
-#' @export
-pdb_model_code <- model_code
-
-
-
-#' @rdname model_code
-#' @export
-model_code_file_path <- function(x, ...) {
-  UseMethod("model_code_file_path")
-}
-
-#' @rdname model_code
-#' @export
-model_code_file_path.pdb_posterior <- function(x, framework, ...) {
-  checkmate::assert_choice(framework, names(x$model_info$model_implementations))
-  mcfp <- pdb_cached_local_file_path(pdb(x), x$model_info$model_implementations[[framework]]$model_code)
-  mcfp
-}
-
-#' @rdname model_code
-#' @export
-model_code_file_path.pdb_model_info <- function(x, framework, pdb = pdb_default(), ...) {
-  model_code_file_path(x$name, framework, pdb, ...)
-}
-
-#' @rdname model_code
-#' @export
-model_code_file_path.character <- function(x, framework, pdb = pdb_default(), ...) {
-  fn <- paste0(x, ".", framework)
-  mcfp <- pdb_cached_local_file_path(pdb = pdb, path = file.path("models", framework, fn), unzip = FALSE)
-  mcfp
-}
-
-#' @export
-print.pdb_model_code <- function(x, ...) {
-  cat(x)
-  invisible(x)
-}
-
-#' @rdname model_code
-#' @export
-stan_code_file_path <- function(x) {
-  checkmate::assert_class(x, "pdb_posterior")
-  model_code_file_path(x, "stan")
-}
-
-#' @rdname model_code
-#' @export
-stan_code <- function(x, ...) {
-  model_code(x, framework = "stan", ...)
-}
-
-#' @rdname model_code
-#' @export
-pdb_stan_code <- stan_code
-
-
-assert_model_code <- function(x){
-  checkmate::assert_class(x, "pdb_model_code")
-  checkmate::assert_string(x)
-  checkmate::assert_choice(framework(x), choices = supported_frameworks())
-  checkmate::assert_class(info(x), "pdb_model_info")
-}
-
-#' Identify the framework for a given [model_code]
-#'
-#' @param x a [pdb_model_code] object.
-#' @param value a supported framework.
-#'
-#' @export
-framework <- function(x){
-  UseMethod("framework")
-}
-
-#' @rdname framework
-#' @export
-framework.pdb_model_code <- function(x){
-  attr(x, which = "framework")
-}
-
-#' @rdname framework
-#' @export
-`framework<-` <- function(x, value){
-  UseMethod("framework<-")
-}
-
-#' @rdname framework
-#' @export
-`framework<-.character` <- function(x, value){
-  checkmate::assert_choice(value, supported_frameworks())
-  attr(x, "framework") <- value
-  x
-}
-
-#' @rdname framework
-#' @export
-`framework<-.pdb_model_code` <- function(x, value){
-  checkmate::assert_choice(value, supported_frameworks())
-  x <- `framework<-.character`(x, value)
-  x
-}
-
-supported_frameworks <- function() c("stan", "pymc3", "tfp", "pyro")
-
-supported_frameworks_file_extension <- function(x){
-  checkmate::assert_choice(x, choices = supported_frameworks())
-  sffe <- c("stan"="stan", "pymc3"="py", "tfp"="py", "pyro"="py")
-  sffe[x]
-}
diff --git a/rpackage/R/model_info.R b/rpackage/R/model_info.R
deleted file mode 100644
index dce1df98..00000000
--- a/rpackage/R/model_info.R
+++ /dev/null
@@ -1,80 +0,0 @@
-#' Access data and model information
-#'
-#' @param x a object to access information for.
-#' @param pdb a \code{pdb} object.
-#' @param ... further arguments to methods.
-#'
-#' @export
-model_info <- function(x, ...) {
-  UseMethod("model_info")
-}
-
-#' @rdname model_info
-#' @export
-pdb_model_info <- model_info
-
-#' @rdname model_info
-#' @export
-model_info.pdb_posterior <- function(x, ...) {
-  x$model_info
-}
-
-#' @rdname model_info
-#' @export
-model_info.character <- function(x, pdb = pdb_default(), ...) {
-  checkmate::assert_string(x)
-  read_model_info(x, pdb)
-}
-
-#' @rdname model_info
-#' @export
-model_info.list <- function(x, pdb = NULL, ...) {
-  class(x) <- "pdb_model_info"
-  if(!is.null(x$framework)){
-    checkmate::assert_null(x$model_implementations)
-    mi <- list(list("model_code" = paste0("models/", x$framework,"/", x$name, ".",
-                supported_frameworks_file_extension(x$framework))))
-    x$model_implementations <- mi
-    names(x$model_implementations) <- x$framework
-    x$framework <- NULL
-  }
-  assert_model_info(x)
-  x
-}
-
-
-# read model info from the data base
-read_model_info <- function(x, pdb = NULL, ...) {
-  model_info <- read_info_json(x, path = "models/info", pdb = pdb, ...)
-  class(model_info) <- "pdb_model_info"
-  assert_model_info(model_info)
-  model_info
-}
-
-#' @export
-print.pdb_model_info <- function(x, ...) {
-  cat0("Model: ", x$name, "\n")
-  cat0(x$title, "\n")
-  cat0("Frameworks: '", paste(names(x$model_implementations), collapse = "', '"), "'\n")
-  invisible(x)
-}
-
-assert_model_info <- function(x){
-  checkmate::assert_names(names(x),
-                          subset.of = c("name", "model_implementations", "title", "prior", "added_by", "added_date", "references", "description", "urls", "keywords"),
-                          must.include = c("name", "model_implementations", "title", "added_by", "added_date"))
-  checkmate::assert_string(x$name)
-  checkmate::assert_names(names(x$model_implementations), subset.of = supported_frameworks())
-  for(i in seq_along(x$model_implementations)){
-    checkmate::assert_names(names(x$model_implementations[[i]]), must.include = "model_code", subset.of = c("model_code", "likelihood_code"))
-  }
-  checkmate::assert_string(x$title)
-  checkmate::assert_string(x$added_by)
-  checkmate::assert_date(x$added_date)
-
-  checkmate::assert_string(x$description, null.ok = TRUE)
-
-  checkmate::assert_character(x$references, null.ok = TRUE)
-  checkmate::assert_character(x$urls)
-  checkmate::assert_character(x$keywords, null.ok = TRUE)
-}
diff --git a/rpackage/R/pdb.R b/rpackage/R/pdb.R
deleted file mode 100644
index 66c307bb..00000000
--- a/rpackage/R/pdb.R
+++ /dev/null
@@ -1,682 +0,0 @@
-#' Create a Posterior Database (pdb) connection
-#'
-#' @details
-#' Connect to a posterior database locally or in a github repo.
-#'
-#' [pdb_config()] read  [.pdb_config.yml] in [directory] and use that to setup a
-#' pdb connection.
-#'
-#' The connection [pdb_default()] first checks if there exists a [.pdb_config.yml]
-#' file in the working directory. If it exist, [pdb_config()] is used to setup,
-#' the connection, otherwise [pdb_github()] is used.
-#'
-#'
-#' @param cache_path The path to the pdb cache. Default is R temporary directory.
-#' This is used to store files locally and without affecting the database.
-#' @param x an object to access a pdb for, if character this is how to identify the pdb (path for local pdb, repo for github pdb)
-#' @param pdb_type Type of posterior database connection. Either \code{local} or \code{github}.
-#' @param path a local path to a posterior database.
-#' @param repo Repository address in the format
-#'   `username/repo[/subdir][@@ref|#pull]`. Alternatively, you can
-#'   specify `subdir` and/or `ref` using the respective parameters
-#'   (see below); if both is specified, the values in `repo` take
-#'   precedence.
-#' @param ref Desired git reference. Could be a commit, tag, or branch
-#'   name. Defaults to `"master"`.
-#' @param subdir subdirectory within repo that contains the posterior database.
-#' @param auth_token To use a private repo, generate a personal
-#'   access token (PAT) in "https://github.com/settings/tokens" and
-#'   supply to this argument. This is safer than using a password because
-#'   you can easily delete a PAT without affecting any others. Defaults to
-#'   the `GITHUB_PAT` environment variable.
-#' @param host GitHub API host to use. Override with your GitHub enterprise
-#'   hostname, for example, `"github.hostname.com/api/v3"`.
-#' @param directory the directory to look for the [.pdb_config.yml] file
-#' @param ... further arguments for specific methods to setup a pdb.
-#' @return a \code{pdb} object
-#'
-#' @export
-pdb_local <- function(path = getOption("pdb_path", getwd()),
-                      cache_path = tempdir()){
-  pdb(x = path, pdb_type = "local", cache_path = cache_path)
-}
-
-#' @rdname pdb_local
-#' @export
-pdb <- function(x, ...){
-  UseMethod("pdb")
-}
-
-#' @rdname pdb_local
-#' @export
-pdb.default <- function(x, ...){
-  return(attr(x, "pdb"))
-}
-
-#' @rdname pdb_local
-#' @export
-pdb.pdb_model_code <- function(x, ...){
-  pdb.default(x, ...)
-}
-
-#' @rdname pdb_local
-#' @export
-pdb.character <- function(x, pdb_type = "local", cache_path = tempdir(), ...) {
-  checkmate::assert_directory(cache_path, "w")
-  checkmate::assert_choice(pdb_type, supported_pdb_types())
-  if(cache_path == tempdir()){
-    # To ensure no duplicate temp file names from R session.
-    cache_path <- file.path(cache_path, "posteriordb_cache")
-  }
-  if(!dir.exists(cache_path)) dir.create(cache_path)
-  pdb <- list(
-    pdb_id = x,
-    cache_path = cache_path
-  )
-  class(pdb) <- c(paste0("pdb_", pdb_type), "pdb")
-  pdb <- setup_pdb(pdb, ...)
-  pdb$version <- pdb_version(pdb)
-  assert_pdb(pdb)
-  pdb
-}
-
-assert_pdb <- function(x){
-  checkmate::assert_class(x, classes = "pdb")
-  checkmate::assert_names(names(x), must.include = c("pdb_id", "cache_path", "version"))
-  checkmate::assert_string(x$pdb_id)
-  checkmate::assert_directory_exists(x$cache_path)
-  checkmate::assert_list(x$version)
-}
-
-supported_pdb_types <- function() c("local", "github")
-
-#' Set pdb slot
-#'
-#' @inheritParams info
-#' @param value a pdb object
-#'
-`pdb<-` <- function(x, value){
-  checkmate::assert_class(value, "pdb", null.ok = TRUE)
-  attr(x, "pdb") <- value
-  x
-}
-
-
-
-# Note, pdb_local contain all information on pdbs.
-#' @rdname pdb_local
-#' @export
-pdb_default <- function(cache_path = tempdir()){
-  pdbc <- suppressWarnings(try(pdb_config(), silent = TRUE))
-  if(inherits(pdbc, "pdb")) return(pdbc)
-  pdb_github("stan-dev/posteriordb/posterior_database", cache_path = cache_path)
-}
-
-#' @rdname pdb_local
-#' @export
-pdb_config <- function(directory = getwd()){
-  obj <- yaml::read_yaml(file.path(directory, ".pdb_config.yml"))
-  pdb_fun <- eval(parse(text = paste0("pdb_", obj$type)))
-  args <- obj;args$type <- NULL
-  pdbo <- do.call(pdb_fun, args = args)
-  pdbo$.pdb_config.yml <- obj
-  pdbo
-}
-
-#' Setup object specific part of pdb object
-#' @param pdb a \code{pdb} object.
-#' @param ... further arguments supplied to specific methods (not in use)
-#' @keywords internal
-setup_pdb <- function(pdb, ...){
-  UseMethod("setup_pdb")
-}
-
-#' @rdname setup_pdb
-setup_pdb.pdb_local <- function(pdb, ...){
-  pdb <- pdb_endpoint(pdb)
-  checkmate::assert_directory(pdb$pdb_local_endpoint, "r")
-  pdb$pdb_id <- pdb$pdb_local_endpoint
-  pdb
-}
-
-#' Get version of the \code{pdb}
-#'
-#' @param pdb a \code{pdb} object to return version for.
-#' @param ... Further argument to methods.
-#'
-#' @return the git sha for the posterior database.
-#' @export
-pdb_version <- function(pdb, ...){
-  if(!is.null(pdb$version)) return(pdb$version)
-  UseMethod("pdb_version")
-}
-
-#' @rdname pdb_version
-#' @export
-pdb_version.pdb_local <- function(pdb, ...){
-  repo <- git2r::repository(pdb$pdb_local_endpoint)
-  r <- git2r::revparse_single(repo, "HEAD")
-  list("sha" = git2r::sha(r))
-}
-
-#' Get all existing posterior names from a posterior database or posterior objects.
-#'
-#' @param x a \code{pdb}, \code{posterior} object or a list of \code{posterior} objects.
-#' @param ... further arguments supplied to specific methods (not in use)
-#' @export
-posterior_names <- function(x = pdb_default(), ...) {
-  pn(x, ...)
-}
-
-#' @rdname posterior_names
-#' @export
-posterior_name <- posterior_names
-
-pn <- function(x, ...) {
-  UseMethod("pn")
-}
-
-pn.pdb_local <- function(x, ...) {
-  pns <- dir(pdb_file_path(x, "posteriors"))
-  remove_file_extension(pns)
-}
-
-pn.list <- function(x, ...) {
-  res <- list()
-  for(i in seq_along(x)){
-    res[[i]] <- pn(x[[i]], ...)
-  }
-  res
-}
-
-pn.pdb_posterior <- function(x, ...){
-  x$name
-}
-
-pdb_file_path <- function(pdb, ...){
-  UseMethod("pdb_file_path")
-}
-
-pdb_file_path.pdb_local <- function(pdb, ...){
-  file.path(pdb$pdb_local_endpoint, ...)
-}
-
-#' Get all existing model names from a posterior database
-#'
-#' @param pdb a \code{pdb} object.
-#' @param ... Further argument to methods.
-#' @export
-model_names <- function(pdb = pdb_default(), ...) {
-  UseMethod("model_names")
-}
-
-#' @rdname model_names
-#' @export
-model_names.pdb_local <- function(pdb = pdb_default(), ...) {
-  pns <- dir(pdb_file_path(pdb, "models", "info"),
-             recursive = TRUE, full.names = FALSE)
-  pns <- pns[grepl(pns, pattern = "\\.info\\.json$")]
-  basename(remove_file_extension(pns))
-}
-
-#' Get all existing data names from a posterior database
-#'
-#' @param pdb a \code{pdb} object.
-#' @param ... Further argument to methods.
-#'
-#' @export
-data_names <- function(pdb = pdb_default(), ...) {
-  UseMethod("data_names")
-}
-
-#' @rdname data_names
-#' @export
-data_names.pdb_local <- function(pdb = pdb_default(), ...) {
-  pns <- dir(pdb_file_path(pdb, "data", "info"),
-             recursive = TRUE, full.names = FALSE)
-  pns <- pns[grepl(pns, pattern = "\\.info\\.json$")]
-  basename(remove_file_extension(pns))
-}
-
-#' Get all existing reference posterior names from a posterior database
-#'
-#' @param pdb a \code{pdb} object.
-#' @param type supported reference posterior types.
-#' @param ... Further argument to methods.
-#'
-#' @export
-reference_posterior_names <- function(pdb = pdb_default(), type, ...) {
-  checkmate::assert_choice(type, supported_reference_posterior_types())
-  UseMethod("reference_posterior_names")
-}
-
-#' @rdname reference_posterior_names
-#' @export
-reference_posterior_names.pdb_local <- function(pdb = pdb_default(), type, ...) {
-  pns <- dir(pdb_file_path(pdb, "reference_posteriors", type, "info"),
-             recursive = TRUE, full.names = FALSE)
-  pns <- pns[grepl(pns, pattern = "\\.info\\.json$")]
-  basename(remove_file_extension(pns))
-}
-
-
-#' @export
-print.pdb <- function(x, ...) {
-  cat0("Posterior Database (", pdb_type(x), ")\n")
-  cat0("Path: ", x$pdb_id, "\n")
-  cat0("Version:\n")
-  for (vn in names(x$version)) {
-    cat0("  ", vn, ": ", x$version[[vn]], "\n")
-  }
-  if(!is.null(x$.pdb_config.yml)){
-    cat0("\n.pdb_config.yml:\n")
-    prt <- paste0("  ", yaml::as.yaml(x$.pdb_config.yml))
-    cat0(gsub(prt, pattern = "\n", replacement = "\\\n  "))
-  }
-  invisible(x)
-}
-
-#' @export
-print.pdb_github <- function(x, ...) {
-  x$pdb_id <- paste(x$pdb_id, "@", x$github$ref)
-  NextMethod("print")
-}
-
-#' Extract the pdb type from class name
-#' @noRd
-#' @param a \code{pdb} object.
-#' @keywords internal
-pdb_type <- function(pdb){
-  strsplit(class(pdb)[1], split = "_")[[1]][2]
-}
-
-
-#' Set and check posterior database endpoint
-#' i.e. after this has run, the pdb points to the
-#' posteriordb root. Local pdb search all folders below
-#' Github pdb just checks that the supplied github repo
-#' (with subdir) points to the pdb
-#' @noRd
-#' @param pdb a \code{pdb} object.
-#' @param ... further arguments supplied to class specific methods.
-#' @return a \code{pdb} object with set/checked endpoint.
-#' @keywords internal
-pdb_endpoint <- function(pdb, ...) {
-  UseMethod("pdb_endpoint")
-}
-
-#' @noRd
-#' @rdname pdb_endpoint
-#' @keywords internal
-pdb_endpoint.pdb_local <- function(pdb, ...) {
-  if(!is.null(pdb$pdb_local_endpoint)) return(pdb$pdb_local_endpoint)
-
-  pdb$pdb_local_endpoint <- normalizePath(pdb$pdb_id)
-  while (!is_pdb_endpoint(pdb) & basename(pdb$pdb_local_endpoint) != "") {
-    # Check if the folder has a posterior_database folder
-    pdbfp <- file.path(pdb$pdb_local_endpoint, "posterior_database")
-    if(is_pdb_endpoint_local_path(pdbfp)){
-      pdb$pdb_local_endpoint <- pdbfp
-    } else {
-      pdb$pdb_local_endpoint <- dirname(pdb$pdb_local_endpoint)
-    }
-  }
-  if (basename(pdb$pdb_local_endpoint) == "") {
-    stop2("No posterior database in path '", pdb$pdb_id, "'.")
-  }
-  checkmate::assert_directory(pdb$pdb_local_endpoint)
-  pdb
-}
-
-
-#' Check if the current pdb points to a posterior database endpoint
-#' @noRd
-#' @param pdb a \code{pdb} object.
-#' @param ... further arguments supplied to class specific methods.
-#' @return a boolean
-#' @keywords internal
-is_pdb_endpoint <- function(pdb, ...) {
-  UseMethod("is_pdb_endpoint")
-}
-
-pdb_minimum_contents <- function() c("data", "models", "posteriors")
-
-#' @noRd
-#' @rdname is_pdb_endpoint
-#' @keywords internal
-is_pdb_endpoint.pdb_local <- function(pdb, ...) {
-  is_pdb_endpoint_local_path(pdb$pdb_local_endpoint)
-
-}
-
-#' @noRd
-#' @rdname is_pdb_endpoint
-#' @keywords internal
-is_pdb_endpoint_local_path <- function(x) {
-  checkmate::test_directory_exists(x) && all(pdb_minimum_contents() %in% dir(x))
-}
-
-
-#' Read json file from \code{path}
-#'
-#' @details
-#' Copies the file to the cache and return path
-#'
-#' @param pdb a \code{pdb} to read from.
-#' @param path a \code{pdb} to read from.
-#' @param unzip if true, path is zipped and should be unzipped to cache.
-#' @importFrom utils unzip
-pdb_cached_local_file_path <- function(pdb, path, unzip = FALSE){
-  checkmate::assert_class(pdb, "pdb")
-  checkmate::assert_string(path)
-  checkmate::assert_flag(unzip)
-
-  # Check if path in cache - return cached path
-  cp <- pdb_cache_path(pdb, path)
-  if(file.exists(cp)) return(cp)
-
-  # Assert file exists
-  if(unzip) {
-    path_zip <- paste0(path, ".zip")
-  }
-
-  # Copy (and unzip) file to cache
-  if(unzip){
-    cp_zip <- paste0(cp, ".zip")
-    pdb_file_copy(pdb, from = path_zip, to = cp_zip, overwrite = TRUE)
-    utils::unzip(zipfile = cp_zip, exdir = dirname(cp_zip))
-    file.remove(cp_zip)
-  } else {
-    pdb_file_copy(pdb, from = path, to = cp, overwrite = TRUE)
-  }
-
-  return(cp)
-}
-
-#' Returns a writable cache path for a pdb and a path
-#' It will create the directory if it does not exist.
-#' @param pdb a \code{pdb} object.
-#' @param path a \code{pdb} path.
-pdb_cache_path <- function(pdb, path){
-  cp <- file.path(pdb$cache_path, path)
-  for(i in seq_along(cp)){
-    if(!dir.exists(dirname(cp[i]))){
-      dir.create(dirname(cp[i]), showWarnings = FALSE, recursive = TRUE)
-    }
-  }
-  cp
-}
-
-#' Returns a cached files in path
-#' @param pdb a \code{pdb} object.
-#' @param path a \code{pdb} path.
-#' @param file_ext should the file extensions be returned? Default is TRUE.
-#' @param all.files see \code{dir()}.
-#' @param full.names see \code{dir()}.
-#' @param recursive see \code{dir()}.
-#' @keywords internal
-#' @noRd
-pdb_list_files_in_cache <- function(pdb, path, file_ext = TRUE, all.files = FALSE, full.names = FALSE, recursive = FALSE){
-  checkmate::assert_class(pdb, "pdb")
-  checkmate::assert_string(path)
-  checkmate::assert_flag(file_ext)
-  checkmate::assert_flag(all.files)
-  checkmate::assert_flag(full.names)
-  checkmate::assert_flag(recursive)
-  fns <- list.files(pdb_cache_path(pdb, path), all.files = all.files, full.names = full.names,  recursive = recursive)
-  if(!file_ext) fns <- remove_file_extension(fns)
-  fns
-}
-
-
-#' Copy a file from a pdb to a local path
-#'
-#' @param pdb a \code{pdb} connection.
-#' @param from a path in the pdb
-#' @param to a local file path
-#' @param overwrite overwrite local file.
-#' @param ... further argument supplied to methods
-#' @return a boolean indicator as file.copy indicating success.
-pdb_file_copy <- function(pdb, from, to, overwrite = FALSE, ...){
-  checkmate::assert_class(pdb, "pdb")
-  checkmate::assert_string(from)
-  checkmate::assert_path_for_output(to, overwrite = overwrite)
-  checkmate::assert_flag(overwrite)
-  UseMethod("pdb_file_copy")
-}
-
-#' @rdname pdb_file_copy
-pdb_file_copy.pdb_local <- function(pdb, from, to, overwrite = FALSE, ...){
-  pdb_assert_file_exist(pdb, from)
-  file.copy(from = pdb_file_path(pdb, from), to = to, overwrite = overwrite, ...)
-}
-
-#' Assert that a file exists
-#' @param pdb a \code{pdb} object.
-#' @param path a \code{pdb} path.
-#' @param ... further arguments supplied to methods.
-pdb_assert_file_exist <- function(pdb, path, ...){
-  UseMethod("pdb_assert_file_exist")
-}
-
-#' @rdname pdb_assert_file_exist
-pdb_assert_file_exist.pdb_local <- function(pdb, path, ...){
-  checkmate::assert_file_exists(file.path(pdb$pdb_local_endpoint, path))
-}
-
-#' Clear posterior database cache
-#' @param pdb a \code{pdb} to clear cache for
-#' @keywords internal
-pdb_clear_cache <- function(pdb = pdb_default()){
-  cached_files <- dir(pdb_cache_path(pdb, ""), recursive = TRUE, full.names = TRUE)
-  file.remove(cached_files)
-}
-
-#' @rdname pdb_clear_cache
-#' @keywords internal
-pdb_cache_clear <- pdb_clear_cache
-
-#' Remove object from cache
-#' @param x an object to remove from cache
-#' @param ... Currently not in use.
-pdb_cache_rm <- function(x, ...){
-  UseMethod(object = x, generic = "pdb_cache_rm")
-}
-
-#' @export
-#' @rdname pdb_cache_rm
-pdb_cache_rm.pdb_reference_posterior_draws <- function(x, ...){
-  fp <- file.path("reference_posteriors", "draws", "draws", paste0(info(x)$name, ".json"))
-  fpi <- file.path("reference_posteriors", "draws", "info", paste0(info(x)$name, ".info.json"))
-  file.remove(pdb_cache_path(pdb(x), c(fp,fpi)))
-}
-
-#' @export
-#' @rdname pdb_cache_rm
-pdb_cache_rm.pdb_data <- function(x, ...){
-  fp <- file.path("data", "data", paste0(info(x)$name, ".json"))
-  file.remove(pdb_cache_path(pdb(x), fp))
-}
-
-#' Cache a whole directory
-#'
-#' Mainly used for the filter functions
-#' @noRd
-#' @param pdb a \code{pdb} object.
-#' @param path path to cache
-#' @param ... further arguments supplied to class specific methods.
-#' @return a boolean indicating success
-#' @keywords internal
-pdb_cache_dir <- function(pdb, path, ...){
-  checkmate::assert_class(pdb, "pdb")
-  checkmate::assert_choice(path, choices = c("posteriors", "models/info", "data/info", "reference_posteriors/info"))
-  UseMethod("pdb_cache_dir")
-}
-
-#' @noRd
-#' @rdname pdb_cache_dir
-#' @keywords internal
-pdb_cache_dir.pdb_local <- function(pdb, path, ...){
-  fns <- dir(pdb_file_path(pdb, path), full.names = FALSE)
-  froms <- file.path(path, fns)
-  tos <- pdb_cache_path(pdb = pdb, path = file.path(path, fns))
-  for(i in seq_along(froms)){
-    pdb_file_copy(pdb = pdb, from = froms[i], to = tos[i], overwrite = TRUE)
-  }
-}
-
-#' Read in information json
-#' @param x a data, model or posterior name
-#' @param path one of \code{"posteriors"}, \code{"models/info"}, \code{"data/info"}
-#' @param pdb a posterior db object to access the info json from
-#' @noRd
-#' @keywords internal
-read_info_json <- function(x, path, pdb, ...){
-  checkmate::assert_choice(path, supported_pdb_paths())
-  UseMethod("read_info_json")
-}
-
-supported_pdb_paths <- function(){
-  c("posteriors",
-    "models/info",
-    "data/info",
-    "reference_posteriors/draws/draws",
-    "reference_posteriors/draws/info",
-    "reference_posteriors/expectations/expectations",
-    paste0("reference_posteriors/summary_statistics/", supported_summary_statistic_types(), "/",supported_summary_statistic_types()),
-    paste0("reference_posteriors/summary_statistics/", supported_summary_statistic_types(), "/info"),
-    "bibliography")
-}
-
-
-
-#' Read JSON objects from the posterior database
-#'
-#' @param fn file name
-#' @param path path to file name in pdb
-#' @param pdb a [pdb] object
-#' @param ... further arguments supplied to [jsonlite::read_json()]
-read_json_from_pdb <- function(fn, path, pdb, ...){
-  fp <- file.path(path, fn)
-  cfp <- pdb_cached_local_file_path(pdb, path = fp)
-  jsonlite::read_json(cfp, ...)
-}
-
-#' @rdname read_info_json
-#' @noRd
-#' @keywords internal
-read_info_json.character <- function(x, path, pdb, ...){
-  checkmate::assert_class(pdb, "pdb")
-  fn <- x
-  if(path != "posteriors") {
-    fn <- paste0(fn, ".info")
-  }
-  fn <- paste0(fn, ".json")
-
-  po <- read_json_from_pdb(fn, path, pdb, simplifyVector = TRUE)
-
-  po$added_date <- as.Date(po$added_date)
-  class(po) <- paste0("pdb_", gsub(x = path, pattern = "/", "_"))
-  po
-}
-
-#' @rdname read_info_json
-#' @noRd
-#' @keywords internal
-read_info_json.pdb_posterior <- function(x, path, pdb = NULL, ...){
-  if(path == "posteriors"){
-    nm <- x$name
-  } else if(path == "models/info") {
-    nm <- x$model_name
-  } else if(path == "data/info") {
-    nm <- x$data_name
-  }
-  po <- read_info_json(nm, path = path, pdb = pdb(x))
-  po
-}
-
-
-#' Write objects to posteriordb
-#' @param x a [reference_posterior_draws] object
-#' @param path a posteriordb path.
-#' @param info is this an info json?
-#' @param type Output type, [json] or [txt].
-#' @param name Used for code files and data.
-#' @param overwrite Should an existing file be overwritten?
-#' @param zip Should the json be zipped?
-#' @param pdb a local posteriordb object to write to
-#' @keywords internal
-write_to_path <- function(x, path, type, pdb, name = NULL, zip = FALSE, info = TRUE, overwrite = FALSE){
-  checkmate::assert_subset(class(x)[1], choices = c("character", "pdb_posterior", "pdb_model_info", "pdb_data_info", "pdb_data", "pdb_model_code", "pdb_reference_posterior_draws", "pdb_reference_posterior_info", supported_summary_statistic_classes()))
-  checkmate::assert_string(path)
-  checkmate::assert_class(pdb, "pdb_local")
-  checkmate::assert_choice(type, c("json", "txt", supported_frameworks()))
-  checkmate::assert_flag(zip)
-  checkmate::assert_flag(info)
-
-  if(is.null(name)){
-    if(is.null(x$name)){
-      nm <- info(x)$name
-    } else {
-      nm <- x$name
-    }
-  } else {
-    nm <- name
-  }
-
-  if(info) {
-    nm <- paste0(nm, ".info.", type)
-  } else {
-    nm <- paste0(nm, ".", type)
-  }
-
-  path <- strsplit(path, "/")[[1]]
-  fp <- file.path(pdb_endpoint(pdb), do.call(file.path, as.list(path)), nm)
-  zfp <- paste0(fp, ".zip")
-  if(zip){
-    checkmate::assert_path_for_output(zfp, overwrite = overwrite)
-  } else {
-    checkmate::assert_path_for_output(fp, overwrite = overwrite)
-  }
-
-  if(type == "json"){
-    out <- jsonlite::toJSON(x, pretty = TRUE, auto_unbox = TRUE, null = "null", digits = NA, encoding = "UTF-8")
-  } else if (type == "txt"){
-    out <- x
-  } else if (type == "stan"){
-    out <- x
-  } else {
-    stop(type, " not implemented.")
-  }
-
-  Encoding(out) <- "UTF-8"
-  writeLines(text = out, con = fp, useBytes = TRUE)
-
-  if(zip){
-    zip(files = fp, zipfile = zfp, flags = "-jq")
-    file.remove(fp)
-  }
-  return(invisible(TRUE))
-}
-
-#' @rdname write_to_path
-#' @keywords internal
-write_json_to_path <- function(x, path, pdb, type, name = NULL, zip = FALSE, info = TRUE, overwrite = FALSE){
-  write_to_path(x, path, pdb, type = "json", name, zip, info, overwrite)
-}
-#' @rdname write_to_path
-#' @keywords internal
-write_txt_to_path <- function(x, path, pdb, type, name = NULL, zip = FALSE, info = TRUE, overwrite = FALSE){
-  write_to_path(x, path, pdb, type = "txt", name, zip, info, overwrite)
-}
-#' @rdname write_to_path
-#' @keywords internal
-write_stan_to_path <- function(x, path, pdb, type, name = NULL, zip = FALSE, info = TRUE, overwrite = FALSE){
-  write_to_path(x, path, pdb, type = "stan", name, zip, info, overwrite)
-}
-
-#' @rdname write_to_path
-#' @keywords internal
-write_model_code_to_path <- function(x, path, pdb, framework, name = NULL, zip = FALSE, info = TRUE, overwrite = FALSE){
-  write_to_path(x, paste0(path, framework), pdb, type = framework, name, zip, info, overwrite)
-}
diff --git a/rpackage/R/pdb_github.R b/rpackage/R/pdb_github.R
deleted file mode 100644
index aa780c98..00000000
--- a/rpackage/R/pdb_github.R
+++ /dev/null
@@ -1,209 +0,0 @@
-#' @rdname pdb_local
-#' @export
-pdb_github <- function(repo = getOption("pdb_repo", "stan-dev/posteriordb/posterior_database"),
-                       cache_path = tempdir(),
-                       ref = github_ref(),
-                       subdir = NULL,
-                       auth_token = github_pat(),
-                       host = "https://api.github.com"){
-  pdb(x = repo, pdb_type = "github", cache_path = cache_path, ref = ref, subdir = subdir, pat = auth_token, host = host)
-}
-
-#' Setup a GitHub pdb
-#' @noRd
-#' @param pdb a github pdb to setup
-#' @param ref see \code{pdb_github}.
-#' @param subdir see \code{pdb_github}.
-#' @param pat see \code{pdb_github}.
-#' @param host see \code{pdb_github}.
-setup_pdb.pdb_github <- function(pdb, ...){
-  arg <- list(...)
-  pdb$github <- remotes::parse_github_repo_spec(pdb$pdb_id)
-  if(!nzchar(pdb$github$ref)) {
-    pdb$github$ref <- arg$ref
-  }
-  if(!nzchar(pdb$github$subdir)) {
-    pdb$github$subdir <- arg$subdir
-  }
-  pdb$github$host <- arg$host
-  pdb$github$pat <- arg$pat
-
-  pdb <- pdb_endpoint(pdb)
-  pdb
-}
-
-#' @rdname pdb_version
-#' @export
-pdb_version.pdb_github <- function(pdb, ...){
-  pat <- github_pat(pdb)
-  ghp <- gh::gh(github_path(pdb, type = "git/ref/heads"), .token = pat)
-  list("sha" = ghp$object$sha)
-}
-
-pn.pdb_github <- function(pdb, ...) {
-  pns <- github_dir(gh_path = github_path(pdb, type = "contents", path = "posteriors"), pdb = pdb)
-  remove_file_extension(pns)
-}
-
-#' @rdname pdb_file_copy
-pdb_file_copy.pdb_github <- function(pdb, from, to, overwrite = FALSE, ...){
-  pat <- github_pat(pdb)
-  ghp <- gh::gh(github_path(pdb, type = "contents", path = from), .token = pat)
-
-  if(is.null(pat)) {
-    ret <- httr::GET(ghp$download_url, httr::write_disk(to, overwrite = overwrite))
-  } else {
-    ret <- httr::GET(ghp$download_url, httr::add_headers(c("Authorization" = paste0("token ", pat))), httr::write_disk(to, overwrite = overwrite))
-  }
-
-  httr::status_code(ret) == 200L
-}
-
-
-#' @rdname data_names
-#' @export
-data_names.pdb_github <- function(pdb, ...) {
-  pns <- github_dir(gh_path = github_path(pdb, type = "contents", path = "data/info"), pdb = pdb)
-  pns <- pns[grepl(pns, pattern = "\\.json")]
-  basename(remove_file_extension(pns))
-}
-
-#' @rdname data_names
-#' @export
-model_names.pdb_github <- function(pdb, ...) {
-  pns <- github_dir(gh_path = github_path(pdb, type = "contents", path = "models/info"), pdb = pdb)
-  pns <- pns[grepl(pns, pattern = "\\.json")]
-  basename(remove_file_extension(pns))
-}
-
-#' @rdname data_names
-#' @export
-reference_posterior_names.pdb_github <- function(pdb, ...) {
-  pns <- github_dir(gh_path = github_path(pdb, type = "contents", path = "reference_posteriors/draws/info"), pdb = pdb)
-  pns <- pns[grepl(pns, pattern = "\\.json")]
-  basename(remove_file_extension(pns))
-}
-
-
-#' @noRd
-#' @rdname pdb_endpoint
-#' @keywords internal
-pdb_endpoint.pdb_github <- function(pdb, ...) {
-  if(!is_pdb_endpoint(pdb)){
-    stop2("No posterior database in '", pdb$pdb_id, "'.")
-  }
-  pdb
-}
-
-#' @noRd
-#' @rdname is_pdb_endpoint
-#' @keywords internal
-is_pdb_endpoint.pdb_github <- function(pdb, ...) {
-  dir_github <- github_dir(github_path(pdb, type = "contents"), pdb)
-  all(pdb_minimum_contents() %in% dir_github)
-}
-
-github_dir <- function(gh_path, pdb, recursive = FALSE, full.names = TRUE, ...){
-  if(recursive) stop("not implemented")
-  if(!full.names) stop("not implemented")
-  checkmate::assert_class(pdb, c("pdb_github"))
-  x <- gh::gh(gh_path, .token = github_pat(pdb), ...)
-  unlist(lapply(x, FUN=function(x) x$name))
-}
-
-github_path <- function(pdb, type, path = NULL){
-  checkmate::assert_class(pdb, c("pdb_github"))
-  checkmate::assert_choice(type, c("contents", "git/ref/heads"))
-  base_path <- file.path("/repos", pdb$github$username, pdb$github$repo)
-
-  if(type == "contents"){
-    final_path <- paste0(file.path0(base_path, "contents", pdb$github$subdir, path), "?ref=", pdb$github$ref)
-    return(final_path)
-  } else if (type == "git/ref/heads"){
-    final_path <- file.path0(base_path, "git/ref/heads", pdb$github$ref)
-    return(final_path)
-  }
-
-  stop("Incorrect type argument. This should not happen.")
-}
-
-
-#' Retrieve Github personal access token.
-#'
-#' A github personal access token
-#' Looks in env var `GITHUB_PAT`
-#' @param pdb A posterior datasbase object to extract pat from.
-#' @export
-github_pat <- function(pdb = NULL) {
-  # Sys.setenv(GITHUB_PAT = "my github token here")
-  # Sys.unsetenv("GITHUB_PAT")
-  pat <- Sys.getenv("GITHUB_PAT")
-  if (nzchar(pat)) {
-    return(pat)
-  }
-  if(is.null(pdb)) return(NULL)
-  pdb$github$pat
-}
-
-#' Retrieve Github reference.
-#'
-#' A github reference to use
-#' Looks in env var `GITHUB_REF`
-#' @param pdb A posterior datasbase object.
-#' @export
-github_ref <- function(pdb = NULL) {
-  ref <- Sys.getenv("GITHUB_REF")
-  if (nzchar(ref)) {
-    # This is to handle that GITHUB_REF on Github Actions return 'refs/heads/[ref]'
-    ref <- sub("^refs/heads/", "", ref)
-    return(ref)
-  } else {
-    return("master")
-  }
-}
-
-
-
-#' Download file from GitHub
-#'
-#' A github personal access token
-#' Looks in env var `GITHUB_PAT`
-#' @param download_url A github download url
-#' @param to A local file path to download to
-#' @param pat A github access token
-#' @param overwrite Should an existing file be overwritten?
-#' @keywords internal
-#' @noRd
-github_download <- function(download_url, to, pat, overwrite){
-  checkmate::assert_string(download_url, pattern = "^http(s)?://")
-  checkmate::assert_path_for_output(to, overwrite = TRUE)
-  checkmate::assert_string(pat, null.ok = TRUE)
-  checkmate::assert_flag(overwrite)
-
-  if(file.exists(to) & !overwrite) return(TRUE)
-
-  if(is.null(pat)) {
-    ret <- httr::GET(download_url, httr::write_disk(to, overwrite = overwrite))
-  } else {
-    ret <- httr::GET(download_url, httr::add_headers(c("Authorization" = paste0("token ", pat))), httr::write_disk(to, overwrite = overwrite))
-  }
-  httr::http_error(ret)
-  httr::status_code(ret) == 200L
-}
-
-
-#' @noRd
-#' @rdname pdb_cache_dir
-#' @keywords internal
-pdb_cache_dir.pdb_github <- function(pdb, path, ...){
-  pat <- github_pat(pdb)
-  ghp <- gh::gh(github_path(pdb, type = "contents", path = path), .token = pat)
-  download_urls <- unlist(lapply(ghp, FUN = function(x) x$download_url))
-  fns <- unlist(lapply(ghp, FUN = function(x) x$name))
-  message("Downloading github content...")
-  for(i in seq_along(download_urls)){
-    to <- pdb_cache_path(pdb = pdb, path = file.path(path, fns[i]))
-    github_download(download_url = download_urls[i], to = to, pat = pat, overwrite = FALSE)
-  }
-  message("Done.")
-}
diff --git a/rpackage/R/posterior.R b/rpackage/R/posterior.R
deleted file mode 100644
index 57ca560a..00000000
--- a/rpackage/R/posterior.R
+++ /dev/null
@@ -1,78 +0,0 @@
-#' Access a posterior in the posterior database
-#'
-#' @param x a posterior name that exist in the posterior database
-#' @param pdb a \code{pdb} posterior database object.
-#' @param ... currently not in use.
-#' @export
-posterior <- function(x, pdb = pdb_default(), ...) {
-  UseMethod("posterior")
-}
-
-#' @rdname posterior
-#' @export
-posterior.character <- function(x, pdb = pdb_default(), ...) {
-  checkmate::assert_string(x)
-  checkmate::assert_class(pdb, "pdb")
-  x <- handle_aliases(x, type = "posteriors", pdb)
-  po <- read_info_json(x, "posteriors", pdb)
-  pdb(po) <- pdb
-  class(po) <- "pdb_posterior"
-  po$model_info <- read_model_info(po)
-  po$data_info <- read_data_info(po)
-  assert_pdb_posterior(po)
-  po
-}
-
-#' @rdname posterior
-#' @export
-posterior.list <- function(x, pdb = pdb_default(), ...) {
-  class(x) <- "pdb_posterior"
-  if(!is.null(x$pdb_model_code) & !is.null(x$pdb_data)){
-    # We setup the posterior object from a data and model object
-    mci <- info(x$pdb_model_code)
-    di <- info(x$pdb_data)
-    x$name <- paste0(di$name, "-", mci$name)
-    x$model_name <- mci$name
-    x$data_name <- di$name
-    x$model_info <- mci
-    x$data_info <- di
-    x$pdb_model_code <- NULL
-    x$pdb_data <- NULL
-  }
-  pdb(x) <- pdb
-  assert_pdb_posterior(x)
-  x
-}
-
-#' @rdname posterior
-#' @export
-pdb_posterior <- posterior
-
-#' @export
-print.pdb_posterior <- function(x, ...) {
-  cat0("Posterior (", x$name, ")\n\n")
-  print(x$data_info)
-  cat0("\n")
-  print(x$model_info)
-  invisible(x)
-}
-
-assert_pdb_posterior <- function(x) {
-  checkmate::assert_class(x, "pdb_posterior")
-  checkmate::assert_list(x)
-  must.include <- c(
-    "name", "model_name", "data_name", "reference_posterior_name", "dimensions",
-    "model_info", "data_info",
-    "added_by", "added_date"
-  )
-  checkmate::assert_names(names(x), must.include = must.include)
-  checkmate::assert_list(x$dimensions)
-  checkmate::assert_named(x$dimensions)
-  checkmate::assert_class(x$added_date, "Date")
-  checkmate::assert_class(x$data_info$added_date, "Date")
-  checkmate::assert_class(x$model_info$added_date, "Date")
-  checkmate::assert_list(x$model_info, min.len = 1)
-
-  checkmate::assert_class(pdb(x), "pdb")
-  invisible(x)
-}
diff --git a/rpackage/R/reference_posterior.R b/rpackage/R/reference_posterior.R
deleted file mode 100644
index 856bb491..00000000
--- a/rpackage/R/reference_posterior.R
+++ /dev/null
@@ -1,294 +0,0 @@
-#' Reference posterior information
-#'
-#' @details
-#' Reference posterior information on how, when and by whom
-#' the reference posterior was computed.
-#'
-#' @param x a \code{posterior} object to access the reference posterior for.
-#' @param pdb a \code{pdb} posterior database connection.
-#' @param type Type of reference posterior [draws] or [summary_statistic].
-#' @param ... Currently not used.
-#'
-#' @seealso reference_posterior_draws
-#'
-#' @export
-reference_posterior_info <- function(x, type, pdb = pdb_default(), ...) {
-  UseMethod("reference_posterior_info")
-}
-
-#' @rdname reference_posterior_info
-#' @export
-pdb_reference_posterior_info <- reference_posterior_info
-
-#' @rdname reference_posterior_info
-#' @export
-reference_posterior_draws_info <- function(x, pdb = pdb_default(), ...) {
-  reference_posterior_info(x, type = "draws", pdb = pdb)
-}
-
-#' @rdname reference_posterior_info
-#' @export
-pdb_reference_posterior_draws_info <- reference_posterior_draws_info
-
-
-#' @rdname reference_posterior_info
-#' @export
-reference_posterior_info.pdb_posterior <- function(x, type, ...) {
-  read_reference_posterior_info(x = x$reference_posterior_name, type = type, pdb = pdb(x))
-}
-
-#' @rdname reference_posterior_info
-#' @export
-reference_posterior_info.character <- function(x, type, pdb = pdb_default(), ...) {
-  reference_posterior_info(x = posterior(x, pdb), type = type)
-}
-
-#' @rdname reference_posterior_info
-#' @export
-reference_posterior_info.list <- function(x, type = NULL, pdb = NULL, ...) {
-  class(x) <- "pdb_reference_posterior_info"
-  assert_reference_posterior_info(x)
-  x
-}
-
-
-#' Read in reference_posterior_info json object
-#' @param x a data, model or posterior name
-#' @param pdb a posterior db object to access the info json from
-#' @param type Type of reference posterior [draws] or sufficient statistic of interst, such as the means.
-#' @noRd
-#' @keywords internal
-read_reference_posterior_info <- function(x, type, pdb = NULL, ...) {
-  if(is.null(x)) stop("There is currently no reference posterior for this posterior.")
-  type_path <- type
-  if(type %in% supported_summary_statistic_types()) type_path <- paste("summary_statistics", type, sep = "/")
-  reference_posterior_info <- read_info_json(x, path = paste0("reference_posteriors/", type_path, "/info"), pdb = pdb, ...)
-  class(reference_posterior_info) <- "pdb_reference_posterior_info"
-  assert_reference_posterior_info(reference_posterior_info)
-  reference_posterior_info
-}
-
-
-
-#' Read reference_posterior_draws json object
-#' @param x a data, model or posterior name
-#' @param pdb a posterior db object to access the info json from
-#' @param ... further arguments. Currently not used.
-#' @noRd
-#' @keywords internal
-read_reference_posterior_draws <- function(x, pdb, ...) {
-  checkmate::assert_string(x, null.ok = TRUE)
-  if(is.null(x)) stop("There is currently no reference posterior for this posterior.", call. = FALSE)
-  checkmate::assert_class(pdb, classes = "pdb")
-
-  rpfp <- pdb_cached_local_file_path(pdb, file.path("reference_posteriors", "draws", "draws", paste0(x, ".json")), unzip = TRUE)
-  rpd <- jsonlite::read_json(rpfp, simplifyVector = FALSE)
-  rpd <- lapply(rpd, FUN = function(X) lapply(X, as.numeric))
-  rpd <- posterior::as_draws_list(rpd)
-  names(rpd) <- NULL
-  info(rpd) <- reference_posterior_draws_info(x, pdb)
-  pdb(rpd) <- pdb
-  class(rpd) <- c("pdb_reference_posterior_draws", class(rpd))
-  assert_reference_posterior_draws(rpd)
-  rpd
-}
-
-#' Extract data for posterior
-#'
-#' @inheritParams model_code_file_path
-#' @export
-reference_posterior_draws_file_path <- function(x, ...) {
-  UseMethod("reference_posterior_draws_file_path")
-}
-
-#' @rdname reference_posterior_draws_file_path
-#' @export
-reference_posterior_draws_file_path.pdb_posterior <- function(x, ...) {
-  if(is.null(x$reference_posterior_name)) stop2("There is currently no gold standard for this posterior.")
-  reference_posterior_draws_file_path(x$reference_posterior_name, pdb = pdb(x))
-}
-
-#' @rdname reference_posterior_draws_file_path
-#' @export
-reference_posterior_draws_file_path.character <- function(x, pdb = pdb_default(), ...) {
-  checkmate::assert_string(x)
-  fp <- paste0("reference_posteriors/draws/draws/", x, ".json")
-  rpfp <- pdb_cached_local_file_path(pdb, path = fp, unzip = TRUE)
-  checkmate::assert_file_exists(rpfp)
-  rpfp
-}
-
-#' @rdname reference_posterior_draws_file_path
-#' @export
-reference_posterior_draws_file_path.pdb_reference_posterior_info <- function(x, pdb = pdb_default(), ...) {
-  reference_posterior_draws_file_path(x$name, pdb, ...)
-}
-
-
-#' Reference Posterior draws and summary statistics
-#' @param x a [posterior] object or a posterior name.
-#' @param pdb a [pdb] object (if [x] is a posterior name)
-#' @param info a [pdb_reference_posterior_info] object
-#' @param ... further arguments supplied to specific methods.
-#' @return a [pdb_reference_posterior] object.
-#' @export
-reference_posterior_draws <- function(x, ...){
-  UseMethod("reference_posterior_draws")
-}
-
-#' @rdname reference_posterior_draws
-#' @export
-pdb_reference_posterior_draws <- reference_posterior_draws
-
-#' @rdname reference_posterior_draws
-#' @export
-reference_posterior_draws.character <- function(x, pdb = pdb_default(), ...){
-  reference_posterior_draws(posterior(x, pdb = pdb))
-}
-
-#' @rdname reference_posterior_draws
-#' @export
-reference_posterior_draws.pdb_posterior <- function(x, ...){
-  read_reference_posterior_draws(x = x$reference_posterior_name, pdb = pdb(x))
-}
-
-#' @rdname reference_posterior_draws
-#' @export
-reference_posterior_draws.pdb_reference_posterior_info <- function(x, pdb = pdb_default(), ...){
-  read_reference_posterior_draws(x = x$name, pdb = pdb)
-}
-
-#' @rdname reference_posterior_draws
-#' @export
-reference_posterior_draws.draws_list <- function(x, info, ...){
-  checkmate::assert_class(info, "pdb_reference_posterior_info")
-  x <- posterior::as_draws_list(posterior::as_draws(x))
-  names(x) <- NULL
-  for(i in seq_along(x)){
-    x[[i]]$lp__ <- NULL
-  }
-
-  attr(x, "info") <- info
-  class(x) <- c("pdb_reference_posterior_draws", class(x))
-  assert_reference_posterior_draws(x)
-  x
-}
-
-
-#' @rdname reference_posterior_draws
-#' @export
-assert_reference_posterior_draws <- function(x){
-  checkmate::assert_class(x, c("pdb_reference_posterior_draws", "draws_list"))
-
-  checkmate::assert_class(info(x), c("pdb_reference_posterior_info"))
-
-  # Assert named chains has the same parameter names
-  par_names <- lapply(x, names)
-  for(i in seq_along(par_names)){
-    checkmate::assert_true(identical(par_names[[1]],par_names[[i]]))
-  }
-
-  # Assert chains don't have names
-  checkmate::assert_null(names(x))
-}
-
-#' Assert a [pdb_reference_posterior_info] object
-#' @param x a an object to assert is a [pdb_reference_posterior_info] object.
-#' @keywords internal
-assert_reference_posterior_info <- function(x){
-  checkmate::assert_class(x, "pdb_reference_posterior_info")
-  checkmate::assert_names(names(x), identical.to = c("name", "inference", "diagnostics", "checks_made", "comments", "added_by", "added_date", "versions"))
-  checkmate::assert_string(x$name)
-
-  checkmate::assert_true(x$inference$method %in% c("stan_sampling", "analytical"))
-  checkmate::assert_list(x$inference$method_arguments)
-
-  if(!is.null(x$diagnostics)){
-    checkmate::assert_names(names(x$diagnostics),
-                            must.include = c("ndraws"))
-    if(x$inference$method == "stan_sampling"){
-      checkmate::assert_names(names(x$diagnostics),
-                              must.include = c("nchains",
-                                               "effective_sample_size_bulk",
-                                               "effective_sample_size_tail",
-                                               "r_hat",
-                                               "divergent_transitions",
-                                               "expected_fraction_of_missing_information"))
-    }
-  }
-  if(!is.null(x$checks_made)){
-    checkmate::assert_named(x$checks_made)
-  }
-
-  checkmate::assert_string(x$added_by)
-  checkmate::assert_date(x$added_date)
-  if(!is.null(x$versions)){
-    checkmate::assert_names(names(x$versions), subset.of = c("rstan_version", "r_Makevars", "r_version", "r_session", "r_summary_statistic"))
-    if(!is.null(x$versions$rstan_version)){
-      checkmate::assert_names(names(x$versions), must.include = c("rstan_version", "r_Makevars", "r_version", "r_session"))
-    }
-    for(i in seq_along(x$versions)){
-      checkmate::assert_string(x$versions[[i]])
-    }
-  }
-}
-
-
-#' Subset a [pdb_reference_posterior_draws] object
-#' @param x a [pdb_reference_posterior_draws] to subest
-#' @param variable parameter names to subset.
-#' @param ... Further arguments (not used).
-#' @export
-subset.pdb_reference_posterior_draws <- function(x, variable, ...){
-  requireNamespace("posterior")
-  attrs <- attributes(x)
-  class(x) <- class(x)[-1]
-  x <- subset(x, variable = variable, regex = FALSE)
-  attributes(x) <- attrs
-  x
-}
-
-
-#' @export
-print.pdb_reference_posterior_draws <- function(x, ...) {
-  cat0("Reference Posterior: ", info(x)$name, "\n")
-  NextMethod("print")
-}
-
-#' @export
-summary.pdb_reference_posterior_draws <- function(object, ...) {
-  cat0("Reference Posterior: ", info(object)$name, "\n")
-  print(posterior::summarise_draws(object))
-}
-
-
-#' @export
-print.pdb_reference_posterior_info <- function(x, ...) {
-  cat0("Posterior: ", x$name, "\n")
-  cat0("Method: ", x$inference$method, " (", x$versions[[1]], ")\n")
-  cat0("Arguments:\n")
-  print_list(x$inference$method_arguments)
-}
-
-supported_reference_posterior_types <- function() c("draws", supported_summary_statistic_types())
-
-#' Thin draws to reduce their size and autocorrelation of the chains.
-#'
-#' @description Thin [pdb_reference_posterior_draws] objects to reduce their size and autocorrelation of the chains.
-#'
-#' @param x An R object for which the methods are defined.
-#' @param thin A positive integer specifying the period for selecting draws.
-#' @param ... Arguments passed to individual methods (if applicable).
-#'
-#' @return
-#' A thinned [pdb_reference_posterior_draws] object.
-#'
-#' @export
-thin_draws.pdb_reference_posterior_draws <- function(x, thin, ...){
-  rpdi <- info(x)
-  class(x) <- class(x)[-1]
-  x <- posterior::thin_draws(x, thin, ...)
-  x <- pdb_reference_posterior_draws(x, rpdi)
-  checkmate::assert_class(x, "pdb_reference_posterior_draws")
-  x
-}
diff --git a/rpackage/R/remove_pdb.R b/rpackage/R/remove_pdb.R
deleted file mode 100644
index e32381d8..00000000
--- a/rpackage/R/remove_pdb.R
+++ /dev/null
@@ -1,96 +0,0 @@
-
-#' Remove objects from local pdb
-#'
-#' @description a function to simplify removing object from a local pdb.
-#'
-#' @param x an object to remove to the pdb.
-#' @param pdb the pdb to remove from. Currently only a local pdb.
-#' @param type supported reference posterior types.
-#' @param remove_info should the information JSON be removed as well?
-#' @param ... further arguments supplied to methods.
-#'
-#' @export
-remove_pdb <- function(x, pdb, ...){
-  checkmate::assert_class(pdb, "pdb_local")
-  UseMethod("remove_pdb")
-}
-
-#' @rdname remove_pdb
-#' @export
-remove_pdb.character <- function(x, pdb, ...){
-  checkmate::assert_file_exists(x)
-  file.remove(x)
-}
-
-#' @rdname remove_pdb
-#' @export
-remove_pdb.pdb_data <- function(x, pdb, remove_info = TRUE,...){
-  fn <- paste0(info(x)$name, ".json.zip")
-  fp <- pdb_file_path(pdb, "data", "data", fn)
-  remove_pdb(fp, pdb)
-  if(remove_info) remove_pdb(info(x), pdb)
-}
-
-#' @rdname remove_pdb
-#' @export
-remove_pdb.pdb_data_info <- function(x, pdb, ...){
-  fn <- paste0(x$name, ".info.json")
-  fp <- pdb_file_path(pdb, "data", "info", fn)
-  remove_pdb(fp, pdb)
-}
-
-#' @rdname remove_pdb
-#' @export
-remove_pdb.pdb_model_code <- function(x, pdb, remove_info = TRUE, ...){
-  fw <- framework(x)
-  fn <- paste0(info(x)$name, ".", fw)
-  fp <- pdb_file_path(pdb, "models", fw, fn)
-  remove_pdb(fp, pdb)
-  if(remove_info) remove_pdb(info(x), pdb)
-}
-
-#' @rdname remove_pdb
-#' @export
-remove_pdb.pdb_model_info <- function(x, pdb, ...){
-  fn <- paste0(x$name, ".info.json")
-  fp <- pdb_file_path(pdb, "models", "info", fn)
-  remove_pdb(fp, pdb)
-}
-
-#' @rdname remove_pdb
-#' @export
-remove_pdb.pdb_posterior <- function(x, pdb, ...){
-  fn <- paste0(x$name, ".json")
-  fp <- pdb_file_path(pdb, "posteriors", fn)
-  remove_pdb(fp, pdb)
-}
-
-#' @rdname remove_pdb
-#' @export
-remove_pdb.pdb_reference_posterior_draws <- function(x, pdb, remove_info = TRUE, ...){
-  fn <- paste0(info(x)$name, ".json.zip")
-  fp <- pdb_file_path(pdb, "reference_posteriors", "draws", "draws", fn)
-  remove_pdb(fp, pdb)
-  if(remove_info) remove_pdb(info(x), type = "draws", pdb)
-}
-
-#' @rdname remove_pdb
-#' @export
-remove_pdb.pdb_reference_posterior_info <- function(x, pdb, type, ...){
-  checkmate::assert_choice(type, choices = supported_reference_posterior_types())
-  fn <- paste0(x$name, ".info.json")
-  type_path <- type
-  if(type %in% supported_summary_statistic_types()) type_path <- paste("summary_statistics", type, sep = "/")
-  fp <- pdb_file_path(pdb, "reference_posteriors", type_path, "info", fn)
-  remove_pdb(fp, pdb)
-}
-
-#' @rdname remove_pdb
-#' @export
-remove_pdb.pdb_reference_posterior_summary_statistic <- function(x, pdb, remove_info = TRUE, ...){
-  fn <- paste0(info(x)$name, ".json")
-  sst <- summary_statistic_type(x)
-  fp <- pdb_file_path(pdb, "reference_posteriors", "summary_statistics", sst, sst, fn)
-  remove_pdb(fp, pdb)
-  if(remove_info) remove_pdb(info(x), type = sst, pdb)
-}
diff --git a/rpackage/R/run_stan.R b/rpackage/R/run_stan.R
deleted file mode 100644
index 311d1edc..00000000
--- a/rpackage/R/run_stan.R
+++ /dev/null
@@ -1,27 +0,0 @@
-#' Run Stan on a posterior
-#'
-#' @description
-#' Run Stan on a posterior
-#'
-#' @param x a [pdb_posterior] object.
-#' @param stan_args Arguments supplied to [rstan::stan] to compute the posterior
-#' @param ... currently not in use.
-#'
-run_stan <- function(x, stan_args, ...){
-  UseMethod("run_stan")
-}
-
-#' @rdname run_stan
-run_stan.pdb_posterior <- function(x, stan_args, ...){
-  checkmate::assert_list(stan_args)
-  checkmate::assert_names(names(stan_args), disjunct.from = c("model_name", "model_code", "data"))
-  sa <- list(model_name = x$name,
-             model_code = stan_code(x),
-             data = stan_data(x))
-  sa <- c(sa, stan_args)
-  stan_object <- do.call(rstan::stan, sa)
-
-  # Stan model codes are stored locally (seem to be a bug)
-  stan_object@model_name <- x$name
-  stan_object
-}
diff --git a/rpackage/R/summary_statistic.R b/rpackage/R/summary_statistic.R
deleted file mode 100644
index 37b1e3f5..00000000
--- a/rpackage/R/summary_statistic.R
+++ /dev/null
@@ -1,152 +0,0 @@
-
-supported_summary_statistic_types <- function() c("mean", "sd")
-
-summary_statistic_class_name <- function(type){
-  checkmate::assert_subset(type, supported_summary_statistic_types())
-  paste0("pdb_summary_statistic_", type)
-}
-
-supported_summary_statistic_classes <- function() {
-  summary_statistic_class_name(supported_summary_statistic_types())
-}
-
-
-#' Extract the type of summary statistic
-#'
-#' @param x a [pdb_reference_posterior_summary_statistic]
-#'
-summary_statistic_type <- function(x){
-  checkmate::assert_class(x, "pdb_reference_posterior_summary_statistic")
-  sst <- supported_summary_statistic_types()
-  bool <- logical(length(sst))
-  for(i in seq_along(sst)){
-    bool[i] <- grepl(x = class(x)[1], pattern = sst[i])
-  }
-  checkmate::assert_true(sum(bool) == 1L)
-  sst[bool]
-}
-
-
-#' @export
-print.pdb_reference_posterior_summary_statistic <- function(x, ...) {
-  cat(paste0("Posterior: ",  info(x)$name, "\n\n"))
-  attr(x, "info") <- NULL
-  attr(x, "pdb") <- NULL
-  x <- unclass(x)
-  print(x)
-}
-
-
-assert_reference_posterior_summary_statistic <- function(x){
-  checkmate::assert_class(x, c("pdb_reference_posterior_summary_statistic"))
-  sst <- summary_statistic_type(x)
-
-  checkmate::assert_names(names(x)[1], identical.to = c("names"))
-  checkmate::assert_true(all(grepl(names(x)[-1], pattern = sst)))
-  checkmate::assert_true(any(grepl(names(x)[-1], pattern = paste0("mcse_", sst))))
-
-  checkmate::assert_character(x[[1]])
-  for(j in 2:length(x)){
-    checkmate::assert_numeric(x[[j]])
-  }
-}
-
-
-#' Reference posterior summary statistics
-#'
-#' @param x a [posterior] object or a posterior name.
-#' @param pdb a [pdb] object (if [x] is a posterior name)
-#' @param info a [pdb_reference_posterior_info] object
-#' @param type the type of summary statistic to extract
-#' @param ... further arguments supplied to specific methods.
-#' @return a [pdb_reference_posterior_summary_statistic] object.
-#' @export
-reference_posterior_summary_statistic <- function(x, ...){
-  UseMethod("reference_posterior_summary_statistic")
-}
-
-#' @rdname reference_posterior_summary_statistic
-#' @export
-pdb_reference_posterior_summary_statistic <- reference_posterior_summary_statistic
-
-#' @rdname reference_posterior_summary_statistic
-#' @export
-reference_posterior_summary_statistic.character <- function(x, pdb = pdb_default(), type, ...){
-  reference_posterior_summary_statistic(posterior(x, pdb = pdb), type)
-}
-
-#' @rdname reference_posterior_summary_statistic
-#' @export
-reference_posterior_summary_statistic.pdb_posterior <- function(x, type, ...){
-  read_reference_posterior_summary_statistic(x = x$reference_posterior_name, pdb = pdb(x), type = type)
-}
-
-#' @rdname reference_posterior_summary_statistic
-#' @export
-reference_posterior_summary_statistic.pdb_reference_posterior_info <- function(x, pdb = pdb_default(), type, ...){
-  read_reference_posterior_summary_statistic(x = x$name, pdb = pdb, type = type)
-}
-
-#' @rdname reference_posterior_summary_statistic
-#' @export
-reference_posterior_summary_statistic.list <- function(x, info, type, ...){
-  checkmate::assert_class(info, "pdb_reference_posterior_info")
-  checkmate::assert_choice(type, supported_summary_statistic_types())
-  attr(x, "info") <- info
-  class(x) <- c(summary_statistic_class_name(type), "pdb_reference_posterior_summary_statistic", "list")
-  assert_reference_posterior_summary_statistic(x)
-  x
-}
-
-
-#' Read reference_posterior_summary_statistic json object
-#' @param x a data, model or posterior name
-#' @param pdb a posterior db object to access the info json from
-#' @param ... further arguments. Currently not used.
-#' @noRd
-#' @keywords internal
-read_reference_posterior_summary_statistic <- function(x, pdb, type, ...) {
-  checkmate::assert_string(x, null.ok = TRUE)
-  checkmate::assert_choice(type, supported_summary_statistic_types())
-
-  if(is.null(x)) stop("There is currently no reference posterior for this posterior.", call. = FALSE)
-  checkmate::assert_class(pdb, classes = "pdb")
-
-  rpssfp <- pdb_cached_local_file_path(pdb, file.path("reference_posteriors", "summary_statistics", type, type,  paste0(x, ".json")), unzip = FALSE)
-  rpssd <- jsonlite::read_json(rpssfp, simplifyVector = TRUE)
-
-  rpssi <- reference_posterior_info(x, pdb, type = type)
-  rpss <- reference_posterior_summary_statistic(rpssd, rpssi, type)
-
-  assert_reference_posterior_summary_statistic(rpss)
-  rpss
-}
-
-
-#' @rdname reference_posterior_summary_statistic
-#' @export
-reference_posterior_summary_statistics <- function(x, ...){
-  UseMethod("reference_posterior_summary_statistics")
-}
-
-#' @rdname reference_posterior_summary_statistic
-#' @export
-pdb_reference_posterior_summary_statistics <- reference_posterior_summary_statistics
-
-#' @rdname reference_posterior_summary_statistic
-#' @export
-reference_posterior_summary_statistics.character <- function(x, pdb = pdb_default(), ...){
-  reference_posterior_summary_statistics(x = posterior(x, pdb = pdb))
-}
-
-#' @rdname reference_posterior_summary_statistic
-#' @export
-reference_posterior_summary_statistics.pdb_posterior <- function(x, ...){
-  ssst <- supported_summary_statistic_types()
-  ss_list <- list()
-  for(i in seq_along(ssst)){
-    ss_list[[ssst[i]]] <- try(read_reference_posterior_summary_statistic(x = x$reference_posterior_name, pdb = pdb(x), type = ssst[i]), silent = TRUE)
-    if(inherits(ss_list[[ssst[i]]], "try-error")) ss_list[[ssst[i]]] <- NULL
-  }
-  ss_list
-}
diff --git a/rpackage/R/tibble.R b/rpackage/R/tibble.R
deleted file mode 100644
index 10aa3ec6..00000000
--- a/rpackage/R/tibble.R
+++ /dev/null
@@ -1,64 +0,0 @@
-#' Create Posterior Database tibbles
-#'
-#' @details Generates a tibble data frame of all posteriors
-#' in the database and their side information
-#'
-#' @param pdb a \code{pdb} object.
-#' @param ... further arguments to supply to \code{dplyr::filter()}
-#' @export
-posteriors_tbl_df <- function(pdb = pdb_default(), ...){
-  pdb_tibble(pdb, path = "posteriors")
-}
-
-models_tbl_df <- function(pdb = pdb_default(), ...){
-  pdb_tibble(pdb, path = "models/info")
-}
-
-data_tbl_df <- function(pdb = pdb_default(), ...){
-  pdb_tibble(pdb, path = "data/info")
-}
-
-#' @noRd
-#' @keywords internal
-pdb_tibble <- function(pdb, path, ...){
-  checkmate::assert_class(pdb, "pdb")
-  checkmate::assert_choice(path, c("posteriors", "models/info", "data/info"))
-
-  pdb_cache_dir(pdb, path)
-  fnms <- pdb_list_files_in_cache(pdb, path, file_ext = FALSE)
-
-  obj_list <- list()
-  for(i in seq_along(fnms)) {
-    x <- read_info_json(fnms[i], path = path, pdb = pdb)
-    obj_list[[i]] <- as.data.frame(x)
-  }
-  dat <- do.call(rbind, obj_list)
-  dplyr::as_tibble(dat)
-}
-
-
-#' Coerce a [pdb_posterior] to a Data Frame
-#'
-#' @details The dataframe will consist of one row per keyword.
-#'
-#' @param x a [pdb_posterior] object.
-#' @param row.names NULL or a character vector giving the row names for the data frame. Missing values are not allowed.
-#' @param ... further arguments to \code{as.data.frame} for a list.
-#' @param optional Not used.
-#' @export
-as.data.frame.pdb_posterior <- function(x, row.names = NULL, optional = FALSE, ...){
-  kws <- unlist(x$keywords)
-  elements <- c("name", "model_name", "reference_posterior_name", "data_name", "added_by", "added_date")
-  if(is.null(x$reference_posterior_name)) x$reference_posterior_name <- "NULL"
-  df <- as.data.frame(x[elements], stringsAsFactors = FALSE, ...)[rep(1, max(1,length(kws))), ]
-  if(length(kws) == 0){
-    df$keywords <- ""
-  } else {
-    df$keywords <- kws
-  }
-  rownames(df) <- row.names
-  df
-}
-#' @rdname as.data.frame.pdb_posterior
-#' @export
-as.data.frame.pdb_posteriors <- as.data.frame.pdb_posterior
diff --git a/rpackage/R/utils.R b/rpackage/R/utils.R
deleted file mode 100644
index 45fde5be..00000000
--- a/rpackage/R/utils.R
+++ /dev/null
@@ -1,39 +0,0 @@
-remove_file_extension <- function(x) {
-  checkmate::assert_character(x, pattern = "\\..{1,5}$")
-  unlist(lapply(strsplit(x, "\\."), function(x) x[1]))
-}
-
-get_file_extension <- function(x) {
-  checkmate::assert_character(x, pattern = "\\..{1,5}$")
-  unlist(lapply(strsplit(x, "\\."), function(x) x[2]))
-}
-
-stop2 <- function(...) {
-  stop(..., call. = FALSE)
-}
-
-warning2 <- function(...) {
-  warning(..., call. = FALSE)
-}
-
-# cat with without separating elements
-cat0 <- function(..., file = "", fill = FALSE, labels = NULL, append = FALSE) {
-  cat(..., sep = "", file = file, fill = fill, labels = labels, append = append)
-}
-
-# file.path that remove null elementd
-file.path0 <- function(...){
-  arg <- list(...)
-  do.call(file.path, arg[!unlist(lapply(arg, FUN = is.null))])
-}
-
-# Print a list as a yaml recursively
-print_list <- function(x, pad = "  "){
-  for(i in seq_along(x)){
-    if(is.list(x[[i]])) {
-      print_list(x[[i]], pad = paste0(pad, pad))
-    } else {
-      cat0(pad, names(x)[i], ": ", x[[i]], "\n")
-    }
-  }
-}
diff --git a/rpackage/R/utils_reference_posterior.R b/rpackage/R/utils_reference_posterior.R
deleted file mode 100644
index eb337397..00000000
--- a/rpackage/R/utils_reference_posterior.R
+++ /dev/null
@@ -1,170 +0,0 @@
-#' Check that reference posterior draws follows the
-#' reference posterior summary definition.
-#'
-#' @param x a posterior name, posterior object or reference_posterior_draws object
-#' @param ... currently not used.
-#'
-#' @export
-check_summary_statistics_draws <- function(x, ...){
-  UseMethod("check_summary_statistics_draws")
-}
-
-#' @rdname check_summary_statistics_draws
-#' @export
-check_summary_statistics_draws.character <- function(x, ...){
-  x <- pdb_posterior(x, ...)
-  check_summary_statistics_draws(x)
-}
-
-#' @rdname check_summary_statistics_draws
-#' @export
-check_summary_statistics_draws.pdb_posterior <- function(x, ...){
-  x <- reference_posterior_draws(x)
-  check_summary_statistics_draws(x)
-}
-
-#' @rdname check_summary_statistics_draws
-#' @export
-check_summary_statistics_draws.pdb_reference_posterior_draws <- function(x, ...){
-  assert_reference_posterior_draws(x)
-  rpi <- info(x)
-  assert_reference_posterior_info(rpi)
-
-  tst <- list()
-
-  # Assert that there is exactly 10000 draws
-  checkmate::assert_true(rpi$diagnostics$ndraws >= 10000)
-  tst$ndraws_is_gte_10k <- TRUE
-
-  if(rpi$inference$method == "stan_sampling"){
-    # Assert that at least 4 chains has been used
-    checkmate::assert_true(rpi$diagnostics$nchains >= 4)
-    tst$nchains_is_gte_4 <- TRUE
-
-    # Assert the effective sample size is correct/within bounds
-    ess_bnds <- ess_bounds(x)
-    checkmate::assert_numeric(rpi$diagnostics$effective_sample_size_bulk, lower = ess_bnds$ess_bulk[2], upper = ess_bnds$ess_bulk[1])
-    checkmate::assert_numeric(rpi$diagnostics$effective_sample_size_tail, lower = ess_bnds$ess_tail[2], upper = ess_bnds$ess_tail[1])
-    tst$ess_within_bounds <- TRUE
-
-    # Assert all Rhat < 1.01
-    checkmate::assert_numeric(rpi$diagnostics$r_hat, upper = 1.01)
-    tst$r_hat_below_1_01 <- TRUE
-
-    # Assert that the EFMI is larger than 0.2
-    checkmate::assert_numeric(rpi$diagnostics$expected_fraction_of_missing_information, lower = 0.2)
-    tst$efmi_above_0_2 <- TRUE
-
-  }
-
-  # Add checks made to reference posterior
-  rpi$checks_made <- tst
-
-  # Add the rp information
-  assert_reference_posterior_info(x = rpi)
-  attr(x, "info") <- rpi
-
-  # Check the reference posterior
-  assert_reference_posterior_draws(x)
-  assert_checked_summary_statistics_draws(x)
-  invisible(x)
-}
-
-
-#' Check that reference posterior draws follows the
-#' reference posterior draws definition.
-#'
-#' @param x a posterior name, posterior object or reference_posterior_draws object
-#' @param ... currently not used.
-#'
-#' @export
-check_reference_posterior_draws <- function(x, ...){
-  UseMethod("check_reference_posterior_draws")
-}
-
-#' @rdname check_reference_posterior_draws
-#' @export
-check_reference_posterior_draws.character <- function(x, ...){
-  x <- pdb_posterior(x, ...)
-  check_reference_posterior_draws(x)
-}
-
-#' @rdname check_reference_posterior_draws
-#' @export
-check_reference_posterior_draws.pdb_posterior <- function(x, ...){
-  x <- reference_posterior_draws(x)
-  check_reference_posterior_draws(x)
-}
-
-#' @rdname check_reference_posterior_draws
-#' @export
-check_reference_posterior_draws.pdb_reference_posterior_draws <- function(x, ...){
-  assert_reference_posterior_draws(x)
-  rpi <- info(x)
-  assert_reference_posterior_info(rpi)
-
-  tst <- list()
-
-  # Assert that there is exactly 10000 draws
-  checkmate::assert_true(rpi$diagnostics$ndraws == 10000)
-  tst$ndraws_is_10k <- TRUE
-
-  if(rpi$inference$method == "stan_sampling"){
-    # Assert that at least 4 chains has been used
-    checkmate::assert_true(rpi$diagnostics$nchains >= 4)
-    tst$nchains_is_gte_4 <- TRUE
-
-    # Assert the effective sample size is correct/within bounds
-    ess_bnds <- ess_bounds(x)
-    checkmate::assert_numeric(rpi$diagnostics$effective_sample_size_bulk, lower = ess_bnds$ess_bulk[2], upper = ess_bnds$ess_bulk[1])
-    checkmate::assert_numeric(rpi$diagnostics$effective_sample_size_tail, lower = ess_bnds$ess_tail[2], upper = ess_bnds$ess_tail[1])
-    tst$ess_within_bounds <- TRUE
-
-    # Assert all Rhat < 1.01
-    checkmate::assert_numeric(rpi$diagnostics$r_hat, upper = 1.01)
-    tst$r_hat_below_1_01 <- TRUE
-
-    # Assert that the EFMI is larger than 0.2
-    checkmate::assert_numeric(rpi$diagnostics$expected_fraction_of_missing_information, lower = 0.2)
-    tst$efmi_above_0_2 <- TRUE
-
-  }
-
-  # Add checks made to reference posterior
-  rpi$checks_made <- tst
-
-  # Add the rp information
-  assert_reference_posterior_info(x = rpi)
-  attr(x, "info") <- rpi
-
-  # Check the reference posterior
-  assert_reference_posterior_draws(x)
-  assert_checked_reference_posterior_draws(x)
-  invisible(x)
-}
-
-#' Compute ESS tail and bulk bounds
-#'
-#' @details Compute the bounds for ESS tail and bulk based on 100 000
-#' simulated ESS computations.
-#'
-#' @param x a [pdb_reference_posterior_draws] object.
-#' @param p the joint probability for independent ESS estimators.
-#' @keywords internal
-ess_bounds <- function(x){
-  checkmate::assert_class(x, "draws")
-
-  npar <- posterior::nvariables(x)
-  ndraws <- posterior::ndraws(x)
-  # We approximate ESS SD as follows (after some simulations)
-  # We then use 4 SD to check the ESSs
-  approx_ess_sd <- sqrt(7) * sqrt(ndraws)
-  bnds <- ndraws + 4 * c(approx_ess_sd, -approx_ess_sd)
-
-  #  alpha <- 1 - exp(log(p)/npar)
-  #  essb <- esst <- NULL # To mask check NOTEs
-
-  list(ess_bulk = bnds,
-       ess_tail = bnds)
-
-}
diff --git a/rpackage/R/write_pdb.R b/rpackage/R/write_pdb.R
deleted file mode 100644
index 7cc7d50e..00000000
--- a/rpackage/R/write_pdb.R
+++ /dev/null
@@ -1,94 +0,0 @@
-#' Write objects to pdb
-#'
-#' @description a function to simplify writing to a local pdb.
-#'
-#' @param x an object to write to the pdb.
-#' @param pdb the pdb to write to. Currently only a local pdb.
-#' @param overwrite overwrite existing file?
-#' @param type supported reference posterior types.
-#' @param ... further arguments supplied to methods.
-#' @export
-write_pdb <- function(x, pdb, overwrite = FALSE, ...){
-  checkmate::assert_class(pdb, "pdb_local")
-  UseMethod("write_pdb")
-}
-
-#' @rdname write_pdb
-#' @export
-write_pdb.pdb_reference_posterior_info <- function(x, pdb, overwrite = FALSE, type, ...){
-  checkmate::assert_choice(type, choices = supported_reference_posterior_types())
-  assert_reference_posterior_info(x)
-  class(x) <- c(class(x), "list")
-  type_path <- type
-  if(type %in% supported_summary_statistic_types()) type_path <- paste("summary_statistics", type, sep = "/")
-  write_json_to_path(x, paste("reference_posteriors", type_path, "info", sep = "/"), pdb, zip = FALSE, info = TRUE, overwrite = overwrite)
-}
-
-#' @rdname write_pdb
-#' @export
-write_pdb.pdb_reference_posterior_draws <- function(x, pdb, overwrite = FALSE, ...){
-  assert_reference_posterior_draws(x)
-  assert_checked_reference_posterior_draws(x)
-  write_pdb(info(x), pdb = pdb, overwrite = overwrite, type = "draws")
-  write_json_to_path(x, "reference_posteriors/draws/draws", pdb, zip = TRUE, info = FALSE, overwrite = overwrite)
-}
-
-#' @rdname write_pdb
-#' @export
-write_pdb.pdb_reference_posterior_summary_statistic <- function(x, pdb, overwrite = FALSE, ...){
-  assert_reference_posterior_summary_statistic(x)
-  assert_checked_summary_statistics_draws(x)
-  sstype <- summary_statistic_type(x)
-  write_pdb(info(x), pdb = pdb, overwrite = overwrite, type = sstype)
-  write_json_to_path(x, path = paste0("reference_posteriors/summary_statistics/", sstype, "/", sstype), pdb, zip = FALSE, info = FALSE, overwrite = overwrite, name = info(x)$name)
-}
-
-
-#' @rdname write_pdb
-#' @export
-write_pdb.pdb_data <- function(x, pdb, overwrite = FALSE, ...){
-  assert_data(x)
-  write_pdb(info(x), pdb = pdb, overwrite = overwrite)
-  write_json_to_path(x, "data/data", pdb, name = info(x)$name, zip = TRUE, info = FALSE, overwrite = overwrite)
-}
-
-#' @rdname write_pdb
-#' @export
-write_pdb.pdb_data_info <- function(x, pdb,  overwrite = FALSE, ...){
-  assert_data_info(x)
-  class(x) <- c(class(x), "list")
-  write_json_to_path(x, "data/info", pdb, zip = FALSE, info = TRUE, overwrite = overwrite)
-}
-
-#' @rdname write_pdb
-#' @export
-write_pdb.stanmodel <- function(x, pdb, overwrite = FALSE, ...){
-  write_stan_to_path(x = x@model_code, "models/stan", pdb, name = x@model_name, zip = FALSE, info = FALSE, overwrite = overwrite)
-}
-
-#' @rdname write_pdb
-#' @export
-write_pdb.pdb_model_code <- function(x, pdb,  overwrite = FALSE, ...){
-  assert_model_code(x)
-  write_pdb(info(x), pdb, overwrite = overwrite)
-  write_model_code_to_path(x, path = "models/", pdb = pdb, name = info(x)$name, framework = framework(x), zip = FALSE, info = FALSE, overwrite = overwrite)
-}
-
-#' @rdname write_pdb
-#' @export
-write_pdb.pdb_model_info <- function(x, pdb,  overwrite = FALSE, ...){
-  assert_model_info(x)
-  class(x) <- c(class(x), "list")
-  write_json_to_path(x, "models/info", pdb, zip = FALSE, info = TRUE, overwrite = overwrite)
-}
-
-#' @rdname write_pdb
-#' @export
-write_pdb.pdb_posterior <- function(x, pdb,  overwrite = FALSE, ...){
-  assert_pdb_posterior(x)
-  pdb(x) <- NULL
-  x$model_info <- NULL
-  x$data_info <- NULL
-  class(x) <- c(class(x), "list")
-  write_json_to_path(x, "posteriors", pdb, zip = FALSE, info = FALSE, overwrite = overwrite)
-}
diff --git a/rpackage/README.Rmd b/rpackage/README.Rmd
deleted file mode 100644
index 969640a6..00000000
--- a/rpackage/README.Rmd
+++ /dev/null
@@ -1,154 +0,0 @@
----
-output:
-  md_document:
-    variant: markdown_github
----
-
-<!-- README.md is generated from README.Rmd. Please edit that file -->
-
-The included database contains convenience functions to access data, model code and information for individual posteriors.
-
-# Installation
-
-To install the package, you can either clone this repository and run the following snippet to install the package or install the package and access it from Github directly (see below).
-
-```{r, eval = FALSE}
-remotes::install("rpackage/")
-```
-
-To install only the R package and then access the posteriors remotely, just install the package from GitHub.
-
-```{r, eval = FALSE}
-remotes::install_github("MansMeg/posteriordb", subdir = "rpackage/")
-```
-
-To load the package, just run.
-
-```{r}
-library(posteriordb)
-```
-
-# Connect to the posterior database
-
-First we create the posterior database to use, here we can use the database locally (if the repo is cloned).
-
-```{r, eval=FALSE}
-my_pdb <- pdb_local()
-```
-
-```{r, eval=TRUE, echo=FALSE}
-path <- getwd()
-x <- file.path(dirname(path), "posterior_database")
-my_pdb <- pdb_local(x)
-```
-
-
-The above code requires that your working directory is in the main folder of the cloned repository. Otherwise we can use the `path` argument.
-
-We can also simply use the github repository directly to access the data.
-
-```{r, eval=FALSE}
-my_pdb <- pdb_github()
-```
-
-Independent of the posterior database used, the following works for all.
-
-
-# Access content
-
-To list the posteriors available in the database, use `posterior_names()`.
-
-```{r}
-pos <- posterior_names(my_pdb)
-head(pos)
-```
-
-In the same fashion, we can list data and models included in the database as
-
-```{r}
-mn <- model_names(my_pdb)
-head(mn)
-
-dn <- data_names(my_pdb)
-head(dn)
-```
-
-We can also get all information on each individual posterior as a tibble with
-
-```{r}
-pos <- posteriors_tbl_df(my_pdb)
-head(pos)
-```
-
-The posterior's name is made up of the data and model fitted
-to the data. Together, these two uniquely define a posterior distribution.
-To access a posterior object we can use the model name.
-
-```{r}
-po <- posterior("eight_schools-eight_schools_centered", my_pdb)
-```
-
-From the posterior object, we can access data, model code (i.e., Stan code
-in this case) and a lot of other useful information.
-
-```{r}
-dat <- pdb_data(po)
-dat
-
-code <- stan_code(po)
-code
-```
-
-We can also access the paths to data after they have been unzipped and copied to the cache directory set in `pdb` (the R temp directory by default).
-
-```{r}
-dfp <- data_file_path(po)
-dfp
-
-scfp <- stan_code_file_path(po)
-scfp
-```
-
-We can also access information regarding the model and the data used to compute the posterior.
-
-```{r}
-data_info(po)
-model_info(po)
-```
-
-Note that the references are referencing to BibTeX items that can be found in `content/references/references.bib`.
-
-We can access most of the posterior information as a `tbl_df` using
-
-```{r}
-tbl <- posteriors_tbl_df(my_pdb)
-head(tbl)
-```
-
-In addition, we can also access a list of posteriors with `filter_posteriors()`. The filtering function follows dplyr filter semantics based on the posterior tibble.
-
-```{r}
-pos <- filter_posteriors(pdb = my_pdb, data_name == "eight_schools")
-pos
-```
-
-To access reference posterior draws we use `reference_posterior_draws()`.
-
-```{r}
-rpd <- reference_posterior_draws(po)
-```
-
-The function `reference_posterior_draws()` returns a posterior `draws_list` object that can be summarized and transformed using the `posterior` package.
-
-```{r}
-posterior::summarize_draws(rpd)
-```
-
-To access information on the reference posterior we can use `reference_posterior_draws_info()` or just use `info()` on the reference posterior. This give soime basic information on how the reference posterior was computed.
-
-```{r}
-rpi <- reference_posterior_draws_info(po)
-rpi
-
-info(rpd)
-```
diff --git a/rpackage/README.md b/rpackage/README.md
deleted file mode 100644
index e08fe08d..00000000
--- a/rpackage/README.md
+++ /dev/null
@@ -1,295 +0,0 @@
-<!-- README.md is generated from README.Rmd. Please edit that file -->
-
-The included database contains convenience functions to access data,
-model code and information for individual posteriors.
-
-Installation
-============
-
-To install the package, you can either clone this repository and run the
-following snippet to install the package or install the package and
-access it from Github directly (see below).
-
-``` r
-remotes::install("rpackage/")
-```
-
-To install only the R package and then access the posteriors remotely,
-just install the package from GitHub.
-
-``` r
-remotes::install_github("MansMeg/posteriordb", subdir = "rpackage/")
-```
-
-To load the package, just run.
-
-``` r
-library(posteriordb)
-```
-
-Connect to the posterior database
-=================================
-
-First we create the posterior database to use, here we can use the
-database locally (if the repo is cloned).
-
-``` r
-my_pdb <- pdb_local()
-```
-
-The above code requires that your working directory is in the main
-folder of the cloned repository. Otherwise we can use the `path`
-argument.
-
-We can also simply use the github repository directly to access the
-data.
-
-``` r
-my_pdb <- pdb_github()
-```
-
-Independent of the posterior database used, the following works for all.
-
-Access content
-==============
-
-To list the posteriors available in the database, use
-`posterior_names()`.
-
-``` r
-pos <- posterior_names(my_pdb)
-head(pos)
-```
-
-    ## [1] "8schools"          "arK-arK"           "arK"
-    ## [4] "arma-arma11"       "arma"              "diamonds-diamonds"
-
-In the same fashion, we can list data and models included in the
-database as
-
-``` r
-mn <- model_names(my_pdb)
-head(mn)
-```
-
-    ## [1] "accel_gp"      "accel_splines" "arK"           "arma11"
-    ## [5] "blr"           "diamonds"
-
-``` r
-dn <- data_names(my_pdb)
-head(dn)
-```
-
-    ## [1] "arK"           "arma"          "diamonds"      "earnings"
-    ## [5] "eight_schools" "garch"
-
-We can also get all information on each individual posterior as a tibble
-with
-
-``` r
-pos <- posteriors_tbl_df(my_pdb)
-head(pos)
-```
-
-    ## # A tibble: 6 x 7
-    ##   name     model_name  reference_posteri… data_name added_by added_date keywords
-    ##   <chr>    <chr>       <chr>              <chr>     <chr>    <date>     <chr>
-    ## 1 eight_s… eight_scho… eight_schools-eig… eight_sc… Mans Ma… 2019-08-12 stan_be…
-    ## 2 arK-arK  arK         arK-arK            arK       Mans Ma… 2019-11-19 stan_be…
-    ## 3 arK-arK  arK         arK-arK            arK       Mans Ma… 2019-11-19 stan_be…
-    ## 4 arma-ar… arma11      arma-arma11        arma      Mans Ma… 2020-01-08 stan_be…
-    ## 5 arma-ar… arma11      arma-arma11        arma      Mans Ma… 2019-11-19 stan_be…
-    ## 6 diamond… diamonds    NULL               diamonds  Oliver … 2020-02-01 stan_be…
-
-The posterior’s name is made up of the data and model fitted to the
-data. Together, these two uniquely define a posterior distribution. To
-access a posterior object we can use the model name.
-
-``` r
-po <- posterior("eight_schools-eight_schools_centered", my_pdb)
-```
-
-From the posterior object, we can access data, model code (i.e., Stan
-code in this case) and a lot of other useful information.
-
-``` r
-dat <- pdb_data(po)
-dat
-```
-
-    ## $J
-    ## [1] 8
-    ##
-    ## $y
-    ## [1] 28  8 -3  7 -1  1 18 12
-    ##
-    ## $sigma
-    ## [1] 15 10 16 11  9 11 10 18
-
-``` r
-code <- stan_code(po)
-code
-```
-
-    ##
-    ## data {
-    ##   int <lower=0> J; // number of schools
-    ##   real y[J]; // estimated treatment
-    ##   real<lower=0> sigma[J]; // std of estimated effect
-    ## }
-    ## parameters {
-    ##   real theta[J]; // treatment effect in school j
-    ##   real mu; // hyper-parameter of mean
-    ##   real<lower=0> tau; // hyper-parameter of sdv
-    ## }
-    ## model {
-    ##   tau ~ cauchy(0, 5); // a non-informative prior
-    ##   theta ~ normal(mu, tau);
-    ##   y ~ normal(theta , sigma);
-    ##   mu ~ normal(0, 5);
-    ## }
-
-We can also access the paths to data after they have been unzipped and
-copied to the cache directory set in `pdb` (the R temp directory by
-default).
-
-``` r
-dfp <- data_file_path(po)
-dfp
-```
-
-    ## [1] "/var/folders/9h/yf354vb917z6gr6mz7bfb1d40000gn/T//RtmphMv3oc/posteriordb_cache/data/data/eight_schools.json"
-
-``` r
-scfp <- stan_code_file_path(po)
-scfp
-```
-
-    ## [1] "/var/folders/9h/yf354vb917z6gr6mz7bfb1d40000gn/T//RtmphMv3oc/posteriordb_cache/models/stan/eight_schools_centered.stan"
-
-We can also access information regarding the model and the data used to
-compute the posterior.
-
-``` r
-data_info(po)
-```
-
-    ## Data: eight_schools
-    ## The 8 schools dataset of Rubin (1981)
-
-``` r
-model_info(po)
-```
-
-    ## Model: eight_schools_centered
-    ## A centered hiearchical model for 8 schools
-
-Note that the references are referencing to BibTeX items that can be
-found in `content/references/references.bib`.
-
-We can access most of the posterior information as a `tbl_df` using
-
-``` r
-tbl <- posteriors_tbl_df(my_pdb)
-head(tbl)
-```
-
-    ## # A tibble: 6 x 7
-    ##   name     model_name  reference_posteri… data_name added_by added_date keywords
-    ##   <chr>    <chr>       <chr>              <chr>     <chr>    <date>     <chr>
-    ## 1 eight_s… eight_scho… eight_schools-eig… eight_sc… Mans Ma… 2019-08-12 stan_be…
-    ## 2 arK-arK  arK         arK-arK            arK       Mans Ma… 2019-11-19 stan_be…
-    ## 3 arK-arK  arK         arK-arK            arK       Mans Ma… 2019-11-19 stan_be…
-    ## 4 arma-ar… arma11      arma-arma11        arma      Mans Ma… 2020-01-08 stan_be…
-    ## 5 arma-ar… arma11      arma-arma11        arma      Mans Ma… 2019-11-19 stan_be…
-    ## 6 diamond… diamonds    NULL               diamonds  Oliver … 2020-02-01 stan_be…
-
-In addition, we can also access a list of posteriors with
-`filter_posteriors()`. The filtering function follows dplyr filter
-semantics based on the posterior tibble.
-
-``` r
-pos <- filter_posteriors(pdb = my_pdb, data_name == "eight_schools")
-pos
-```
-
-    ## [[1]]
-    ## Posterior
-    ##
-    ## Data: eight_schools
-    ## The 8 schools dataset of Rubin (1981)
-    ##
-    ## Model: eight_schools_noncentered
-    ## A non-centered hiearchical model for 8 schools
-    ##
-    ## [[2]]
-    ## Posterior
-    ##
-    ## Data: eight_schools
-    ## The 8 schools dataset of Rubin (1981)
-    ##
-    ## Model: eight_schools_centered
-    ## A centered hiearchical model for 8 schools
-
-To access reference posterior draws we use
-`reference_posterior_draws()`.
-
-``` r
-rpd <- reference_posterior_draws(po)
-```
-
-The function `reference_posterior_draws()` returns a posterior
-`draws_list` object that can be summarized and transformed using the
-`posterior` package.
-
-``` r
-posterior::summarize_draws(rpd)
-```
-
-    ## # A tibble: 10 x 10
-    ##    variable  mean median    sd   mad      q5   q95  rhat ess_bulk ess_tail
-    ##    <chr>    <dbl>  <dbl> <dbl> <dbl>   <dbl> <dbl> <dbl>    <dbl>    <dbl>
-    ##  1 theta[1]  5.85   6.04  3.74  2.40 -0.126  10.4  0.941        5        5
-    ##  2 theta[2] 11.2    8.22  9.19  3.49  4.72   27.5  1.05         5        5
-    ##  3 theta[3]  7.97   6.87  5.11  4.54  2.71   16.6  1.01         5        5
-    ##  4 theta[4]  7.05   6.22  8.29  6.00 -1.97   20.3  1.27         5        5
-    ##  5 theta[5]  4.91   4.15  4.11  3.18  0.0617 11.1  0.905        5        5
-    ##  6 theta[6]  5.16   5.93  3.70  3.68  0.459  10.2  1.30         5        5
-    ##  7 theta[7]  5.84   5.25  4.08  4.44 -0.232  11.3  1.42         5        5
-    ##  8 theta[8]  6.05   4.47  9.88  2.82 -4.86   22.1  1.02         5        5
-    ##  9 mu        5.67   5.44  4.88  4.80  0.302  13.3  1.06         5        5
-    ## 10 tau       6.15   6.09  2.24  1.15  3.19    9.65 1.18         5        5
-
-To access information on the reference posterior we can use
-`reference_posterior_draws_info()` or just use `info()` on the reference
-posterior. This give soime basic information on how the reference
-posterior was computed.
-
-``` r
-rpi <- reference_posterior_draws_info(po)
-rpi
-```
-
-    ## Posterior: eight_schools-eight_schools_noncentered
-    ## Method: stan_sampling (rstan 2.21.1)
-    ## Arguments:
-    ##   chains: 10
-    ##   iter: 20000
-    ##   warmup: 10000
-    ##   thin: 10
-    ##   seed: 4711
-    ##     adapt_delta: 0.95
-
-``` r
-info(rpd)
-```
-
-    ## Posterior: eight_schools-eight_schools_noncentered
-    ## Method: stan_sampling (rstan 2.21.1)
-    ## Arguments:
-    ##   chains: 10
-    ##   iter: 20000
-    ##   warmup: 10000
-    ##   thin: 10
-    ##   seed: 4711
-    ##     adapt_delta: 0.95
diff --git a/rpackage/man/alias_names.Rd b/rpackage/man/alias_names.Rd
deleted file mode 100644
index 3ab36f42..00000000
--- a/rpackage/man/alias_names.Rd
+++ /dev/null
@@ -1,16 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/aliases.R
-\name{alias_names}
-\alias{alias_names}
-\title{Get all existing alias names from a posterior database}
-\usage{
-alias_names(type, pdb = pdb_default())
-}
-\arguments{
-\item{type}{type of alias names. Cureently only posteriors.}
-
-\item{pdb}{a \code{pdb} object.}
-}
-\description{
-Get all existing alias names from a posterior database
-}
diff --git a/rpackage/man/as.data.frame.pdb_posterior.Rd b/rpackage/man/as.data.frame.pdb_posterior.Rd
deleted file mode 100644
index 83622f8c..00000000
--- a/rpackage/man/as.data.frame.pdb_posterior.Rd
+++ /dev/null
@@ -1,26 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/tibble.R
-\name{as.data.frame.pdb_posterior}
-\alias{as.data.frame.pdb_posterior}
-\alias{as.data.frame.pdb_posteriors}
-\title{Coerce a [pdb_posterior] to a Data Frame}
-\usage{
-\method{as.data.frame}{pdb_posterior}(x, row.names = NULL, optional = FALSE, ...)
-
-\method{as.data.frame}{pdb_posteriors}(x, row.names = NULL, optional = FALSE, ...)
-}
-\arguments{
-\item{x}{a [pdb_posterior] object.}
-
-\item{row.names}{NULL or a character vector giving the row names for the data frame. Missing values are not allowed.}
-
-\item{optional}{Not used.}
-
-\item{...}{further arguments to \code{as.data.frame} for a list.}
-}
-\description{
-Coerce a [pdb_posterior] to a Data Frame
-}
-\details{
-The dataframe will consist of one row per keyword.
-}
diff --git a/rpackage/man/assert_checked_reference_posterior_draws.Rd b/rpackage/man/assert_checked_reference_posterior_draws.Rd
deleted file mode 100644
index b2ac75d4..00000000
--- a/rpackage/man/assert_checked_reference_posterior_draws.Rd
+++ /dev/null
@@ -1,40 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/assert_checked_draws.R
-\name{assert_checked_reference_posterior_draws}
-\alias{assert_checked_reference_posterior_draws}
-\alias{assert_checked_reference_posterior_draws.pdb_reference_posterior_draws}
-\alias{assert_checked_reference_posterior_draws.pdb_reference_posterior_info}
-\alias{assert_checked_summary_statistics_draws}
-\alias{assert_checked_summary_statistics_draws.pdb_reference_posterior_draws}
-\alias{assert_checked_summary_statistics_draws.pdb_reference_posterior_summary_statistic}
-\alias{assert_checked_summary_statistics_draws.pdb_reference_posterior_info}
-\title{Assert that all checks of the reference posterior draws
-are true}
-\usage{
-assert_checked_reference_posterior_draws(x)
-
-\method{assert_checked_reference_posterior_draws}{pdb_reference_posterior_draws}(x)
-
-\method{assert_checked_reference_posterior_draws}{pdb_reference_posterior_info}(x)
-
-assert_checked_summary_statistics_draws(x)
-
-\method{assert_checked_summary_statistics_draws}{pdb_reference_posterior_draws}(x)
-
-\method{assert_checked_summary_statistics_draws}{pdb_reference_posterior_summary_statistic}(x)
-
-\method{assert_checked_summary_statistics_draws}{pdb_reference_posterior_info}(x)
-}
-\arguments{
-\item{x}{a [pdb_reference_posterior_draws] object}
-}
-\description{
-Assert that all checks of the reference posterior draws
-are true
-}
-\details{
-This functionasserts that the reference posterior draws comply
-with the criterias of the reference posterior draws.
-
-See \url{https://github.com/stan-dev/posteriordb/blob/master/doc/REFERENCE_POSTERIOR_DEFINITION.md} for details.
-}
diff --git a/rpackage/man/assert_reference_posterior_info.Rd b/rpackage/man/assert_reference_posterior_info.Rd
deleted file mode 100644
index 513f0f4e..00000000
--- a/rpackage/man/assert_reference_posterior_info.Rd
+++ /dev/null
@@ -1,15 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/reference_posterior.R
-\name{assert_reference_posterior_info}
-\alias{assert_reference_posterior_info}
-\title{Assert a [pdb_reference_posterior_info] object}
-\usage{
-assert_reference_posterior_info(x)
-}
-\arguments{
-\item{x}{a an object to assert is a [pdb_reference_posterior_info] object.}
-}
-\description{
-Assert a [pdb_reference_posterior_info] object
-}
-\keyword{internal}
diff --git a/rpackage/man/bibliography.Rd b/rpackage/man/bibliography.Rd
deleted file mode 100644
index bcdf0f42..00000000
--- a/rpackage/man/bibliography.Rd
+++ /dev/null
@@ -1,19 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/bibliography.R
-\name{bibliography}
-\alias{bibliography}
-\alias{pdb_bibliography}
-\title{Get the bibliography of a posterior database}
-\usage{
-bibliography(pdb, ...)
-
-pdb_bibliography(pdb, ...)
-}
-\arguments{
-\item{pdb}{a posterior database connection}
-
-\item{...}{further arguments passed to [bibtex::read.bib]}
-}
-\description{
-Get the bibliography of a posterior database
-}
diff --git a/rpackage/man/check_pdb.Rd b/rpackage/man/check_pdb.Rd
deleted file mode 100644
index 45a4b004..00000000
--- a/rpackage/man/check_pdb.Rd
+++ /dev/null
@@ -1,72 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/check_pdb.R
-\name{check_pdb}
-\alias{check_pdb}
-\alias{check_pdb_read_posteriors}
-\alias{check_pdb_read_model_code}
-\alias{check_pdb_aliases}
-\alias{check_pdb_read_data}
-\alias{check_pdb_read_reference_posterior_draws}
-\alias{check_pdb_run_stan}
-\alias{check_pdb_posterior_run_stan}
-\alias{check_pdb_stan_syntax}
-\alias{check_pdb_references}
-\alias{check_pdb_all_models_have_posterior}
-\alias{check_pdb_all_data_have_posterior}
-\alias{check_pdb_all_reference_posteriors_have_posterior}
-\title{Check the content a posterior database}
-\usage{
-check_pdb(pdb, posterior_idx = NULL)
-
-check_pdb_read_posteriors(pdb, posterior_idx = NULL)
-
-check_pdb_read_model_code(posterior_list)
-
-check_pdb_aliases(pdb)
-
-check_pdb_read_data(posterior_list)
-
-check_pdb_read_reference_posterior_draws(posterior_list)
-
-check_pdb_run_stan(pdb, posterior_idx = NULL)
-
-check_pdb_posterior_run_stan(po)
-
-check_pdb_stan_syntax(pdb, posterior_idx = NULL)
-
-check_pdb_references(pdb, posterior_idx = NULL)
-
-check_pdb_all_models_have_posterior(pdb)
-
-check_pdb_all_data_have_posterior(pdb)
-
-check_pdb_all_reference_posteriors_have_posterior(pdb)
-}
-\arguments{
-\item{pdb}{a \code{pdb} object}
-
-\item{posterior_idx}{an index vector indicating what posteriors to check.}
-
-\item{posterior_list}{a list of \code{pdb_posterior} objects.}
-
-\item{po}{a \code{pdb_posterior} object.}
-}
-\value{
-a boolean indicating if the pdb works as it should.
-}
-\description{
-Check the content a posterior database
-}
-\details{
-[check_pdb()] checks that the content exists as specified
-[check_pdb_run_stan()] test to run all posteriors with stan models.
-[check_pdb_stan_syntax()] check that all stan model code files can be parsed.
-[check_pdb_read_posteriors()] check that posteriors can be read.
-[check_pdb_aliases()] check that all alias are correct.
-[check_pdb_read_model_code()] check that posteriors can be read.
-[check_pdb_posteriors()] check a vector of posterior names.
-[check_pdb_references()] check that all references in posteriors also exist in bibtex.
-[check_pdb_all_models_have_posterior()] check that all models belong to a posterior
-[check_pdb_all_data_have_posterior()] check that all datasets belong to a posterior
-[check_pdb_all_reference_posteriors_have_posterior()] check that all reference posteriors belong to a posterior
-}
diff --git a/rpackage/man/check_pdb_posterior.Rd b/rpackage/man/check_pdb_posterior.Rd
deleted file mode 100644
index 2e532489..00000000
--- a/rpackage/man/check_pdb_posterior.Rd
+++ /dev/null
@@ -1,21 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/check_posterior.R
-\name{check_pdb_posterior}
-\alias{check_pdb_posterior}
-\title{Test a posterior}
-\usage{
-check_pdb_posterior(po, run_stan_code_checks = TRUE, verbose = TRUE)
-}
-\arguments{
-\item{po}{a [pdb_posterior] to check.}
-
-\item{run_stan_code_checks}{should checks using Rstan be run?}
-
-\item{verbose}{should check results be printed?}
-}
-\description{
-Test a posterior
-}
-\details{
-The function checks a posterior is consistent.
-}
diff --git a/rpackage/man/check_reference_posterior_draws.Rd b/rpackage/man/check_reference_posterior_draws.Rd
deleted file mode 100644
index ffe24894..00000000
--- a/rpackage/man/check_reference_posterior_draws.Rd
+++ /dev/null
@@ -1,27 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/utils_reference_posterior.R
-\name{check_reference_posterior_draws}
-\alias{check_reference_posterior_draws}
-\alias{check_reference_posterior_draws.character}
-\alias{check_reference_posterior_draws.pdb_posterior}
-\alias{check_reference_posterior_draws.pdb_reference_posterior_draws}
-\title{Check that reference posterior draws follows the
-reference posterior draws definition.}
-\usage{
-check_reference_posterior_draws(x, ...)
-
-\method{check_reference_posterior_draws}{character}(x, ...)
-
-\method{check_reference_posterior_draws}{pdb_posterior}(x, ...)
-
-\method{check_reference_posterior_draws}{pdb_reference_posterior_draws}(x, ...)
-}
-\arguments{
-\item{x}{a posterior name, posterior object or reference_posterior_draws object}
-
-\item{...}{currently not used.}
-}
-\description{
-Check that reference posterior draws follows the
-reference posterior draws definition.
-}
diff --git a/rpackage/man/check_summary_statistics_draws.Rd b/rpackage/man/check_summary_statistics_draws.Rd
deleted file mode 100644
index a7d8ee64..00000000
--- a/rpackage/man/check_summary_statistics_draws.Rd
+++ /dev/null
@@ -1,27 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/utils_reference_posterior.R
-\name{check_summary_statistics_draws}
-\alias{check_summary_statistics_draws}
-\alias{check_summary_statistics_draws.character}
-\alias{check_summary_statistics_draws.pdb_posterior}
-\alias{check_summary_statistics_draws.pdb_reference_posterior_draws}
-\title{Check that reference posterior draws follows the
-reference posterior summary definition.}
-\usage{
-check_summary_statistics_draws(x, ...)
-
-\method{check_summary_statistics_draws}{character}(x, ...)
-
-\method{check_summary_statistics_draws}{pdb_posterior}(x, ...)
-
-\method{check_summary_statistics_draws}{pdb_reference_posterior_draws}(x, ...)
-}
-\arguments{
-\item{x}{a posterior name, posterior object or reference_posterior_draws object}
-
-\item{...}{currently not used.}
-}
-\description{
-Check that reference posterior draws follows the
-reference posterior summary definition.
-}
diff --git a/rpackage/man/compute_reference_posterior_draws.Rd b/rpackage/man/compute_reference_posterior_draws.Rd
deleted file mode 100644
index 37bf34fe..00000000
--- a/rpackage/man/compute_reference_posterior_draws.Rd
+++ /dev/null
@@ -1,17 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in
-%   R/compute_reference_posterior_draws_stan_sampling.R
-\name{compute_reference_posterior_draws}
-\alias{compute_reference_posterior_draws}
-\title{Compute a Reference Posteriors for a reference posterior info object}
-\usage{
-compute_reference_posterior_draws(rpi, pdb = pdb_default())
-}
-\arguments{
-\item{rpi}{a [reference_posterior_info] object.}
-
-\item{pdb}{a [pdb] object.}
-}
-\description{
-Compute a Reference Posteriors for a reference posterior info object
-}
diff --git a/rpackage/man/compute_reference_posterior_draws_stan_sampling.Rd b/rpackage/man/compute_reference_posterior_draws_stan_sampling.Rd
deleted file mode 100644
index a0898204..00000000
--- a/rpackage/man/compute_reference_posterior_draws_stan_sampling.Rd
+++ /dev/null
@@ -1,17 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in
-%   R/compute_reference_posterior_draws_stan_sampling.R
-\name{compute_reference_posterior_draws_stan_sampling}
-\alias{compute_reference_posterior_draws_stan_sampling}
-\title{Compute a Reference Posteriors using Rstan}
-\usage{
-compute_reference_posterior_draws_stan_sampling(rpi, pdb)
-}
-\arguments{
-\item{rpi}{a [reference_posterior_info] object.}
-
-\item{pdb}{a [pdb] object.}
-}
-\description{
-Compute a Reference Posteriors using Rstan
-}
diff --git a/rpackage/man/compute_reference_posterior_summary_statistic.Rd b/rpackage/man/compute_reference_posterior_summary_statistic.Rd
deleted file mode 100644
index 7d3ab4f0..00000000
--- a/rpackage/man/compute_reference_posterior_summary_statistic.Rd
+++ /dev/null
@@ -1,19 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/compute_summary_statistics.R
-\name{compute_reference_posterior_summary_statistic}
-\alias{compute_reference_posterior_summary_statistic}
-\alias{compute_summary_statistic}
-\title{Compute Summary statistics from a reference posterior}
-\usage{
-compute_reference_posterior_summary_statistic(rpd, summary_statistic = "mean")
-
-compute_summary_statistic(rpd, summary_statistic = "mean")
-}
-\arguments{
-\item{rpd}{a [reference_posterior_summary_statistic] object}
-
-\item{summary_statistic}{summary statistic to compute}
-}
-\description{
-Compute Summary statistics from a reference posterior
-}
diff --git a/rpackage/man/data_file_path.Rd b/rpackage/man/data_file_path.Rd
deleted file mode 100644
index b9c6b2d1..00000000
--- a/rpackage/man/data_file_path.Rd
+++ /dev/null
@@ -1,22 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/data.R
-\name{data_file_path}
-\alias{data_file_path}
-\alias{stan_data_file_path}
-\alias{stan_data}
-\title{Extract data for posterior}
-\usage{
-data_file_path(x, ...)
-
-stan_data_file_path(x, ...)
-
-stan_data(x)
-}
-\arguments{
-\item{x}{an object to access file path to.}
-
-\item{...}{further arguments supplied to methods.}
-}
-\description{
-Extract data for posterior
-}
diff --git a/rpackage/man/data_names.Rd b/rpackage/man/data_names.Rd
deleted file mode 100644
index b5a74c39..00000000
--- a/rpackage/man/data_names.Rd
+++ /dev/null
@@ -1,28 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/pdb.R, R/pdb_github.R
-\name{data_names}
-\alias{data_names}
-\alias{data_names.pdb_local}
-\alias{data_names.pdb_github}
-\alias{model_names.pdb_github}
-\alias{reference_posterior_names.pdb_github}
-\title{Get all existing data names from a posterior database}
-\usage{
-data_names(pdb = pdb_default(), ...)
-
-\method{data_names}{pdb_local}(pdb = pdb_default(), ...)
-
-\method{data_names}{pdb_github}(pdb, ...)
-
-\method{model_names}{pdb_github}(pdb, ...)
-
-\method{reference_posterior_names}{pdb_github}(pdb, ...)
-}
-\arguments{
-\item{pdb}{a \code{pdb} object.}
-
-\item{...}{Further argument to methods.}
-}
-\description{
-Get all existing data names from a posterior database
-}
diff --git a/rpackage/man/ess_bounds.Rd b/rpackage/man/ess_bounds.Rd
deleted file mode 100644
index 2f5b4ec3..00000000
--- a/rpackage/man/ess_bounds.Rd
+++ /dev/null
@@ -1,21 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/utils_reference_posterior.R
-\name{ess_bounds}
-\alias{ess_bounds}
-\title{Compute ESS tail and bulk bounds}
-\usage{
-ess_bounds(x)
-}
-\arguments{
-\item{x}{a [pdb_reference_posterior_draws] object.}
-
-\item{p}{the joint probability for independent ESS estimators.}
-}
-\description{
-Compute ESS tail and bulk bounds
-}
-\details{
-Compute the bounds for ESS tail and bulk based on 100 000
-simulated ESS computations.
-}
-\keyword{internal}
diff --git a/rpackage/man/filter_posteriors.Rd b/rpackage/man/filter_posteriors.Rd
deleted file mode 100644
index 788ed3fa..00000000
--- a/rpackage/man/filter_posteriors.Rd
+++ /dev/null
@@ -1,26 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/filter.R
-\name{filter_posteriors}
-\alias{filter_posteriors}
-\title{Filter Posteriors in Database}
-\usage{
-filter_posteriors(pdb = pdb_default(), ...)
-}
-\arguments{
-\item{pdb}{a \code{pdb} object.}
-
-\item{...}{further arguments to supply to \code{dplyr::filter()}}
-}
-\description{
-Filter Posteriors in Database
-}
-\details{
-Filter posteriors in the database and return list of
-posteriors/models/data to work with as a list.
-
-The function is built upon the dplyr filter function and
-follows the exact same syntax. All elements in the
-`posteriors/[posterior_name].json`, `models/info/[model_name].json`
-and `data/info/[data_name].json` can be used to filter the
-posterior database. See examples below.
-}
diff --git a/rpackage/man/framework.Rd b/rpackage/man/framework.Rd
deleted file mode 100644
index 00231443..00000000
--- a/rpackage/man/framework.Rd
+++ /dev/null
@@ -1,28 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/model_code.R
-\name{framework}
-\alias{framework}
-\alias{framework.pdb_model_code}
-\alias{framework<-}
-\alias{framework<-.character}
-\alias{framework<-.pdb_model_code}
-\title{Identify the framework for a given [model_code]}
-\usage{
-framework(x)
-
-\method{framework}{pdb_model_code}(x)
-
-framework(x) <- value
-
-\method{framework}{character}(x) <- value
-
-\method{framework}{pdb_model_code}(x) <- value
-}
-\arguments{
-\item{x}{a [pdb_model_code] object.}
-
-\item{value}{a supported framework.}
-}
-\description{
-Identify the framework for a given [model_code]
-}
diff --git a/rpackage/man/get_data.Rd b/rpackage/man/get_data.Rd
deleted file mode 100644
index cfc194cf..00000000
--- a/rpackage/man/get_data.Rd
+++ /dev/null
@@ -1,35 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/data.R
-\name{get_data}
-\alias{get_data}
-\alias{get_data.pdb_posterior}
-\alias{get_data.character}
-\alias{get_data.pdb_data_info}
-\alias{get_data.list}
-\alias{pdb_data}
-\title{Posterior Data Sets}
-\usage{
-get_data(x, ...)
-
-\method{get_data}{pdb_posterior}(x, ...)
-
-\method{get_data}{character}(x, pdb = pdb_default(), ...)
-
-\method{get_data}{pdb_data_info}(x, pdb = pdb_default(), ...)
-
-\method{get_data}{list}(x, info, ...)
-
-pdb_data(x, ...)
-}
-\arguments{
-\item{x}{an object to access data from.}
-
-\item{...}{Currently not used.}
-
-\item{pdb}{a \code{pdb} object.}
-
-\item{info}{a \code{pdb_data_info} object.}
-}
-\description{
-Posterior Data Sets
-}
diff --git a/rpackage/man/github_pat.Rd b/rpackage/man/github_pat.Rd
deleted file mode 100644
index d34cc39a..00000000
--- a/rpackage/man/github_pat.Rd
+++ /dev/null
@@ -1,15 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/pdb_github.R
-\name{github_pat}
-\alias{github_pat}
-\title{Retrieve Github personal access token.}
-\usage{
-github_pat(pdb = NULL)
-}
-\arguments{
-\item{pdb}{A posterior datasbase object to extract pat from.}
-}
-\description{
-A github personal access token
-Looks in env var `GITHUB_PAT`
-}
diff --git a/rpackage/man/github_ref.Rd b/rpackage/man/github_ref.Rd
deleted file mode 100644
index 0fa2bab0..00000000
--- a/rpackage/man/github_ref.Rd
+++ /dev/null
@@ -1,15 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/pdb_github.R
-\name{github_ref}
-\alias{github_ref}
-\title{Retrieve Github reference.}
-\usage{
-github_ref(pdb = NULL)
-}
-\arguments{
-\item{pdb}{A posterior datasbase object.}
-}
-\description{
-A github reference to use
-Looks in env var `GITHUB_REF`
-}
diff --git a/rpackage/man/handle_aliases.Rd b/rpackage/man/handle_aliases.Rd
deleted file mode 100644
index 20d01ef0..00000000
--- a/rpackage/man/handle_aliases.Rd
+++ /dev/null
@@ -1,18 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/aliases.R
-\name{handle_aliases}
-\alias{handle_aliases}
-\title{Return the name that the alias points to}
-\usage{
-handle_aliases(x, type, pdb)
-}
-\arguments{
-\item{x}{a name to lookup in alias list}
-
-\item{type}{type of alias names. Cureently only posteriors.}
-
-\item{pdb}{a \code{pdb} object.}
-}
-\description{
-Return the name that the alias points to
-}
diff --git a/rpackage/man/info-set.Rd b/rpackage/man/info-set.Rd
deleted file mode 100644
index ad5aa2f9..00000000
--- a/rpackage/man/info-set.Rd
+++ /dev/null
@@ -1,16 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/generics.R
-\name{info<-}
-\alias{info<-}
-\title{Set information to a pdb object}
-\usage{
-info(x) <- value
-}
-\arguments{
-\item{x}{a [pdb_data], [pdb_model_code] and [pdb_reference_posterior]}
-
-\item{value}{an info object}
-}
-\description{
-Set information to a pdb object
-}
diff --git a/rpackage/man/info.Rd b/rpackage/man/info.Rd
deleted file mode 100644
index 546e781a..00000000
--- a/rpackage/man/info.Rd
+++ /dev/null
@@ -1,16 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/generics.R
-\name{info}
-\alias{info}
-\title{Extract information from a pdb object}
-\usage{
-info(x)
-}
-\arguments{
-\item{x}{a [pdb_data], [pdb_model_code] and [pdb_reference_posterior]}
-
-\item{info}{a [pdb_]}
-}
-\description{
-Extract information from a pdb object
-}
diff --git a/rpackage/man/model_code.Rd b/rpackage/man/model_code.Rd
deleted file mode 100644
index 8eed8de2..00000000
--- a/rpackage/man/model_code.Rd
+++ /dev/null
@@ -1,61 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/model_code.R
-\name{model_code}
-\alias{model_code}
-\alias{model_code.pdb_posterior}
-\alias{model_code.character}
-\alias{model_code.pdb_model_info}
-\alias{model_code.stanmodel}
-\alias{pdb_model_code}
-\alias{model_code_file_path}
-\alias{model_code_file_path.pdb_posterior}
-\alias{model_code_file_path.pdb_model_info}
-\alias{model_code_file_path.character}
-\alias{stan_code_file_path}
-\alias{stan_code}
-\alias{pdb_stan_code}
-\title{Extract file paths to model code from posterior object}
-\usage{
-model_code(x, ...)
-
-\method{model_code}{pdb_posterior}(x, framework, ...)
-
-\method{model_code}{character}(x, framework, pdb = pdb_default(), ...)
-
-\method{model_code}{pdb_model_info}(x, framework, pdb = pdb_default(), ...)
-
-\method{model_code}{stanmodel}(x, info, ...)
-
-pdb_model_code(x, ...)
-
-model_code_file_path(x, ...)
-
-\method{model_code_file_path}{pdb_posterior}(x, framework, ...)
-
-\method{model_code_file_path}{pdb_model_info}(x, framework, pdb = pdb_default(), ...)
-
-\method{model_code_file_path}{character}(x, framework, pdb = pdb_default(), ...)
-
-stan_code_file_path(x)
-
-stan_code(x, ...)
-
-pdb_stan_code(x, ...)
-}
-\arguments{
-\item{x}{an object to access file path to.}
-
-\item{...}{further arguments supplied to methods.}
-
-\item{framework}{model code framework (e.g. \code{stan}).}
-
-\item{pdb}{a \code{pdb} object.}
-
-\item{info}{a \code{pdb_model_info} object.}
-}
-\description{
-Extract file paths to model code from posterior object
-}
-\seealso{
-framework()
-}
diff --git a/rpackage/man/model_info.Rd b/rpackage/man/model_info.Rd
deleted file mode 100644
index 806b79ad..00000000
--- a/rpackage/man/model_info.Rd
+++ /dev/null
@@ -1,45 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/data_info.R, R/model_info.R
-\name{data_info}
-\alias{data_info}
-\alias{data_info.pdb_posterior}
-\alias{data_info.character}
-\alias{data_info.list}
-\alias{pdb_data_info}
-\alias{model_info}
-\alias{pdb_model_info}
-\alias{model_info.pdb_posterior}
-\alias{model_info.character}
-\alias{model_info.list}
-\title{Access data and model information}
-\usage{
-data_info(x, ...)
-
-\method{data_info}{pdb_posterior}(x, ...)
-
-\method{data_info}{character}(x, pdb = pdb_default(), ...)
-
-\method{data_info}{list}(x, pdb = NULL, ...)
-
-pdb_data_info(x, ...)
-
-model_info(x, ...)
-
-pdb_model_info(x, ...)
-
-\method{model_info}{pdb_posterior}(x, ...)
-
-\method{model_info}{character}(x, pdb = pdb_default(), ...)
-
-\method{model_info}{list}(x, pdb = NULL, ...)
-}
-\arguments{
-\item{x}{a object to access information for.}
-
-\item{...}{further arguments to methods.}
-
-\item{pdb}{a \code{pdb} object.}
-}
-\description{
-Access data and model information
-}
diff --git a/rpackage/man/model_names.Rd b/rpackage/man/model_names.Rd
deleted file mode 100644
index 89b1293b..00000000
--- a/rpackage/man/model_names.Rd
+++ /dev/null
@@ -1,19 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/pdb.R
-\name{model_names}
-\alias{model_names}
-\alias{model_names.pdb_local}
-\title{Get all existing model names from a posterior database}
-\usage{
-model_names(pdb = pdb_default(), ...)
-
-\method{model_names}{pdb_local}(pdb = pdb_default(), ...)
-}
-\arguments{
-\item{pdb}{a \code{pdb} object.}
-
-\item{...}{Further argument to methods.}
-}
-\description{
-Get all existing model names from a posterior database
-}
diff --git a/rpackage/man/pdb-set.Rd b/rpackage/man/pdb-set.Rd
deleted file mode 100644
index 277e36e0..00000000
--- a/rpackage/man/pdb-set.Rd
+++ /dev/null
@@ -1,16 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/pdb.R
-\name{pdb<-}
-\alias{pdb<-}
-\title{Set pdb slot}
-\usage{
-pdb(x) <- value
-}
-\arguments{
-\item{x}{a [pdb_data], [pdb_model_code] and [pdb_reference_posterior]}
-
-\item{value}{a pdb object}
-}
-\description{
-Set pdb slot
-}
diff --git a/rpackage/man/pdb_aliases.Rd b/rpackage/man/pdb_aliases.Rd
deleted file mode 100644
index 0f2e11e1..00000000
--- a/rpackage/man/pdb_aliases.Rd
+++ /dev/null
@@ -1,16 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/aliases.R
-\name{pdb_aliases}
-\alias{pdb_aliases}
-\title{Extract aliases list from posterior database}
-\usage{
-pdb_aliases(type, pdb)
-}
-\arguments{
-\item{type}{type of alias names. Cureently only posteriors.}
-
-\item{pdb}{a \code{pdb} object.}
-}
-\description{
-Extract aliases list from posterior database
-}
diff --git a/rpackage/man/pdb_assert_file_exist.Rd b/rpackage/man/pdb_assert_file_exist.Rd
deleted file mode 100644
index 2184b995..00000000
--- a/rpackage/man/pdb_assert_file_exist.Rd
+++ /dev/null
@@ -1,21 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/pdb.R
-\name{pdb_assert_file_exist}
-\alias{pdb_assert_file_exist}
-\alias{pdb_assert_file_exist.pdb_local}
-\title{Assert that a file exists}
-\usage{
-pdb_assert_file_exist(pdb, path, ...)
-
-\method{pdb_assert_file_exist}{pdb_local}(pdb, path, ...)
-}
-\arguments{
-\item{pdb}{a \code{pdb} object.}
-
-\item{path}{a \code{pdb} path.}
-
-\item{...}{further arguments supplied to methods.}
-}
-\description{
-Assert that a file exists
-}
diff --git a/rpackage/man/pdb_cache_path.Rd b/rpackage/man/pdb_cache_path.Rd
deleted file mode 100644
index 4e3c21e9..00000000
--- a/rpackage/man/pdb_cache_path.Rd
+++ /dev/null
@@ -1,18 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/pdb.R
-\name{pdb_cache_path}
-\alias{pdb_cache_path}
-\title{Returns a writable cache path for a pdb and a path
-It will create the directory if it does not exist.}
-\usage{
-pdb_cache_path(pdb, path)
-}
-\arguments{
-\item{pdb}{a \code{pdb} object.}
-
-\item{path}{a \code{pdb} path.}
-}
-\description{
-Returns a writable cache path for a pdb and a path
-It will create the directory if it does not exist.
-}
diff --git a/rpackage/man/pdb_cache_rm.Rd b/rpackage/man/pdb_cache_rm.Rd
deleted file mode 100644
index ba46bc86..00000000
--- a/rpackage/man/pdb_cache_rm.Rd
+++ /dev/null
@@ -1,22 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/pdb.R
-\name{pdb_cache_rm}
-\alias{pdb_cache_rm}
-\alias{pdb_cache_rm.pdb_reference_posterior_draws}
-\alias{pdb_cache_rm.pdb_data}
-\title{Remove object from cache}
-\usage{
-pdb_cache_rm(x, ...)
-
-\method{pdb_cache_rm}{pdb_reference_posterior_draws}(x, ...)
-
-\method{pdb_cache_rm}{pdb_data}(x, ...)
-}
-\arguments{
-\item{x}{an object to remove from cache}
-
-\item{...}{Currently not in use.}
-}
-\description{
-Remove object from cache
-}
diff --git a/rpackage/man/pdb_cached_local_file_path.Rd b/rpackage/man/pdb_cached_local_file_path.Rd
deleted file mode 100644
index 98428698..00000000
--- a/rpackage/man/pdb_cached_local_file_path.Rd
+++ /dev/null
@@ -1,21 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/pdb.R
-\name{pdb_cached_local_file_path}
-\alias{pdb_cached_local_file_path}
-\title{Read json file from \code{path}}
-\usage{
-pdb_cached_local_file_path(pdb, path, unzip = FALSE)
-}
-\arguments{
-\item{pdb}{a \code{pdb} to read from.}
-
-\item{path}{a \code{pdb} to read from.}
-
-\item{unzip}{if true, path is zipped and should be unzipped to cache.}
-}
-\description{
-Read json file from \code{path}
-}
-\details{
-Copies the file to the cache and return path
-}
diff --git a/rpackage/man/pdb_clear_cache.Rd b/rpackage/man/pdb_clear_cache.Rd
deleted file mode 100644
index e723e817..00000000
--- a/rpackage/man/pdb_clear_cache.Rd
+++ /dev/null
@@ -1,18 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/pdb.R
-\name{pdb_clear_cache}
-\alias{pdb_clear_cache}
-\alias{pdb_cache_clear}
-\title{Clear posterior database cache}
-\usage{
-pdb_clear_cache(pdb = pdb_default())
-
-pdb_cache_clear(pdb = pdb_default())
-}
-\arguments{
-\item{pdb}{a \code{pdb} to clear cache for}
-}
-\description{
-Clear posterior database cache
-}
-\keyword{internal}
diff --git a/rpackage/man/pdb_file_copy.Rd b/rpackage/man/pdb_file_copy.Rd
deleted file mode 100644
index e63957d7..00000000
--- a/rpackage/man/pdb_file_copy.Rd
+++ /dev/null
@@ -1,31 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/pdb.R, R/pdb_github.R
-\name{pdb_file_copy}
-\alias{pdb_file_copy}
-\alias{pdb_file_copy.pdb_local}
-\alias{pdb_file_copy.pdb_github}
-\title{Copy a file from a pdb to a local path}
-\usage{
-pdb_file_copy(pdb, from, to, overwrite = FALSE, ...)
-
-\method{pdb_file_copy}{pdb_local}(pdb, from, to, overwrite = FALSE, ...)
-
-\method{pdb_file_copy}{pdb_github}(pdb, from, to, overwrite = FALSE, ...)
-}
-\arguments{
-\item{pdb}{a \code{pdb} connection.}
-
-\item{from}{a path in the pdb}
-
-\item{to}{a local file path}
-
-\item{overwrite}{overwrite local file.}
-
-\item{...}{further argument supplied to methods}
-}
-\value{
-a boolean indicator as file.copy indicating success.
-}
-\description{
-Copy a file from a pdb to a local path
-}
diff --git a/rpackage/man/pdb_filter.Rd b/rpackage/man/pdb_filter.Rd
deleted file mode 100644
index 66f78a66..00000000
--- a/rpackage/man/pdb_filter.Rd
+++ /dev/null
@@ -1,15 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/filter.R
-\name{pdb_filter}
-\alias{pdb_filter}
-\title{Internal filter function}
-\usage{
-pdb_filter(path, pdb, ...)
-}
-\arguments{
-\item{pdb}{a pdb connection}
-}
-\description{
-Works for filtering models, data and posteriors.
-}
-\keyword{internal}
diff --git a/rpackage/man/pdb_local.Rd b/rpackage/man/pdb_local.Rd
deleted file mode 100644
index 1fbad93e..00000000
--- a/rpackage/man/pdb_local.Rd
+++ /dev/null
@@ -1,86 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/pdb.R, R/pdb_github.R
-\name{pdb_local}
-\alias{pdb_local}
-\alias{pdb}
-\alias{pdb.default}
-\alias{pdb.pdb_model_code}
-\alias{pdb.character}
-\alias{pdb_default}
-\alias{pdb_config}
-\alias{pdb_github}
-\title{Create a Posterior Database (pdb) connection}
-\usage{
-pdb_local(path = getOption("pdb_path", getwd()), cache_path = tempdir())
-
-pdb(x, ...)
-
-\method{pdb}{default}(x, ...)
-
-\method{pdb}{pdb_model_code}(x, ...)
-
-\method{pdb}{character}(x, pdb_type = "local", cache_path = tempdir(), ...)
-
-pdb_default(cache_path = tempdir())
-
-pdb_config(directory = getwd())
-
-pdb_github(
-  repo = getOption("pdb_repo", "stan-dev/posteriordb/posterior_database"),
-  cache_path = tempdir(),
-  ref = github_ref(),
-  subdir = NULL,
-  auth_token = github_pat(),
-  host = "https://api.github.com"
-)
-}
-\arguments{
-\item{path}{a local path to a posterior database.}
-
-\item{cache_path}{The path to the pdb cache. Default is R temporary directory.
-This is used to store files locally and without affecting the database.}
-
-\item{x}{an object to access a pdb for, if character this is how to identify the pdb (path for local pdb, repo for github pdb)}
-
-\item{...}{further arguments for specific methods to setup a pdb.}
-
-\item{pdb_type}{Type of posterior database connection. Either \code{local} or \code{github}.}
-
-\item{directory}{the directory to look for the [.pdb_config.yml] file}
-
-\item{repo}{Repository address in the format
-`username/repo[/subdir][@ref|#pull]`. Alternatively, you can
-specify `subdir` and/or `ref` using the respective parameters
-(see below); if both is specified, the values in `repo` take
-precedence.}
-
-\item{ref}{Desired git reference. Could be a commit, tag, or branch
-name. Defaults to `"master"`.}
-
-\item{subdir}{subdirectory within repo that contains the posterior database.}
-
-\item{auth_token}{To use a private repo, generate a personal
-access token (PAT) in "https://github.com/settings/tokens" and
-supply to this argument. This is safer than using a password because
-you can easily delete a PAT without affecting any others. Defaults to
-the `GITHUB_PAT` environment variable.}
-
-\item{host}{GitHub API host to use. Override with your GitHub enterprise
-hostname, for example, `"github.hostname.com/api/v3"`.}
-}
-\value{
-a \code{pdb} object
-}
-\description{
-Create a Posterior Database (pdb) connection
-}
-\details{
-Connect to a posterior database locally or in a github repo.
-
-[pdb_config()] read  [.pdb_config.yml] in [directory] and use that to setup a
-pdb connection.
-
-The connection [pdb_default()] first checks if there exists a [.pdb_config.yml]
-file in the working directory. If it exist, [pdb_config()] is used to setup,
-the connection, otherwise [pdb_github()] is used.
-}
diff --git a/rpackage/man/pdb_version.Rd b/rpackage/man/pdb_version.Rd
deleted file mode 100644
index 61711315..00000000
--- a/rpackage/man/pdb_version.Rd
+++ /dev/null
@@ -1,25 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/pdb.R, R/pdb_github.R
-\name{pdb_version}
-\alias{pdb_version}
-\alias{pdb_version.pdb_local}
-\alias{pdb_version.pdb_github}
-\title{Get version of the \code{pdb}}
-\usage{
-pdb_version(pdb, ...)
-
-\method{pdb_version}{pdb_local}(pdb, ...)
-
-\method{pdb_version}{pdb_github}(pdb, ...)
-}
-\arguments{
-\item{pdb}{a \code{pdb} object to return version for.}
-
-\item{...}{Further argument to methods.}
-}
-\value{
-the git sha for the posterior database.
-}
-\description{
-Get version of the \code{pdb}
-}
diff --git a/rpackage/man/posterior.Rd b/rpackage/man/posterior.Rd
deleted file mode 100644
index 4d51c6d4..00000000
--- a/rpackage/man/posterior.Rd
+++ /dev/null
@@ -1,27 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/posterior.R
-\name{posterior}
-\alias{posterior}
-\alias{posterior.character}
-\alias{posterior.list}
-\alias{pdb_posterior}
-\title{Access a posterior in the posterior database}
-\usage{
-posterior(x, pdb = pdb_default(), ...)
-
-\method{posterior}{character}(x, pdb = pdb_default(), ...)
-
-\method{posterior}{list}(x, pdb = pdb_default(), ...)
-
-pdb_posterior(x, pdb = pdb_default(), ...)
-}
-\arguments{
-\item{x}{a posterior name that exist in the posterior database}
-
-\item{pdb}{a \code{pdb} posterior database object.}
-
-\item{...}{currently not in use.}
-}
-\description{
-Access a posterior in the posterior database
-}
diff --git a/rpackage/man/posterior_dimension_names.Rd b/rpackage/man/posterior_dimension_names.Rd
deleted file mode 100644
index 25dd54e4..00000000
--- a/rpackage/man/posterior_dimension_names.Rd
+++ /dev/null
@@ -1,15 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in
-%   R/compute_reference_posterior_draws_stan_sampling.R
-\name{posterior_dimension_names}
-\alias{posterior_dimension_names}
-\title{Construct dimension names from a posterior dimension list}
-\usage{
-posterior_dimension_names(x)
-}
-\arguments{
-\item{x}{a dimensions slot from a [pdb_posterior]}
-}
-\description{
-Construct dimension names from a posterior dimension list
-}
diff --git a/rpackage/man/posterior_names.Rd b/rpackage/man/posterior_names.Rd
deleted file mode 100644
index 78788dc7..00000000
--- a/rpackage/man/posterior_names.Rd
+++ /dev/null
@@ -1,19 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/pdb.R
-\name{posterior_names}
-\alias{posterior_names}
-\alias{posterior_name}
-\title{Get all existing posterior names from a posterior database or posterior objects.}
-\usage{
-posterior_names(x = pdb_default(), ...)
-
-posterior_name(x = pdb_default(), ...)
-}
-\arguments{
-\item{x}{a \code{pdb}, \code{posterior} object or a list of \code{posterior} objects.}
-
-\item{...}{further arguments supplied to specific methods (not in use)}
-}
-\description{
-Get all existing posterior names from a posterior database or posterior objects.
-}
diff --git a/rpackage/man/posteriors_tbl_df.Rd b/rpackage/man/posteriors_tbl_df.Rd
deleted file mode 100644
index 232ad205..00000000
--- a/rpackage/man/posteriors_tbl_df.Rd
+++ /dev/null
@@ -1,20 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/tibble.R
-\name{posteriors_tbl_df}
-\alias{posteriors_tbl_df}
-\title{Create Posterior Database tibbles}
-\usage{
-posteriors_tbl_df(pdb = pdb_default(), ...)
-}
-\arguments{
-\item{pdb}{a \code{pdb} object.}
-
-\item{...}{further arguments to supply to \code{dplyr::filter()}}
-}
-\description{
-Create Posterior Database tibbles
-}
-\details{
-Generates a tibble data frame of all posteriors
-in the database and their side information
-}
diff --git a/rpackage/man/read_json_from_pdb.Rd b/rpackage/man/read_json_from_pdb.Rd
deleted file mode 100644
index d42225fa..00000000
--- a/rpackage/man/read_json_from_pdb.Rd
+++ /dev/null
@@ -1,20 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/pdb.R
-\name{read_json_from_pdb}
-\alias{read_json_from_pdb}
-\title{Read JSON objects from the posterior database}
-\usage{
-read_json_from_pdb(fn, path, pdb, ...)
-}
-\arguments{
-\item{fn}{file name}
-
-\item{path}{path to file name in pdb}
-
-\item{pdb}{a [pdb] object}
-
-\item{...}{further arguments supplied to [jsonlite::read_json()]}
-}
-\description{
-Read JSON objects from the posterior database
-}
diff --git a/rpackage/man/reference_posterior_draws.Rd b/rpackage/man/reference_posterior_draws.Rd
deleted file mode 100644
index 4a677b35..00000000
--- a/rpackage/man/reference_posterior_draws.Rd
+++ /dev/null
@@ -1,45 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in
-%   R/compute_reference_posterior_draws_stan_sampling.R, R/reference_posterior.R
-\name{reference_posterior_draws.stanfit}
-\alias{reference_posterior_draws.stanfit}
-\alias{reference_posterior_draws}
-\alias{pdb_reference_posterior_draws}
-\alias{reference_posterior_draws.character}
-\alias{reference_posterior_draws.pdb_posterior}
-\alias{reference_posterior_draws.pdb_reference_posterior_info}
-\alias{reference_posterior_draws.draws_list}
-\alias{assert_reference_posterior_draws}
-\title{Reference Posterior draws and summary statistics}
-\usage{
-\method{reference_posterior_draws}{stanfit}(x, info, pdb = pdb_default(), ...)
-
-reference_posterior_draws(x, ...)
-
-pdb_reference_posterior_draws(x, ...)
-
-\method{reference_posterior_draws}{character}(x, pdb = pdb_default(), ...)
-
-\method{reference_posterior_draws}{pdb_posterior}(x, ...)
-
-\method{reference_posterior_draws}{pdb_reference_posterior_info}(x, pdb = pdb_default(), ...)
-
-\method{reference_posterior_draws}{draws_list}(x, info, ...)
-
-assert_reference_posterior_draws(x)
-}
-\arguments{
-\item{x}{a [posterior] object or a posterior name.}
-
-\item{info}{a [pdb_reference_posterior_info] object}
-
-\item{pdb}{a [pdb] object (if [x] is a posterior name)}
-
-\item{...}{further arguments supplied to specific methods.}
-}
-\value{
-a [pdb_reference_posterior] object.
-}
-\description{
-Reference Posterior draws and summary statistics
-}
diff --git a/rpackage/man/reference_posterior_draws_file_path.Rd b/rpackage/man/reference_posterior_draws_file_path.Rd
deleted file mode 100644
index 257fb88f..00000000
--- a/rpackage/man/reference_posterior_draws_file_path.Rd
+++ /dev/null
@@ -1,27 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/reference_posterior.R
-\name{reference_posterior_draws_file_path}
-\alias{reference_posterior_draws_file_path}
-\alias{reference_posterior_draws_file_path.pdb_posterior}
-\alias{reference_posterior_draws_file_path.character}
-\alias{reference_posterior_draws_file_path.pdb_reference_posterior_info}
-\title{Extract data for posterior}
-\usage{
-reference_posterior_draws_file_path(x, ...)
-
-\method{reference_posterior_draws_file_path}{pdb_posterior}(x, ...)
-
-\method{reference_posterior_draws_file_path}{character}(x, pdb = pdb_default(), ...)
-
-\method{reference_posterior_draws_file_path}{pdb_reference_posterior_info}(x, pdb = pdb_default(), ...)
-}
-\arguments{
-\item{x}{an object to access file path to.}
-
-\item{...}{further arguments supplied to methods.}
-
-\item{pdb}{a \code{pdb} object.}
-}
-\description{
-Extract data for posterior
-}
diff --git a/rpackage/man/reference_posterior_info.Rd b/rpackage/man/reference_posterior_info.Rd
deleted file mode 100644
index 2cb63ed0..00000000
--- a/rpackage/man/reference_posterior_info.Rd
+++ /dev/null
@@ -1,45 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/reference_posterior.R
-\name{reference_posterior_info}
-\alias{reference_posterior_info}
-\alias{pdb_reference_posterior_info}
-\alias{reference_posterior_draws_info}
-\alias{pdb_reference_posterior_draws_info}
-\alias{reference_posterior_info.pdb_posterior}
-\alias{reference_posterior_info.character}
-\alias{reference_posterior_info.list}
-\title{Reference posterior information}
-\usage{
-reference_posterior_info(x, type, pdb = pdb_default(), ...)
-
-pdb_reference_posterior_info(x, type, pdb = pdb_default(), ...)
-
-reference_posterior_draws_info(x, pdb = pdb_default(), ...)
-
-pdb_reference_posterior_draws_info(x, pdb = pdb_default(), ...)
-
-\method{reference_posterior_info}{pdb_posterior}(x, type, ...)
-
-\method{reference_posterior_info}{character}(x, type, pdb = pdb_default(), ...)
-
-\method{reference_posterior_info}{list}(x, type = NULL, pdb = NULL, ...)
-}
-\arguments{
-\item{x}{a \code{posterior} object to access the reference posterior for.}
-
-\item{type}{Type of reference posterior [draws] or [summary_statistic].}
-
-\item{pdb}{a \code{pdb} posterior database connection.}
-
-\item{...}{Currently not used.}
-}
-\description{
-Reference posterior information
-}
-\details{
-Reference posterior information on how, when and by whom
-the reference posterior was computed.
-}
-\seealso{
-reference_posterior_draws
-}
diff --git a/rpackage/man/reference_posterior_names.Rd b/rpackage/man/reference_posterior_names.Rd
deleted file mode 100644
index 7e33c50c..00000000
--- a/rpackage/man/reference_posterior_names.Rd
+++ /dev/null
@@ -1,21 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/pdb.R
-\name{reference_posterior_names}
-\alias{reference_posterior_names}
-\alias{reference_posterior_names.pdb_local}
-\title{Get all existing reference posterior names from a posterior database}
-\usage{
-reference_posterior_names(pdb = pdb_default(), type, ...)
-
-\method{reference_posterior_names}{pdb_local}(pdb = pdb_default(), type, ...)
-}
-\arguments{
-\item{pdb}{a \code{pdb} object.}
-
-\item{type}{supported reference posterior types.}
-
-\item{...}{Further argument to methods.}
-}
-\description{
-Get all existing reference posterior names from a posterior database
-}
diff --git a/rpackage/man/reference_posterior_summary_statistic.Rd b/rpackage/man/reference_posterior_summary_statistic.Rd
deleted file mode 100644
index 7a6dedef..00000000
--- a/rpackage/man/reference_posterior_summary_statistic.Rd
+++ /dev/null
@@ -1,52 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/summary_statistic.R
-\name{reference_posterior_summary_statistic}
-\alias{reference_posterior_summary_statistic}
-\alias{pdb_reference_posterior_summary_statistic}
-\alias{reference_posterior_summary_statistic.character}
-\alias{reference_posterior_summary_statistic.pdb_posterior}
-\alias{reference_posterior_summary_statistic.pdb_reference_posterior_info}
-\alias{reference_posterior_summary_statistic.list}
-\alias{reference_posterior_summary_statistics}
-\alias{pdb_reference_posterior_summary_statistics}
-\alias{reference_posterior_summary_statistics.character}
-\alias{reference_posterior_summary_statistics.pdb_posterior}
-\title{Reference posterior summary statistics}
-\usage{
-reference_posterior_summary_statistic(x, ...)
-
-pdb_reference_posterior_summary_statistic(x, ...)
-
-\method{reference_posterior_summary_statistic}{character}(x, pdb = pdb_default(), type, ...)
-
-\method{reference_posterior_summary_statistic}{pdb_posterior}(x, type, ...)
-
-\method{reference_posterior_summary_statistic}{pdb_reference_posterior_info}(x, pdb = pdb_default(), type, ...)
-
-\method{reference_posterior_summary_statistic}{list}(x, info, type, ...)
-
-reference_posterior_summary_statistics(x, ...)
-
-pdb_reference_posterior_summary_statistics(x, ...)
-
-\method{reference_posterior_summary_statistics}{character}(x, pdb = pdb_default(), ...)
-
-\method{reference_posterior_summary_statistics}{pdb_posterior}(x, ...)
-}
-\arguments{
-\item{x}{a [posterior] object or a posterior name.}
-
-\item{...}{further arguments supplied to specific methods.}
-
-\item{pdb}{a [pdb] object (if [x] is a posterior name)}
-
-\item{type}{the type of summary statistic to extract}
-
-\item{info}{a [pdb_reference_posterior_info] object}
-}
-\value{
-a [pdb_reference_posterior_summary_statistic] object.
-}
-\description{
-Reference posterior summary statistics
-}
diff --git a/rpackage/man/remove_pdb.Rd b/rpackage/man/remove_pdb.Rd
deleted file mode 100644
index 24a355b7..00000000
--- a/rpackage/man/remove_pdb.Rd
+++ /dev/null
@@ -1,49 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/remove_pdb.R
-\name{remove_pdb}
-\alias{remove_pdb}
-\alias{remove_pdb.character}
-\alias{remove_pdb.pdb_data}
-\alias{remove_pdb.pdb_data_info}
-\alias{remove_pdb.pdb_model_code}
-\alias{remove_pdb.pdb_model_info}
-\alias{remove_pdb.pdb_posterior}
-\alias{remove_pdb.pdb_reference_posterior_draws}
-\alias{remove_pdb.pdb_reference_posterior_info}
-\alias{remove_pdb.pdb_reference_posterior_summary_statistic}
-\title{Remove objects from local pdb}
-\usage{
-remove_pdb(x, pdb, ...)
-
-\method{remove_pdb}{character}(x, pdb, ...)
-
-\method{remove_pdb}{pdb_data}(x, pdb, remove_info = TRUE, ...)
-
-\method{remove_pdb}{pdb_data_info}(x, pdb, ...)
-
-\method{remove_pdb}{pdb_model_code}(x, pdb, remove_info = TRUE, ...)
-
-\method{remove_pdb}{pdb_model_info}(x, pdb, ...)
-
-\method{remove_pdb}{pdb_posterior}(x, pdb, ...)
-
-\method{remove_pdb}{pdb_reference_posterior_draws}(x, pdb, remove_info = TRUE, ...)
-
-\method{remove_pdb}{pdb_reference_posterior_info}(x, pdb, type, ...)
-
-\method{remove_pdb}{pdb_reference_posterior_summary_statistic}(x, pdb, remove_info = TRUE, ...)
-}
-\arguments{
-\item{x}{an object to remove to the pdb.}
-
-\item{pdb}{the pdb to remove from. Currently only a local pdb.}
-
-\item{...}{further arguments supplied to methods.}
-
-\item{remove_info}{should the information JSON be removed as well?}
-
-\item{type}{supported reference posterior types.}
-}
-\description{
-a function to simplify removing object from a local pdb.
-}
diff --git a/rpackage/man/run_stan.Rd b/rpackage/man/run_stan.Rd
deleted file mode 100644
index 1fd5b5b3..00000000
--- a/rpackage/man/run_stan.Rd
+++ /dev/null
@@ -1,21 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/run_stan.R
-\name{run_stan}
-\alias{run_stan}
-\alias{run_stan.pdb_posterior}
-\title{Run Stan on a posterior}
-\usage{
-run_stan(x, stan_args, ...)
-
-\method{run_stan}{pdb_posterior}(x, stan_args, ...)
-}
-\arguments{
-\item{x}{a [pdb_posterior] object.}
-
-\item{stan_args}{Arguments supplied to [rstan::stan] to compute the posterior}
-
-\item{...}{currently not in use.}
-}
-\description{
-Run Stan on a posterior
-}
diff --git a/rpackage/man/setup_pdb.Rd b/rpackage/man/setup_pdb.Rd
deleted file mode 100644
index 5a61c100..00000000
--- a/rpackage/man/setup_pdb.Rd
+++ /dev/null
@@ -1,20 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/pdb.R
-\name{setup_pdb}
-\alias{setup_pdb}
-\alias{setup_pdb.pdb_local}
-\title{Setup object specific part of pdb object}
-\usage{
-setup_pdb(pdb, ...)
-
-\method{setup_pdb}{pdb_local}(pdb, ...)
-}
-\arguments{
-\item{pdb}{a \code{pdb} object.}
-
-\item{...}{further arguments supplied to specific methods (not in use)}
-}
-\description{
-Setup object specific part of pdb object
-}
-\keyword{internal}
diff --git a/rpackage/man/subset.pdb_reference_posterior_draws.Rd b/rpackage/man/subset.pdb_reference_posterior_draws.Rd
deleted file mode 100644
index 9a2b4db9..00000000
--- a/rpackage/man/subset.pdb_reference_posterior_draws.Rd
+++ /dev/null
@@ -1,18 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/reference_posterior.R
-\name{subset.pdb_reference_posterior_draws}
-\alias{subset.pdb_reference_posterior_draws}
-\title{Subset a [pdb_reference_posterior_draws] object}
-\usage{
-\method{subset}{pdb_reference_posterior_draws}(x, variable, ...)
-}
-\arguments{
-\item{x}{a [pdb_reference_posterior_draws] to subest}
-
-\item{variable}{parameter names to subset.}
-
-\item{...}{Further arguments (not used).}
-}
-\description{
-Subset a [pdb_reference_posterior_draws] object
-}
diff --git a/rpackage/man/summary_statistic_type.Rd b/rpackage/man/summary_statistic_type.Rd
deleted file mode 100644
index c5836d8a..00000000
--- a/rpackage/man/summary_statistic_type.Rd
+++ /dev/null
@@ -1,14 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/summary_statistic.R
-\name{summary_statistic_type}
-\alias{summary_statistic_type}
-\title{Extract the type of summary statistic}
-\usage{
-summary_statistic_type(x)
-}
-\arguments{
-\item{x}{a [pdb_reference_posterior_summary_statistic]}
-}
-\description{
-Extract the type of summary statistic
-}
diff --git a/rpackage/man/thin_draws.pdb_reference_posterior_draws.Rd b/rpackage/man/thin_draws.pdb_reference_posterior_draws.Rd
deleted file mode 100644
index 03d0be6b..00000000
--- a/rpackage/man/thin_draws.pdb_reference_posterior_draws.Rd
+++ /dev/null
@@ -1,21 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/reference_posterior.R
-\name{thin_draws.pdb_reference_posterior_draws}
-\alias{thin_draws.pdb_reference_posterior_draws}
-\title{Thin draws to reduce their size and autocorrelation of the chains.}
-\usage{
-thin_draws.pdb_reference_posterior_draws(x, thin, ...)
-}
-\arguments{
-\item{x}{An R object for which the methods are defined.}
-
-\item{thin}{A positive integer specifying the period for selecting draws.}
-
-\item{...}{Arguments passed to individual methods (if applicable).}
-}
-\value{
-A thinned [pdb_reference_posterior_draws] object.
-}
-\description{
-Thin [pdb_reference_posterior_draws] objects to reduce their size and autocorrelation of the chains.
-}
diff --git a/rpackage/man/write_pdb.Rd b/rpackage/man/write_pdb.Rd
deleted file mode 100644
index 8d6d1eed..00000000
--- a/rpackage/man/write_pdb.Rd
+++ /dev/null
@@ -1,49 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/write_pdb.R
-\name{write_pdb}
-\alias{write_pdb}
-\alias{write_pdb.pdb_reference_posterior_info}
-\alias{write_pdb.pdb_reference_posterior_draws}
-\alias{write_pdb.pdb_reference_posterior_summary_statistic}
-\alias{write_pdb.pdb_data}
-\alias{write_pdb.pdb_data_info}
-\alias{write_pdb.stanmodel}
-\alias{write_pdb.pdb_model_code}
-\alias{write_pdb.pdb_model_info}
-\alias{write_pdb.pdb_posterior}
-\title{Write objects to pdb}
-\usage{
-write_pdb(x, pdb, overwrite = FALSE, ...)
-
-\method{write_pdb}{pdb_reference_posterior_info}(x, pdb, overwrite = FALSE, type, ...)
-
-\method{write_pdb}{pdb_reference_posterior_draws}(x, pdb, overwrite = FALSE, ...)
-
-\method{write_pdb}{pdb_reference_posterior_summary_statistic}(x, pdb, overwrite = FALSE, ...)
-
-\method{write_pdb}{pdb_data}(x, pdb, overwrite = FALSE, ...)
-
-\method{write_pdb}{pdb_data_info}(x, pdb, overwrite = FALSE, ...)
-
-\method{write_pdb}{stanmodel}(x, pdb, overwrite = FALSE, ...)
-
-\method{write_pdb}{pdb_model_code}(x, pdb, overwrite = FALSE, ...)
-
-\method{write_pdb}{pdb_model_info}(x, pdb, overwrite = FALSE, ...)
-
-\method{write_pdb}{pdb_posterior}(x, pdb, overwrite = FALSE, ...)
-}
-\arguments{
-\item{x}{an object to write to the pdb.}
-
-\item{pdb}{the pdb to write to. Currently only a local pdb.}
-
-\item{overwrite}{overwrite existing file?}
-
-\item{...}{further arguments supplied to methods.}
-
-\item{type}{supported reference posterior types.}
-}
-\description{
-a function to simplify writing to a local pdb.
-}
diff --git a/rpackage/man/write_to_path.Rd b/rpackage/man/write_to_path.Rd
deleted file mode 100644
index e2e1acaa..00000000
--- a/rpackage/man/write_to_path.Rd
+++ /dev/null
@@ -1,86 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/pdb.R
-\name{write_to_path}
-\alias{write_to_path}
-\alias{write_json_to_path}
-\alias{write_txt_to_path}
-\alias{write_stan_to_path}
-\alias{write_model_code_to_path}
-\title{Write objects to posteriordb}
-\usage{
-write_to_path(
-  x,
-  path,
-  type,
-  pdb,
-  name = NULL,
-  zip = FALSE,
-  info = TRUE,
-  overwrite = FALSE
-)
-
-write_json_to_path(
-  x,
-  path,
-  pdb,
-  type,
-  name = NULL,
-  zip = FALSE,
-  info = TRUE,
-  overwrite = FALSE
-)
-
-write_txt_to_path(
-  x,
-  path,
-  pdb,
-  type,
-  name = NULL,
-  zip = FALSE,
-  info = TRUE,
-  overwrite = FALSE
-)
-
-write_stan_to_path(
-  x,
-  path,
-  pdb,
-  type,
-  name = NULL,
-  zip = FALSE,
-  info = TRUE,
-  overwrite = FALSE
-)
-
-write_model_code_to_path(
-  x,
-  path,
-  pdb,
-  framework,
-  name = NULL,
-  zip = FALSE,
-  info = TRUE,
-  overwrite = FALSE
-)
-}
-\arguments{
-\item{x}{a [reference_posterior_draws] object}
-
-\item{path}{a posteriordb path.}
-
-\item{type}{Output type, [json] or [txt].}
-
-\item{pdb}{a local posteriordb object to write to}
-
-\item{name}{Used for code files and data.}
-
-\item{zip}{Should the json be zipped?}
-
-\item{info}{is this an info json?}
-
-\item{overwrite}{Should an existing file be overwritten?}
-}
-\description{
-Write objects to posteriordb
-}
-\keyword{internal}
diff --git a/rpackage/posteriordb.Rproj b/rpackage/posteriordb.Rproj
deleted file mode 100644
index 777259d2..00000000
--- a/rpackage/posteriordb.Rproj
+++ /dev/null
@@ -1,23 +0,0 @@
-Version: 1.0
-
-RestoreWorkspace: No
-SaveWorkspace: No
-AlwaysSaveHistory: Default
-
-EnableCodeIndexing: Yes
-UseSpacesForTab: Yes
-NumSpacesForTab: 2
-Encoding: UTF-8
-
-RnwWeave: Sweave
-LaTeX: pdfLaTeX
-
-AutoAppendNewline: Yes
-StripTrailingWhitespace: Yes
-
-BuildType: Package
-PackageUseDevtools: Yes
-PackageInstallArgs: --no-multiarch --with-keep.source
-PackageRoxygenize: rd,collate,namespace
-
-QuitChildProcessesOnExit: Yes


Test patch:
diff --git a/python/tests/__init__.py b/python/tests/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/python/tests/integrity_tests/__init__.py b/python/tests/integrity_tests/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/python/tests/integrity_tests/helpers.py b/python/tests/integrity_tests/helpers.py
deleted file mode 100644
index 235320cf..00000000
--- a/python/tests/integrity_tests/helpers.py
+++ /dev/null
@@ -1,40 +0,0 @@
-import collections
-
-import pytest
-
-
-def _ensure_all_distinct(dct, error_message_callable):
-    reverse_mapping = collections.defaultdict(list)
-    for key, val in dct.items():
-        reverse_mapping[val].append(key)
-
-    duplicates = {k: v for (k, v) in reverse_mapping.items() if len(v) > 1}
-
-    if len(duplicates) > 0:
-        error_msgs = "\n".join(
-            [
-                error_message_callable(duplicate_val, duplicate_names)
-                for (duplicate_val, duplicate_names) in duplicates.items()
-            ]
-        )
-        pytest.fail(error_msgs)
-
-
-def ensure_model_codes_are_distinct(dct):
-    def error_msg(code_path, names):
-        return f"""Models {", ".join(names)} had the same stan code: {code_path}"""
-
-    __tracebackhide__ = True
-
-    _ensure_all_distinct(dct, error_msg)
-
-
-def ensure_dataset_paths_are_distinct(dct):
-    def error_msg(data_file_path, names):
-        return (
-            f"""Datasets {", ".join(names)} had the same data file: {data_file_path}"""
-        )
-
-    __tracebackhide__ = True
-
-    _ensure_all_distinct(dct, error_msg)
diff --git a/python/tests/integrity_tests/test_integrity.py b/python/tests/integrity_tests/test_integrity.py
deleted file mode 100644
index ecd42aba..00000000
--- a/python/tests/integrity_tests/test_integrity.py
+++ /dev/null
@@ -1,34 +0,0 @@
-import os
-
-from . import helpers
-from posteriordb import PosteriorDatabase
-
-
-def get_posterior_db():
-    project_path = os.path.dirname(
-        os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
-    )
-    pdb_path = os.path.join(project_path, "posterior_database")
-    pdb = PosteriorDatabase(pdb_path)
-    assert len(pdb.posterior_names()) > 0
-    return pdb
-
-
-def test_models_dont_have_same_model_code():
-    pdb = get_posterior_db()
-
-    model_code_paths = {
-        model.name: model.stan_code_file_path() for model in pdb.models()
-    }
-
-    helpers.ensure_model_codes_are_distinct(model_code_paths)
-
-
-def test_datasets_dont_have_same_data():
-    pdb = get_posterior_db()
-
-    data_names = pdb.dataset_names()
-
-    data_file_paths = {name: pdb.get_dataset_path(name) for name in data_names}
-
-    helpers.ensure_dataset_paths_are_distinct(data_file_paths)
diff --git a/python/tests/test_pdb.py b/python/tests/test_pdb.py
deleted file mode 100644
index 8a572476..00000000
--- a/python/tests/test_pdb.py
+++ /dev/null
@@ -1,147 +0,0 @@
-import os
-import re
-
-from posteriordb import PosteriorDatabase, PosteriorDatabaseGithub
-from posteriordb.posterior_database_github import get_sha1_hash
-
-
-def test_posterior_database():
-    # path to ../../ which is the posterior database directory
-    project_path = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
-    pdb_path = os.path.join(project_path, "posterior_database")
-    pdb = PosteriorDatabase(pdb_path)
-
-    model_names = pdb.model_names()
-    assert len(model_names) > 0
-
-    dataset_names = pdb.dataset_names()
-    assert len(dataset_names) > 0
-
-    posterior_names = pdb.posterior_names()
-
-    assert len(posterior_names) > 0
-
-    for name in posterior_names:
-        posterior = pdb.posterior(name)
-
-        assert posterior.name is not None
-
-        # test dataset methods
-        data = posterior.data
-        assert data.name is not None
-
-        assert data.values() is not None
-        assert data.file_path() is not None
-
-        assert data.information is not None
-
-        # test that pdb.data works
-        data2 = pdb.data(data.name)
-        assert data2 is not None
-
-        # test model methods
-        model = posterior.model
-
-        assert model.name is not None
-
-        assert model.code("stan") is not None
-        assert model.code_file_path("stan") is not None
-        assert model.stan_code() is not None
-        assert model.stan_code_file_path() is not None
-
-        assert model.information is not None
-
-        # test that pdb.model works
-        model2 = pdb.model(model.name)
-        assert model2 is not None
-
-    posteriors = list(pdb.posteriors())
-    assert len(posteriors) > 0
-
-    models = list(pdb.models())
-    assert len(models) > 0
-
-    datasets = list(pdb.datasets())
-    assert len(datasets) > 0
-
-
-def test_posterior_database_github():
-    # Skip test if GITHUB_PAT not defined
-    if os.environ.get("GITHUB_PAT") is None:
-        if os.environ.get("CI"):
-            raise TypeError("GITHUB_PAT environmental variable is missing")
-        return
-
-    kwargs = {}
-    if os.environ.get("GITHUB_ACTIONS"):
-        kwargs["repo"] = os.environ.get("GITHUB_REPOSITORY", "MansMeg/posteriordb")
-        kwargs["ref"] = re.sub(
-            "^refs/heads/", "", os.environ.get("GITHUB_REF", "master")
-        )
-    pdb = PosteriorDatabaseGithub(**kwargs)
-
-    model_names = pdb.model_names()
-    assert len(model_names) > 0
-
-    dataset_names = pdb.dataset_names()
-    assert len(dataset_names) > 0
-
-    posterior_names = pdb.posterior_names()
-
-    assert len(posterior_names) > 0
-
-    for name in posterior_names:
-        posterior = pdb.posterior(name)
-
-        assert posterior.name is not None
-
-        # test dataset methods
-        data = posterior.data
-        assert data.name is not None
-
-        assert data.values() is not None
-        assert data.file_path() is not None
-
-        assert data.information is not None
-
-        # test that pdb.data works
-        data2 = pdb.data(data.name)
-        assert data2 is not None
-
-        # test model methods
-        model = posterior.model
-
-        assert model.name is not None
-
-        assert model.code("stan") is not None
-        assert model.code_file_path("stan") is not None
-        assert model.stan_code() is not None
-        assert model.stan_code_file_path() is not None
-
-        assert model.information is not None
-
-        # test that pdb.model works
-        model2 = pdb.model(model.name)
-        assert model2 is not None
-
-        # check sha1
-        model_files = [
-            (key, item["sha"])
-            for key, item in pdb._links.items()
-            if (
-                (key.with_suffix("").stem == model.name)
-                and ("/models/" in key.as_posix())
-            )
-        ]
-        for model_file_path, sha1_github in model_files:
-            sha1_file = get_sha1_hash(model_file_path)
-            assert sha1_file == sha1_github
-
-    posteriors = list(pdb.posteriors())
-    assert len(posteriors) > 0
-
-    models = list(pdb.models())
-    assert len(models) > 0
-
-    datasets = list(pdb.datasets())
-    assert len(datasets) > 0
diff --git a/rpackage/R/utils_tests.R b/rpackage/R/utils_tests.R
deleted file mode 100644
index 9bdb853d..00000000
--- a/rpackage/R/utils_tests.R
+++ /dev/null
@@ -1,42 +0,0 @@
-# Test utils - only used for tests
-
-
-#' Get path to the posterior database
-#' @noRd
-get_test_pdb_dir <- function(x) {
-  x <- getwd()
-  # If on Travis - use Travis build path
-  # To handle covr::codecov, that test package in temp folder
-  if (on_travis()) x <- Sys.getenv("TRAVIS_BUILD_DIR")
-  # If on Appveyor - use Appveyor build path
-  if (on_appveyor()) x <- Sys.getenv("APPVEYOR_BUILD_FOLDER")
-  # If on github actions, use github actions build path
-  if (on_github_actions()) x <- Sys.getenv("GITHUB_WORKSPACE")
-
-  find_local_posterior_database(x)
-}
-
-
-find_local_posterior_database <- function(x){
-  checkmate::assert_directory(x)
-  fp <- normalizePath(x)
-  while (!"posterior_database" %in% dir(fp) & basename(fp) != "") {
-    fp <- dirname(fp)
-  }
-  if (basename(fp) == "") {
-    stop2("No local posterior database in path '", x, "'.")
-  }
-  fpep <- file.path(fp, "posterior_database")
-  pdb <- pdb_local(fpep)
-  if(is_pdb_endpoint(pdb)){
-    return(fpep)
-  } else {
-    stop2("No local posterior database in path '", fpep, "'.")
-  }
-}
-
-on_travis <- function() identical(Sys.getenv("TRAVIS"), "true")
-on_appveyor <- function() identical(tolower(Sys.getenv("APPVEYOR")), "true")
-on_covr <- function() identical(Sys.getenv("R_COVR"), "true")
-on_windows <- function() identical(tolower(Sys.info()[["sysname"]]), "windows")
-on_github_actions <- function() identical(Sys.getenv("GITHUB_ACTIONS"), "true")
diff --git a/rpackage/inst/test_files/eight_schools.R b/rpackage/inst/test_files/eight_schools.R
deleted file mode 100644
index 7b7e2308..00000000
--- a/rpackage/inst/test_files/eight_schools.R
+++ /dev/null
@@ -1,3 +0,0 @@
-eight_schools <- list(J = 8L,
-                      y = as.integer(c(28, 8, -3, 7, -1, 1, 18, 12)),
-                      sigma = as.integer(c(15, 10, 16, 11, 9, 11, 10, 18)))
diff --git a/rpackage/inst/test_files/eight_schools_noncentered.stan b/rpackage/inst/test_files/eight_schools_noncentered.stan
deleted file mode 100644
index 574aaf54..00000000
--- a/rpackage/inst/test_files/eight_schools_noncentered.stan
+++ /dev/null
@@ -1,21 +0,0 @@
-data {
-  int <lower=0> J; // number of schools
-  real y[J]; // estimated treatment
-  real<lower=0> sigma[J]; // std of estimated effect
-}
-parameters {
-  vector[J] theta_trans; // transformation of theta
-  real mu; // hyper-parameter of mean
-  real<lower=0> tau; // hyper-parameter of sd
-}
-transformed parameters{
-  vector[J] theta;
-  // original theta
-  theta=theta_trans*tau+mu;
-}
-model {
-  theta_trans ~ normal (0,1);
-  y ~ normal(theta , sigma);
-  mu ~ normal(0, 5); // a non-informative prior
-  tau ~ cauchy(0, 5);
-}
diff --git a/rpackage/tests/testthat.R b/rpackage/tests/testthat.R
deleted file mode 100644
index 9b4032b2..00000000
--- a/rpackage/tests/testthat.R
+++ /dev/null
@@ -1,4 +0,0 @@
-library(testthat)
-library(posteriordb)
-
-test_check("posteriordb")
diff --git a/rpackage/tests/testthat/test-alias.R b/rpackage/tests/testthat/test-alias.R
deleted file mode 100644
index b990cbfb..00000000
--- a/rpackage/tests/testthat/test-alias.R
+++ /dev/null
@@ -1,18 +0,0 @@
-context("test-alias")
-
-test_that("posteriordb:::check_pdb indicates that github PDB is ok", {
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-  expect_silent(po1 <- posterior(x = "8schools", pdb_test))
-  expect_silent(po2 <- posterior(x = "8_schools", pdb_test))
-  expect_silent(po3 <- posterior(x = "eight_schools", pdb_test))
-
-  expect_identical(po1, po2)
-
-  expect_silent(pn <- posterior_names(pdb_test))
-  expect_silent(an <- alias_names(type = "posteriors", pdb_test))
-
-  expect_failure(checkmate::expect_choice("8schools", pn))
-  expect_success(checkmate::expect_choice("8schools", an))
-
-})
diff --git a/rpackage/tests/testthat/test-check_posterior_draws.R b/rpackage/tests/testthat/test-check_posterior_draws.R
deleted file mode 100644
index 36c90c39..00000000
--- a/rpackage/tests/testthat/test-check_posterior_draws.R
+++ /dev/null
@@ -1,25 +0,0 @@
-context("test-check_posterior_draws")
-
-test_that("test-check_posterior_draws", {
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-
-  expect_silent(rp <- reference_posterior_draws(x = "eight_schools-eight_schools_noncentered", pdb_test))
-  expect_silent(rp1 <- check_reference_posterior_draws(x = rp))
-  expect_silent(rp2 <- check_reference_posterior_draws(x = "eight_schools-eight_schools_noncentered", pdb = pdb_test))
-  po <- pdb_posterior("eight_schools-eight_schools_noncentered", pdb_test)
-  expect_silent(rp3 <- check_reference_posterior_draws(x = po))
-
-  expect_equal(rp1, rp2)
-  expect_equal(rp1, rp3)
-})
-
-test_that("check_pdb_posterior works", {
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-
-  po <- pdb_posterior("eight_schools-eight_schools_noncentered", pdb_test)
-
-  if(on_github_actions()) skip_on_os("linux") # Currently problem with stringi on ubuntu (2021-03-10)
-  expect_message(check_pdb_posterior(po, run_stan_code_checks = FALSE), regexp = "Posterior is ok.")
-})
diff --git a/rpackage/tests/testthat/test-doc-CONTRIBUTING.R b/rpackage/tests/testthat/test-doc-CONTRIBUTING.R
deleted file mode 100644
index 834f076a..00000000
--- a/rpackage/tests/testthat/test-doc-CONTRIBUTING.R
+++ /dev/null
@@ -1,141 +0,0 @@
-context("test-CONTRIBUTING.md")
-
-test_that("CONTRIBUTION.md works as usual (not testing rstan)", {
-  skip_on_cran()
-  if(on_github_actions()) skip_on_os("windows")
-
-  if(on_travis()){
-    # On Travis the package are checked in rpackage/
-    TRAVIS_BUILD_DIR <- Sys.getenv("TRAVIS_BUILD_DIR")
-    fp_to_CONTRIBUTING_md <- file.path(TRAVIS_BUILD_DIR, "doc", "CONTRIBUTING.md")
-  } else if(on_github_actions()) {
-    ACTIONS_WORKSPACE <- Sys.getenv("GITHUB_WORKSPACE")
-    fp_to_CONTRIBUTING_md <- file.path(ACTIONS_WORKSPACE, "doc", "CONTRIBUTING.md")
-  } else {
-  fp_to_CONTRIBUTING_md <- "../../../doc/CONTRIBUTING.md"
-  }
-
-  skip_if(!file.exists(fp_to_CONTRIBUTING_md))
-  # check hash
-  # If this fails, the CONTRIBUTING.md has been changed.
-  # Please check that no code has been changed or update this test suite accordingly
-  # Then change the hash to the md5 of the new updated file.
-  md5_hash <- digest::digest(readLines(fp_to_CONTRIBUTING_md), algo = "md5")
-  expect_equal(md5_hash, "10368458d4fe0e5278f01d6bebceb43c")
-
-  # Init
-  if(on_covr() & on_travis()){
-    expect_silent(pdbl <- pdb_local(path = file.path(TRAVIS_BUILD_DIR, "posterior_database")))
-  } else if(on_covr() & on_github_actions()){
-    expect_silent(pdbl <- pdb_local(path = file.path(ACTIONS_WORKSPACE, "posterior_database")))
-  } else {
-    expect_silent(pdbl <- pdb_local())
-  }
-
-  # Data
-  expect_silent(
-    x <- list(name = "test_eight_schools_data",
-              keywords = c("test_data"),
-              title = "A Test Data for the Eight Schools Model",
-              description = "The data contain data from eight schools on SAT scores.",
-              urls = "https://cran.r-project.org/web/packages/rstan/vignettes/rstan.html",
-              references = "testBiBTeX2020",
-              added_date = Sys.Date(),
-              added_by = "Stanislaw Ulam")
-  )
-  expect_silent(di <- pdb_data_info(x))
-  expect_silent(file_path <- system.file("test_files/eight_schools.R", package = "posteriordb"))
-  expect_silent(eval(parse(file_path)))
-  expect_silent(dat <- pdb_data(eight_schools, info = di))
-  expect_silent(write_pdb(dat, pdbl))
-  # remove_pdb - see below
-
-  # Model
-  expect_silent(
-    x <- list(name = "test_eight_schools_model",
-              keywords = c("test_model", "hiearchical"),
-              title = "Test Non-Centered Model for Eight Schools",
-              description = "An hiearchical model, non-centered parametrisation.",
-              urls = c("https://cran.r-project.org/web/packages/rstan/vignettes/rstan.html"),
-              framework = "stan",
-              references = NULL,
-              added_by = "Stanislaw Ulam",
-              added_date = Sys.Date())
-    )
-  expect_silent(mi <- pdb_model_info(x))
-  expect_silent(file_path <- system.file("test_files/eight_schools_noncentered.stan", package = "posteriordb"))
-  expect_silent(smc <- readLines(file_path))
-  # sm <- rstan::stan_model(model_code = smc)
-  # mc <- model_code(sm, info = mi)
-  expect_silent(mc <- model_code("eight_schools_noncentered", info = mi, framework = "stan", pdb = pdbl))
-  expect_silent(mc <- posteriordb:::`info<-`(mc, mi))
-  expect_silent(write_pdb(mc, pdbl))
-  # remove_pdb - see below
-
-
-  # Posterior
-  expect_silent(
-    x <- list(pdb_model_code = mc,
-              pdb_data = dat,
-              keywords = "posterior_keywords",
-              urls = "posterior_urls",
-              references = "posterior_references",
-              dimensions = list("dimensions" = 2, "dim" = 3),
-              reference_posterior_name = NULL,
-              added_date = Sys.Date(),
-              added_by = "Stanislaw Ulam")
-  )
-  expect_silent(po <- pdb_posterior(x, pdbl))
-  expect_silent(write_pdb(po, pdbl))
-  # remove_pdb - see below
-  expect_error(suppressMessages(check_posterior(po, run_stan_code_checks = FALSE)))
-
-  # Posterior draws
-  if(on_covr() & on_travis()){
-    expect_silent(pdbl <- pdb_local(path = file.path(TRAVIS_BUILD_DIR, "posterior_database")))
-  } else if(on_covr() & on_github_actions()){
-    expect_silent(pdbl <- pdb_local(path = file.path(ACTIONS_WORKSPACE, "posterior_database")))
-  } else {
-    expect_silent(pdbl <- pdb_local())
-  }
-  po <- posterior("test_eight_schools_data-test_eight_schools_model", pdbl)
-
-  # Access Makevar
-  expect_silent(M <- file.path(Sys.getenv("HOME"), ".R", ifelse(.Platform$OS.type == "windows", "Makevars.win", "Makevars")))
-  expect_silent(Mfile <- if(file.exists(M)) paste(readLines(M), collapse = "\n") else "")
-
-  # Setup reference posterior info ----
-  expect_silent(
-    x <- list(name = posterior_name(po),
-              inference = list(method = "stan_sampling",
-                               method_arguments = list(chains = 10,
-                                                       iter = 20000,
-                                                       warmup = 10000,
-                                                       thin = 10,
-                                                       seed = 4711,
-                                                       control = list(adapt_delta = 0.92))),
-              diagnostics = NULL,
-              checks_made = NULL,
-              comments = "This is a test reference posterior",
-              added_by = "Stanislaw Ulam",
-              added_date = Sys.Date(),
-              versions = list(rstan_version = paste("rstan", utils::packageVersion("rstan")),
-                              r_Makevars = Mfile, # This works for macosx
-                              r_version = R.version$version.string,
-                              r_session = paste(capture.output(print(sessionInfo())), collapse = "\n")))
-  )
-  expect_silent(rpi <- pdb_reference_posterior_draws_info(x))
-  # rp <- compute_reference_posterior_draws(rpi, pdbl)
-  expect_silent(rp <- reference_posterior_draws(x = "eight_schools-eight_schools_noncentered", pdbl))
-  rpi$diagnostics <- info(rp)$diagnostics
-  expect_silent(rp <- posteriordb:::`info<-`(rp, rpi))
-  expect_silent(rp <- check_reference_posterior_draws(x = rp))
-  expect_silent(write_pdb(rp, pdbl))
-  # remove_pdb - see below
-
-  # Remove test cases from the posteriordb
-  expect_silent(remove_pdb(dat, pdbl))
-  expect_silent(remove_pdb(mc, pdbl))
-  expect_silent(remove_pdb(po, pdbl))
-  expect_silent(remove_pdb(rp, pdbl))
-})
diff --git a/rpackage/tests/testthat/test-doc-README.R b/rpackage/tests/testthat/test-doc-README.R
deleted file mode 100644
index 6b0f36ca..00000000
--- a/rpackage/tests/testthat/test-doc-README.R
+++ /dev/null
@@ -1,74 +0,0 @@
-context("test-README.md")
-
-test_that("README.md works as stated", {
-  skip_on_cran()
-  if(on_github_actions()) skip_on_os("windows")
-
-  if(on_travis()){
-    # On Travis the package are checked in rpackage/
-    TRAVIS_BUILD_DIR <- Sys.getenv("TRAVIS_BUILD_DIR")
-    fp_to_README_md <- file.path(TRAVIS_BUILD_DIR, "README.md")
-  } else if(on_github_actions()) {
-    ACTIONS_WORKSPACE <- Sys.getenv("GITHUB_WORKSPACE")
-    fp_to_README_md <- file.path(ACTIONS_WORKSPACE, "README.md")
-  } else {
-    fp_to_README_md <- "../../../README.md"
-  }
-
-  skip_if(!file.exists(fp_to_README_md))
-  # check hash
-  # If this fails, the README.md has been changed.
-  # Please check that no code has been changed or update this test suite accordingly
-  # Then change the hash to the md5 of the new updated file.
-  md5_hash <- digest::digest(readLines(fp_to_README_md), algo = "md5")
-  expect_equal(md5_hash, "97859d071ca551c10e19aaec524521ad")
-
-  skip_if(is.null(github_pat()))
-
-  expect_silent(pd <- pdb_default())
-  expect_silent(pn <- posterior_names(pd))
-
-  head_pn <- c("arK-arK",
-                "arma-arma11",
-                "bball_drive_event_0-hmm_drive_0",
-                "bball_drive_event_1-hmm_drive_1",
-                "butterfly-multi_occupancy",
-                "diamonds-diamonds")
-  expect_equal(head(pn), head_pn)
-
-  expect_silent(po <- pdb_posterior("eight_schools-eight_schools_centered", pdb = pd))
-  expect_s3_class(po, "pdb_posterior")
-  expect_output(print(po))
-
-  expect_silent(sc <- pdb_stan_code(x = po))
-  expect_s3_class(sc, "pdb_model_code")
-  expect_output(print(sc))
-
-  expect_silent(sci <- info(sc))
-  expect_s3_class(sci, "pdb_model_info")
-  expect_output(print(sci))
-
-  expect_silent(dat <- pdb_data(po))
-  expect_s3_class(dat, "pdb_data")
-  expect_output(print(dat))
-
-  expect_silent(di <- info(dat))
-  expect_s3_class(di, "pdb_data_info")
-  expect_output(print(di))
-
-  expect_silent(rpd <- reference_posterior_draws(po))
-  expect_s3_class(rpd, "pdb_reference_posterior_draws")
-  expect_output(print(rpd))
-
-  expect_silent(rpi <- info(rpd))
-  expect_s3_class(rpi, "pdb_reference_posterior_info")
-  expect_output(print(rpi))
-
-  expect_silent(mi <- pdb_model_info(po))
-  expect_s3_class(mi, "pdb_model_info")
-  expect_silent(di <- pdb_data_info(po))
-  expect_s3_class(di, "pdb_data_info")
-  expect_silent(rpi <- pdb_reference_posterior_draws_info(po))
-  expect_s3_class(rpi, "pdb_reference_posterior_info")
-
-})
diff --git a/rpackage/tests/testthat/test-filter-tibble.R b/rpackage/tests/testthat/test-filter-tibble.R
deleted file mode 100644
index b8c45f44..00000000
--- a/rpackage/tests/testthat/test-filter-tibble.R
+++ /dev/null
@@ -1,15 +0,0 @@
-context("test-filter-tibble")
-
-test_that("Filter posteriors locally and on github", {
-
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-  expect_silent(po <- filter_posteriors(pdb = pdb_test, name == "eight_schools-eight_schools_noncentered"))
-  expect_silent(tblp <- posteriors_tbl_df(pdb = pdb_test))
-
-  skip_if(is.null(github_pat()))
-  expect_silent(pdb_github_test <- pdb_github("stan-dev/posteriordb/posterior_database"))
-  posteriordb:::pdb_clear_cache(pdb_github_test)
-  expect_message(po <- filter_posteriors(pdb = pdb_github_test, name == "eight_schools-eight_schools_noncentered"))
-  posteriordb:::pdb_clear_cache(pdb_github_test)
-})
diff --git a/rpackage/tests/testthat/test-info.R b/rpackage/tests/testthat/test-info.R
deleted file mode 100644
index 8fed31cf..00000000
--- a/rpackage/tests/testthat/test-info.R
+++ /dev/null
@@ -1,53 +0,0 @@
-context("test-info")
-
-test_that("info() should extract the object information", {
-
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb_local(posterior_db_path))
-  pdb_clear_cache()
-  expect_silent(po <- posterior("eight_schools-eight_schools_noncentered", pdb = pdb_test))
-
-  # Data
-  expect_silent(d <- pdb_data(po))
-  expect_silent(di1 <- pdb_data_info(po))
-  expect_silent(di2 <- info(d))
-  expect_identical(di1, di2)
-  expect_s3_class(d, "pdb_data")
-  expect_s3_class(d, "list")
-
-  # Models
-  expect_silent(m <- pdb_model_code(po, "stan"))
-  expect_silent(mi1 <- pdb_model_info(po))
-  expect_silent(mi2 <- info(m))
-  expect_identical(mi1, mi2)
-  expect_s3_class(m, "pdb_model_code")
-  expect_s3_class(m, "character")
-
-  # Reference posterior draws
-  expect_silent(rp <- pdb_reference_posterior_draws(po, "stan"))
-  expect_silent(rpi1 <- pdb_reference_posterior_draws_info(po))
-  expect_silent(rpi2 <- info(rp))
-  expect_identical(rpi1, rpi2)
-  expect_s3_class(rp, "pdb_reference_posterior_draws")
-  expect_s3_class(rp, "draws_list")
-
-})
-
-
-test_that("data info constructor ", {
-  x <- list(name = "wells_data2",
-            keywords = c("wells","arsenic","Bangladesh"),
-            title = "Factors affecting the decision to switch wells",
-            description = "Decisions of households in Bangladesh about whether to change their source of
-                     drinking water.",
-            urls = "https://github.com/stan-dev/example-models/tree/master/ARM/Ch.5",
-            references = "gelman2006data",
-            added_date = Sys.Date(),
-            data_file = "data/data/.json",
-            added_by = "Phil Clemson")
-  expect_error(di <- pdb_data_info(x))
-  x$data_file <- NULL
-  expect_silent(di <- pdb_data_info(x))
-  x$data_file <- "data/data/wells_data2.json"
-  expect_silent(di <- pdb_data_info(x))
-})
diff --git a/rpackage/tests/testthat/test-pdb-cache.R b/rpackage/tests/testthat/test-pdb-cache.R
deleted file mode 100644
index be96c59b..00000000
--- a/rpackage/tests/testthat/test-pdb-cache.R
+++ /dev/null
@@ -1,41 +0,0 @@
-context("test-pdb-cache")
-
-test_that("remove reference posterior cache", {
-
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-  posteriordb:::pdb_clear_cache(pdb_test)
-
-  expect_length(dir(pdb_test$cache_path, recursive = TRUE),0)
-
-  po <- posterior("8_schools", pdb_test)
-  expect_false(any(grepl(dir(pdb_test$cache_path, recursive = TRUE),
-                        pattern = "draws/draws/eight_schools-eight_schools_noncentered\\.json")))
-  rp <- reference_posterior_draws(po)
-  expect_true(any(grepl(dir(pdb_test$cache_path, recursive = TRUE),
-                    pattern = "draws/draws/eight_schools-eight_schools_noncentered\\.json")))
-  pdb_cache_rm(x = rp)
-  expect_false(any(grepl(dir(pdb_test$cache_path, recursive = TRUE),
-                         pattern = "draws/draws/eight_schools-eight_schools_noncentered\\.json")))
-
-})
-
-
-test_that("remove data cache", {
-
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-  pdb_clear_cache(pdb_test)
-
-  expect_length(dir(pdb_test$cache_path, recursive = TRUE),0)
-
-  po <- posterior("8_schools", pdb_test)
-  expect_false(any(grepl(dir(pdb_test$cache_path, recursive = TRUE),
-                         pattern = "data/data/eight_schools\\.json")))
-  sd <- get_data(po)
-  expect_true(any(grepl(dir(pdb_test$cache_path, recursive = TRUE),
-                        pattern = "data/data/eight_schools\\.json")))
-  pdb_cache_rm(x = sd)
-  expect_false(any(grepl(dir(pdb_test$cache_path, recursive = TRUE),
-                         pattern = "data/data/eight_schools\\.json")))
-})
diff --git a/rpackage/tests/testthat/test-pdb-check-content.R b/rpackage/tests/testthat/test-pdb-check-content.R
deleted file mode 100644
index 8f9304bd..00000000
--- a/rpackage/tests/testthat/test-pdb-check-content.R
+++ /dev/null
@@ -1,73 +0,0 @@
-context("test-pdb-check-content")
-# This is checks of the content of the database,
-# Hence it does not need to run on all systems using CI
-if(on_github_actions()) skip_on_os("windows")
-
-test_that("check_pdb_read_posteriors", {
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-  expect_silent(pdb_clear_cache(pdb_test))
-
-  expect_silent(check_pdb_read_posteriors(pdb_test))
-})
-
-
-test_that("check_pdb_read_model_code", {
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-
-  expect_silent(pl <- check_pdb_read_posteriors(pdb_test))
-  expect_silent(check_pdb_read_model_code(pl))
-})
-
-
-test_that("check_pdb_read_data", {
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-
-  # Ignore large data on Travis or Appveyor
-  if(on_travis() | on_appveyor()){
-    ignore_posterior <- "mnist-nn_rbm1bJ100"
-  } else {
-    ignore_posterior <- character(0)
-  }
-  expect_silent(pl <- posteriordb:::check_pdb_read_posteriors(pdb_test))
-
-  for (i in seq_along(pl)){
-    if(posterior_names(pl[[i]]) %in% ignore_posterior) next
-    expect_silent(check_pdb_read_data(list(pl[[i]])))
-  }
-})
-
-test_that("check_pdb_read_reference_posterior_draws", {
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-
-  expect_silent(pl <- check_pdb_read_posteriors(pdb_test))
-  expect_silent(check_pdb_read_reference_posterior_draws(pl))
-})
-
-
-test_that("check_pdb_aliases", {
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-
-  expect_silent(check_pdb_aliases(pdb_test))
-})
-
-test_that("check_pdb_references", {
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-
-  if(on_github_actions()) skip_on_os("linux") # Currently problem with stringi on ubuntu (2021-03-10)
-  expect_message(check_pdb_references(pdb_test))
-})
-
-test_that("check_pdb_model_data_ref_in_posteriors", {
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-
-  expect_silent(check_pdb_all_models_have_posterior(pdb_test))
-  expect_silent(check_pdb_all_data_have_posterior(pdb_test))
-  expect_silent(check_pdb_all_reference_posteriors_have_posterior(pdb_test))
-})
diff --git a/rpackage/tests/testthat/test-pdb.R b/rpackage/tests/testthat/test-pdb.R
deleted file mode 100644
index f40cb006..00000000
--- a/rpackage/tests/testthat/test-pdb.R
+++ /dev/null
@@ -1,91 +0,0 @@
-context("test-pdb")
-
-test_that("model_names and data_names works as expected", {
-
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-  expect_silent(posteriors <- posterior_names(pdb_test))
-  expect_silent(mn <- model_names(pdb_test))
-  expect_silent(dn <- data_names(pdb_test))
-
-  posteriors <- posteriors[grepl(x = posteriors, "-")]
-  slpdat <- unlist(lapply(strsplit(posteriors, split = "-"), FUN = function(x) x[[1]]))
-  slpmn <- unlist(lapply(strsplit(posteriors, split = "-"), FUN = function(x) x[[2]]))
-
-  expect_true(all(slpmn %in% mn))
-  expect_true(all(slpdat %in% dn))
-})
-
-
-test_that("pdb_version", {
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-  checkmate::expect_list(pdb_version(pdb_test))
-  checkmate::expect_names(names(pdb_version(pdb_test)), must.include = "sha")
-})
-
-
-test_that("pdb_local", {
-  if(on_github_actions()) skip_on_os("windows")
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdbl1 <- pdb_local(posterior_db_path))
-  if(!on_covr()) expect_silent(pdbl2 <- pdb_local())
-  expect_silent(pdbl3 <- pdb_local(path = dirname(posterior_db_path)))
-  expect_silent(pdbl4 <- pdb_local(file.path(posterior_db_path, "data", "data")))
-  expect_error(pdbl5 <- pdb_local(dirname(dirname(dirname(dirname(posterior_db_path))))))
-  if(!on_covr())expect_equal(pdbl1, pdbl2)
-  expect_equal(pdbl1, pdbl3)
-  expect_equal(pdbl1, pdbl4)
-})
-
-
-test_that("pdb_config", {
-  if(on_github_actions()) skip_on_os("windows")
-  skip_on_covr()
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdbl1 <- pdb_local())
-  expect_silent(pdbl2 <- pdb_local(posterior_db_path))
-
-  writeLines(text = c("type: \"local\""), con = ".pdb_config.yml")
-  expect_silent(pdbc1 <- pdb_config())
-  pdbc1b <- pdbc1; pdbc1b$.pdb_config.yml <- NULL
-  writeLines(text = c("type: \"local\"",
-                      paste0("path: \"", posterior_db_path, "\"")), con = ".pdb_config.yml")
-  expect_silent(pdbc2 <- pdb_config())
-  pdbc2b <- pdbc2; pdbc2b$.pdb_config.yml <- NULL
-
-  expect_silent(pdbd <- pdb_default())
-  pdbdb <- pdbd; pdbdb$.pdb_config.yml <- NULL
-
-  expect_equal(pdbl1, pdbl2)
-  expect_equal(pdbl1, pdbc1b)
-  expect_equal(pdbl1, pdbc2b)
-  expect_equal(pdbl1, pdbdb)
-
-  expect_failure(expect_equal(pdbl1, pdbc1))
-  expect_failure(expect_equal(pdbl1, pdbc2))
-  expect_failure(expect_equal(pdbc1, pdbc2))
-  expect_failure(expect_equal(pdbc1, pdbd))
-
-  expect_equal(pdbc2, pdbd)
-
-  file.remove(".pdb_config.yml")
-})
-
-
-test_that("pdb_config", {
-  if(on_github_actions()) skip_on_os("windows")
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdbl <- pdb_local(posterior_db_path))
-
-  writeLines(text = c("type: \"local\"",
-                      paste0("path: \"", posterior_db_path, "\"")), con = ".pdb_config.yml")
-  expect_silent(pdbc <- pdb_config())
-  pdbcb <- pdbc; pdbcb$.pdb_config.yml <- NULL
-
-
-  expect_output(print(pdbc), ".pdb_config.yml")
-
-  expect_equal(pdbl, pdbcb)
-  file.remove(".pdb_config.yml")
-})
diff --git a/rpackage/tests/testthat/test-pdb_github.R b/rpackage/tests/testthat/test-pdb_github.R
deleted file mode 100644
index 206ab2c0..00000000
--- a/rpackage/tests/testthat/test-pdb_github.R
+++ /dev/null
@@ -1,50 +0,0 @@
-context("test-pdb_github")
-
-test_that("posteriordb:::check_pdb indicates that github PDB is ok", {
-  skip_if(is.null(github_pat()))
-
-  expect_silent(pdb_github_test <- pdb_github("stan-dev/posteriordb/posterior_database"))
-  expect_output(print(pdb_github_test), "Posterior Database")
-  expect_output(print(pdb_github_test), "github")
-  posteriordb:::pdb_clear_cache(pdb_github_test)
-  expect_message(posteriordb:::check_pdb(pdb = pdb_github_test, posterior_idx = 1), "Posterior database is ok")
-  expect_message(posteriordb:::check_pdb(pdb = pdb_github_test, posterior_idx = 1), "Posterior database is ok")
-})
-
-test_that("model_names, data_names and posterior_names work", {
-  skip_if(is.null(github_pat()))
-
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-  posteriordb:::pdb_clear_cache(pdb_test)
-  expect_silent(nms <- posterior_names(pdb_test))
-  checkmate::expect_choice("eight_schools-eight_schools_centered", nms)
-  expect_silent(nms <- data_names(pdb = pdb_test))
-  checkmate::expect_choice("eight_schools", nms)
-  expect_silent(nms <- model_names(pdb_test))
-  checkmate::expect_choice("eight_schools_centered", nms)
-  expect_silent(nms <- reference_posterior_names(pdb_test, "draws"))
-  checkmate::expect_choice("eight_schools-eight_schools_noncentered", nms)
-
-
-  expect_silent(pdb_github_test <- pdb_github("stan-dev/posteriordb/posterior_database"))
-  posteriordb:::pdb_clear_cache(pdb_github_test)
-  expect_silent(nms <- posterior_names(pdb_github_test))
-  checkmate::expect_choice("eight_schools-eight_schools_centered", nms)
-  expect_silent(nms <- data_names(pdb = pdb_github_test))
-  checkmate::expect_choice("eight_schools", nms)
-  expect_silent(nms <- model_names(pdb_github_test))
-  checkmate::expect_choice("eight_schools_centered", nms)
-  expect_silent(nms <- reference_posterior_names(pdb_github_test, "draws"))
-  checkmate::expect_choice("eight_schools-eight_schools_noncentered", nms)
-  posteriordb:::pdb_clear_cache(pdb_github_test)
-})
-
-
-test_that("pdb_default is github", {
-  skip_if(is.null(github_pat()))
-
-  expect_silent(pdb_default_test <- pdb_default())
-  expect_silent(pdb_github_test <- pdb_github("stan-dev/posteriordb/posterior_database"))
-  expect_equal(pdb_default_test, pdb_github_test)
-})
diff --git a/rpackage/tests/testthat/test-posterior-getters.R b/rpackage/tests/testthat/test-posterior-getters.R
deleted file mode 100644
index f38a7297..00000000
--- a/rpackage/tests/testthat/test-posterior-getters.R
+++ /dev/null
@@ -1,138 +0,0 @@
-context("test-posterior-getters")
-
-test_that("Check that all posteriors can access stan_data and stan_code", {
-
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-
-  expect_silent(po <- posterior("eight_schools-eight_schools_noncentered", pdb = pdb_test))
-
-  # Test stan_data_file_path
-  expect_silent(sdfp <- stan_data_file_path(po))
-  expect_true(file.exists(sdfp))
-  if(!on_windows()) expect_true(grepl(pattern = tempdir(), x = sdfp))
-  expect_equal(posteriordb:::get_file_extension(sdfp), "json")
-  expect_silent(jsonlite::read_json(sdfp))
-
-  # Test data_info
-  expect_silent(di <- data_info(po))
-  expect_s3_class(di, "pdb_data_info")
-  expect_output(print(di), "Data: eight_schools")
-
-  # Test model_code
-  expect_silent(mcfp <- model_code_file_path(po, "stan"))
-  expect_true(file.exists(mcfp))
-  if(!on_windows()) expect_true(grepl(pattern = tempdir(), x = mcfp))
-  expect_equal(posteriordb:::get_file_extension(mcfp), "stan")
-  expect_silent(scfp <- stan_code_file_path(po))
-  expect_equal(scfp, mcfp)
-
-  # Test model_code
-  expect_silent(mc <- model_code(po, framework = "stan"))
-  expect_s3_class(mc, "pdb_model_code")
-  expect_output(print(mc), "data \\{")
-  expect_output(print(mc), "parameters \\{")
-  expect_output(print(mc), "model \\{")
-
-  # Test stan_code
-  expect_silent(sc <- stan_code(po))
-  expect_s3_class(sc, "pdb_model_code")
-  expect_equal(sc, mc)
-
-  # Test model_info
-  expect_silent(mi <- model_info(po))
-  expect_s3_class(mi, "pdb_model_info")
-  expect_output(print(mi), "Model: eight_schools_noncentered")
-
-  expect_output(print(po), "Posterior")
-
-  # Get posteriors draws directly
-  expect_silent(gsd <- reference_posterior_draws(po))
-  expect_silent(gsi <- reference_posterior_draws_info(po))
-
-})
-
-
-
-test_that("Check access only with posterior name", {
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-
-  # Test stan_data_file_path
-  expect_silent(di <- data_info("eight_schools", pdb_test))
-  expect_silent(d1 <- get_data("eight_schools", pdb_test))
-  expect_silent(d2 <- get_data(di, pdb_test))
-  expect_identical(d1,d2)
-  expect_silent(sdfp <- data_file_path("eight_schools", pdb_test))
-  expect_silent(sdfp <- data_file_path(di, pdb_test))
-  expect_true(file.exists(sdfp))
-
-  # Test model_code/stan_code
-  expect_silent(mi <- model_info("eight_schools_noncentered", pdb = pdb_test, framework = "stan"))
-  expect_silent(sc1 <- stan_code("eight_schools_noncentered", pdb = pdb_test))
-  expect_silent(sc2 <- stan_code(mi, pdb = pdb_test))
-  expect_identical(sc1,sc2)
-  expect_silent(mcfp <- model_code_file_path("eight_schools_noncentered", pdb = pdb_test, framework = "stan"))
-  expect_silent(mcfp <- model_code_file_path(mi, pdb = pdb_test, framework = "stan"))
-  expect_true(file.exists(mcfp))
-
-  # Test reference_posterior
-  expect_silent(gsi <- reference_posterior_draws_info("eight_schools-eight_schools_noncentered", pdb = pdb_test))
-  expect_silent(gsd1 <- reference_posterior_draws("eight_schools-eight_schools_noncentered", pdb = pdb_test))
-  expect_silent(gsd2 <- reference_posterior_draws(x = gsi, pdb = pdb_test))
-  expect_identical(gsd1,gsd2)
-  expect_silent(gsdfp <- reference_posterior_draws_file_path("eight_schools-eight_schools_noncentered", pdb = pdb_test))
-  expect_silent(gsdfp <- reference_posterior_draws_file_path(gsi, pdb = pdb_test))
-})
-
-
-
-test_that("Check access only with posterior name and default pdb", {
-
-  skip_if(is.null(github_pat()))
-
-  # Test stan_data_file_path
-  expect_silent(di <- data_info("eight_schools"))
-  expect_silent(d1 <- get_data("eight_schools"))
-  expect_silent(d2 <- get_data(di))
-  expect_silent(sdfp <- data_file_path("eight_schools"))
-  expect_silent(sdfp <- data_file_path(di))
-
-  # Test model_code/stan_code
-  expect_silent(mi <- model_info("eight_schools_noncentered", framework = "stan"))
-  expect_silent(sc1 <- stan_code("eight_schools_noncentered"))
-  expect_silent(sc2 <- stan_code(mi))
-  expect_silent(mcfp <- model_code_file_path("eight_schools_noncentered", framework = "stan"))
-  expect_silent(mcfp <- model_code_file_path(mi, framework = "stan"))
-
-  # Test reference_posterior
-  expect_silent(gsi <- reference_posterior_draws_info("eight_schools-eight_schools_noncentered"))
-  expect_silent(gsd1 <- reference_posterior_draws("eight_schools-eight_schools_noncentered"))
-  expect_silent(gsd2 <- reference_posterior_draws(x = gsi))
-  expect_silent(gsdfp <- reference_posterior_draws_file_path("eight_schools-eight_schools_noncentered"))
-  expect_silent(gsdfp <- reference_posterior_draws_file_path(gsi))
-
-})
-
-
-
-test_that("Check that model_code, data and reference_posteriors contain a pdb attr", {
-
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-
-  expect_silent(po <- posterior("eight_schools-eight_schools_noncentered", pdb = pdb_test))
-  expect_identical(pdb(po), pdb_test)
-
-  expect_silent(d <- get_data(po))
-  expect_identical(pdb(d), pdb_test)
-
-  expect_silent(mc <- stan_code(po))
-  expect_identical(pdb(mc), pdb_test)
-
-  expect_silent(rp <- reference_posterior_draws(po))
-  expect_identical(pdb(rp), pdb_test)
-
-})
diff --git a/rpackage/tests/testthat/test-posterior_names.R b/rpackage/tests/testthat/test-posterior_names.R
deleted file mode 100644
index e864a2a5..00000000
--- a/rpackage/tests/testthat/test-posterior_names.R
+++ /dev/null
@@ -1,11 +0,0 @@
-context("test-posterior_names")
-
-test_that("posterior_names handels list of objects", {
-
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-  expect_silent(pns <- posterior_names(pdb_test, pdb_test))
-  expect_silent(pns_list <- posterior_names(list(pdb_test, pdb_test)))
-  expect_equal(pns_list[[1]], pns)
-
-})
diff --git a/rpackage/tests/testthat/test-print.R b/rpackage/tests/testthat/test-print.R
deleted file mode 100644
index 64a2641c..00000000
--- a/rpackage/tests/testthat/test-print.R
+++ /dev/null
@@ -1,10 +0,0 @@
-context("test-print")
-
-test_that("All PPFs are printed", {
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-  expect_silent(po <- posterior("eight_schools-eight_schools_noncentered", pdb = pdb_test))
-
-  expect_output(print(model_info(po)), "stan")
-
-})
diff --git a/rpackage/tests/testthat/test-reference_posterior.R b/rpackage/tests/testthat/test-reference_posterior.R
deleted file mode 100644
index 518af0ec..00000000
--- a/rpackage/tests/testthat/test-reference_posterior.R
+++ /dev/null
@@ -1,52 +0,0 @@
-context("test-pdb-reference_posterior")
-
-test_that("Check that reference_posterior works as expected", {
-
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-  expect_silent(po <- posterior("eight_schools-eight_schools_centered", pdb_test))
-  expect_silent(gsi1 <- reference_posterior_info(po, type = "draws"))
-  expect_s3_class(gsi1, "pdb_reference_posterior_info")
-  expect_silent(po <- posterior("eight_schools-eight_schools_noncentered", pdb_test))
-  expect_silent(gsi2 <- reference_posterior_draws_info(po))
-  expect_s3_class(gsi2, "pdb_reference_posterior_info")
-  expect_identical(gsi1, gsi2)
-  expect_silent(gsi3 <- reference_posterior_draws_info("eight_schools-eight_schools_centered", pdb_test))
-  expect_s3_class(gsi3, "pdb_reference_posterior_info")
-  expect_identical(gsi1, gsi3)
-
-  expect_output(print(gsi1), "Posterior: eight_schools-eight_schools_noncentered")
-  expect_output(print(gsi1), "Method: stan_sampling ")
-  expect_output(print(gsi1), "Arguments:")
-
-
-  expect_silent(po <- posterior("eight_schools-eight_schools_centered", pdb_test))
-  expect_silent(pd1 <- reference_posterior_draws(x = po))
-  expect_s3_class(pd1, "pdb_reference_posterior_draws")
-  expect_s3_class(pd1, "draws_list")
-  expect_silent(po <- posterior("eight_schools-eight_schools_noncentered", pdb_test))
-  expect_silent(pd2 <- reference_posterior_draws(x = po))
-  expect_identical(pd1, pd2)
-  expect_silent(pd3 <- reference_posterior_draws("eight_schools-eight_schools_centered", pdb_test))
-  expect_s3_class(pd3, "pdb_reference_posterior_draws")
-  expect_identical(pd1, pd3)
-
-  expect_silent(gsdfp <- reference_posterior_draws_file_path(po))
-  expect_true(file.exists(gsdfp))
-
-  expect_output(print(pd1), "Posterior: eight_schools-eight_schools_noncentered")
-
-  expect_output(sf <- summary(pd1), "Posterior: eight_schools-eight_schools_noncentered")
-  expect_output(st1 <- summary(subset(pd1, "theta[1]")), "Posterior: eight_schools-eight_schools_noncentered")
-  expect_failure(expect_equal(sf, st1))
-
-  expect_silent(pd1thin <- thin_draws.pdb_reference_posterior_draws(x = pd1, thin = 2))
-  expect_equal(posterior::ndraws(pd1thin), posterior::ndraws(pd1)/2)
-
-  expect_silent(po <- posterior("prideprejustice_chapter-ldaK5", pdb_test))
-  expect_error(gs <- reference_posterior_draws(po),
-               regexp = "There is currently no reference posterior for this posterior.")
-  expect_error(gs <- reference_posterior_draws(po),
-               regexp = "There is currently no reference posterior for this posterior.")
-})
diff --git a/rpackage/tests/testthat/test-reference_posterior_summary_statistic.R b/rpackage/tests/testthat/test-reference_posterior_summary_statistic.R
deleted file mode 100644
index c4a2c671..00000000
--- a/rpackage/tests/testthat/test-reference_posterior_summary_statistic.R
+++ /dev/null
@@ -1,66 +0,0 @@
-context("test-pdb-reference_posterior_summary_statistics")
-
-test_that("Check that reference_posterior_summary_statistics work as expected", {
-
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-  expect_silent(po <- posterior("eight_schools-eight_schools_noncentered", pdb_test))
-  expect_silent(rpssi1 <- reference_posterior_info(po, type = "mean"))
-  expect_s3_class(rpssi1, "pdb_reference_posterior_info")
-  expect_silent(rpssi3 <- reference_posterior_info("eight_schools-eight_schools_noncentered", pdb_test, type = "mean"))
-  expect_identical(rpssi1, rpssi3)
-
-  expect_output(print(rpssi1), "Posterior: eight_schools-eight_schools_noncentered")
-
-  expect_silent(rpm1 <- reference_posterior_summary_statistic(x = po, type = "mean"))
-  expect_silent(rpm2 <- reference_posterior_summary_statistics(x = po))
-  expect_identical(rpm1, rpm2$mean)
-
-  expect_output(print(rpm1), "Posterior: eight_schools-eight_schools_noncentered")
-
-  expect_silent(po <- posterior("prideprejustice_chapter-ldaK5", pdb_test))
-  expect_error(rpm <- reference_posterior_summary_statistic(po, type = "mean"),
-               regexp = "There is currently no reference posterior for this posterior.")
-})
-
-
-
-test_that("compute and write summary_statistics", {
-  if(on_github_actions()) skip_on_os("windows")
-
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-  expect_silent(po <- posterior("eight_schools-eight_schools_noncentered", pdb_test))
-  expect_silent(rpd <- reference_posterior_draws(po))
-
-  expect_silent(rpdc <- check_summary_statistics_draws(x = rpd))
-  expect_silent(rpm <- compute_reference_posterior_summary_statistic(rpdc, "mean"))
-  expect_silent(rpmi <- info(rpm))
-
-  # Setup posterior
-  # This is needed to access the created reference posterior
-  # since it uses posterior() to access the test reference posterior
-  po$name <- "test_data-test_model"
-  po$reference_posterior_name <- po$name
-  write_pdb(po, pdb_test)
-
-  # Test write gsd
-  info(rpm)$name <- "test_data-test_model"
-  expect_silent(write_pdb(rpm, pdb_test))
-  expect_error(write_pdb(rpm, pdb_test))
-  expect_silent(write_pdb(rpm, pdb_test, overwrite = TRUE))
-
-  expect_silent(rpt <- pdb_reference_posterior_summary_statistics(x = "test_data-test_model", pdb = pdb_test))
-  expect_equal(rpt$mean, rpm, tolerance = 0.000000000000001)
-  expect_identical(info(rpm), info(rpt$mean))
-  expect_identical(rpm$names, rpt$mean$names)
-
-  # Remove rpd
-  expect_silent(remove_pdb(rpt$mean, pdb = pdb_test))
-  pdb_clear_cache(pdb_test)
-  expect_error(pdb_reference_posterior_draws("test_data-test_model", pdb_test))
-
-  # Cleanup
-  remove_pdb(po, pdb_test)
-})
diff --git a/rpackage/tests/testthat/test-travis-envir.R b/rpackage/tests/testthat/test-travis-envir.R
deleted file mode 100644
index 5f392da4..00000000
--- a/rpackage/tests/testthat/test-travis-envir.R
+++ /dev/null
@@ -1,11 +0,0 @@
-context("test-travis-envir")
-
-test_that("Environmental variable TRAVIS_BUILD_DIR exist on Travis CI", {
-  if(on_github_actions()) skip_on_os("windows")
-
-  if(on_travis()){
-    expect_failure(expect_equal(Sys.getenv("TRAVIS_BUILD_DIR"), expected = ""))
-  } else {
-    expect_true(TRUE) # To give a nice test pass when run locally
-  }
-})
diff --git a/rpackage/tests/testthat/test-write-pdb.R b/rpackage/tests/testthat/test-write-pdb.R
deleted file mode 100644
index b8f7bca8..00000000
--- a/rpackage/tests/testthat/test-write-pdb.R
+++ /dev/null
@@ -1,173 +0,0 @@
-context("test-write-pdb")
-
-test_that("write data", {
-
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-  expect_silent(po <- posterior("eight_schools-eight_schools_centered", pdb_test))
-  expect_silent(d <- get_data(po))
-
-  # Test write data
-  di <- info(d); di$name <- "test_data"; info(d) <- di
-  expect_error(write_pdb(d, pdb_test))
-  di$data_file <- "data/data/test_data.json"; info(d) <- di
-  expect_silent(write_pdb(d, pdb_test))
-  expect_error(write_pdb(d, pdb_test))
-  expect_silent(write_pdb(d, pdb_test, overwrite = TRUE))
-
-  # Test write data info
-  di$name <- "test_data"
-  di$title <- di$description <- "Test data"
-  di$data_file <- "data/data/test_data.json"
-
-  expect_silent(write_pdb(di, pdb_test, overwrite = TRUE))
-  expect_error(write_pdb(di, pdb_test))
-  expect_silent(write_pdb(di, pdb_test, overwrite = TRUE))
-
-  info(d) <- di
-  expect_silent(dt <- pdb_data("test_data", pdb_test))
-  expect_identical(d, dt)
-  expect_silent(dti <- pdb_data_info("test_data", pdb_test))
-
-  # Remove test_data
-  expect_silent(remove_pdb(x = dt, pdb = pdb_test))
-  pdb_clear_cache(pdb_test)
-  expect_error(pdb_data("test_data", pdb_test))
-  expect_error(pdb_data_info("test_data", pdb_test))
-})
-
-
-test_that("write model", {
-
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-  expect_silent(po <- posterior("eight_schools-eight_schools_centered", pdb_test))
-  expect_silent(sc <- stan_code(po))
-
-  # Test write model info
-  mi <- info(sc)
-  mi$name <- "test_model"
-  mi$title <- mi$description <- "Test model"
-  mi$model_implementations <- list(stan = list(model_code = "models/stan/test_model.stan"))
-
-  # Test write model
-  info(sc) <- mi
-  expect_silent(write_pdb(sc, pdb_test, overwrite = TRUE))
-  expect_error(write_pdb(sc, pdb_test))
-  expect_silent(write_pdb(sc, pdb_test, overwrite = TRUE))
-
-  expect_silent(sct <- pdb_stan_code("test_model", pdb_test))
-  expect_identical(sc, sct)
-
-  # Remove model
-  expect_silent(remove_pdb(sc, pdb = pdb_test))
-  pdb_clear_cache(pdb_test)
-  expect_error(pdb_model_code("test_model", pdb_test, "stan"))
-  expect_error(pdb_model_info("test_model", pdb_test))
-
-  # Write model info
-  expect_silent(write_pdb(mi, pdb_test))
-  expect_error(write_pdb(mi, pdb_test))
-  expect_silent(write_pdb(mi, pdb_test, overwrite = TRUE))
-
-  expect_silent(mit <- pdb_model_info("test_model", pdb_test))
-  expect_identical(mi, mit)
-
-  # Remove model info
-  expect_silent(remove_pdb(mi, pdb = pdb_test))
-  pdb_clear_cache(pdb_test)
-  expect_error(pdb_model_info("test_model", pdb_test))
-})
-
-
-
-
-
-test_that("write posterior", {
-
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-  expect_silent(po <- posterior("eight_schools-eight_schools_centered", pdb_test))
-  expect_silent(sc <- stan_code(po))
-  expect_silent(d <- pdb_data(po))
-
-  # Test write model info
-  info(sc)$name <- "test_model"
-  info(d)$name <- "test_data"
-  info(d)$data_file <- "data/data/test_data.json"
-
-  # Test write gsd
-  po$name <- "test_data-test_model"
-  po$model_name <- "test_model"
-  po$data_name <- "test_data"
-  po["reference_posterior_name"] <- list(NULL)
-  po$model_info <- info(sc)
-  po$data_info <- info(d)
-
-  expect_silent(write_pdb(po, pdb_test))
-  expect_error(write_pdb(po, pdb_test))
-  expect_silent(write_pdb(po, pdb_test, overwrite = TRUE))
-
-  # Test that we get identical posteriors
-  write_pdb(d, pdb_test)
-  write_pdb(sc, pdb_test)
-  expect_silent(pot <- posterior("test_data-test_model", pdb_test))
-  expect_identical(po, pot)
-
-  # Remove posterior
-  expect_silent(remove_pdb(pot, pdb = pdb_test))
-  pdb_clear_cache(pdb_test)
-  expect_error(posterior("test_data-test_model", pdb_test))
-
-  remove_pdb(sc, pdb = pdb_test)
-  remove_pdb(d, pdb = pdb_test)
-
-})
-
-
-
-test_that("write reference_posterior", {
-  if(on_github_actions()) skip_on_os("windows")
-
-  posterior_db_path <- posteriordb:::get_test_pdb_dir()
-  expect_silent(pdb_test <- pdb(posterior_db_path))
-  expect_silent(po <- posterior("eight_schools-eight_schools_centered", pdb_test))
-  expect_silent(gsi <- reference_posterior_draws_info(po))
-  expect_silent(gsd <- reference_posterior_draws(po))
-
-  # Setup posterior
-  # This is needed to access the created reference posterior
-  # since it uses posterior() to access the test reference posterior
-  po$name <- "test_data-test_model"
-  po$reference_posterior_name <- po$name
-  write_pdb(po, pdb_test)
-
-  # Test write gsd
-  info(gsd)$name <- "test_data-test_model"
-  expect_silent(write_pdb(gsd, pdb_test))
-  expect_error(write_pdb(gsd, pdb_test))
-  expect_silent(write_pdb(gsd, pdb_test, overwrite = TRUE))
-
-  expect_silent(rpt <- pdb_reference_posterior_draws(x = "test_data-test_model", pdb_test))
-
-  expect_identical(info(gsd)$added_by, info(rpt)$added_by)
-  expect_identical(gsd, rpt)
-
-  # Remove rpd
-  expect_silent(remove_pdb(rpt, pdb = pdb_test))
-  pdb_clear_cache(pdb_test)
-  expect_error(pdb_reference_posterior_draws("test_data-test_model", pdb_test))
-
-  # Test write gsi
-  gsi$name <- "test_data-test_model"
-  expect_silent(write_pdb(gsi, pdb_test, type = "draws"))
-  expect_error(write_pdb(gsi, pdb_test, type = "draws"))
-  expect_silent(write_pdb(gsi, pdb_test, overwrite = TRUE, type = "draws"))
-
-  expect_silent(rpi <- pdb_reference_posterior_draws_info(x = "test_data-test_model", pdb_test))
-  expect_identical(gsi, rpi)
-  expect_silent(remove_pdb(rpi, pdb = pdb_test, type = "draws"))
-
-  # Cleanup
-  remove_pdb(po, pdb_test)
-})
diff --git a/rpackage/tests/testthat/test_files/test_model.rds b/rpackage/tests/testthat/test_files/test_model.rds
deleted file mode 100644
index b9538ad8..00000000
Binary files a/rpackage/tests/testthat/test_files/test_model.rds and /dev/null differ
diff --git a/tests/R/add_posterior_to_db.R b/tests/R/add_posterior_to_db.R
deleted file mode 100644
index c2960ea9..00000000
--- a/tests/R/add_posterior_to_db.R
+++ /dev/null
@@ -1,101 +0,0 @@
-library(posteriordb)
-# remotes::install_github("stan-dev/posterior")
-library(posterior)
-
-# Use local pdb to write posterior
-pdb <- pdb_local()
-
-# General info
-added_by <- "Mans Magnusson"
-
-# Data info
-data_name <- "eight_schools"
-data_keywords <- c("bda3_example")
-data_title <- "The 8 schools dataset of Rubin (1981)"
-data_description <- "A study for the Educational Testing Service to analyze the effects of
-                     special coaching programs on test scores.
-                     See Gelman et. al. (2014), Section 5.5 for details."
-data_urls <- c("http://www.stat.columbia.edu/~gelman/arm/examples/schools")
-data_references <- c("rubin1981estimation", "gelman2013bayesian")
-
-# Data
-txt <- readLines("posterior_database/data/data-raw/eight_schools/eight_schools.R")
-eval(parse(text = txt));
-dat <- eight_schools
-
-
-# Model
-model_name <- "eight_schools_noncentered"
-model_keywords <- c("hiearchical")
-model_title <- "A non-centered hiearchical model for 8 schools"
-model_description <- "A non-centered hiearchical model for the 8 schools example of Rubin (1981)"
-model_urls <- c("http://www.stat.columbia.edu/~gelman/arm/examples/schools")
-model_references <- c("rubin1981estimation", "gelman2013bayesian")
-model_prior_keywords <- "stan_recommended_35dbfe6"
-
-# Model code
-stan_model_code <- readLines("posterior_database/models/stan/eight_schools_noncentered.stan")
-
-# Posterior
-posterior_keywords <- c("stan_benchmark")
-posterior_urls <- c(NULL)
-posterior_references <- c("rubin1981estimation", "gelman2013bayesian")
-dimensions <- list(theta = 8L, mu = 1L, tau = 1L)
-posterior_name <- paste0(data_name, "-", model_name)
-
-
-
-## Create objects ----
-# Create data_info_object ----
-di <- list(name = data_name,
-           keywords = data_keywords,
-           title = data_title,
-           description = data_description,
-           urls = data_urls,
-           data_file = paste0("data/data/", data_name, ".json"),
-           references = data_references,
-           added_date = Sys.Date(),
-           added_by = added_by)
-di <- pdb_data_info(di)
-
-# Create data object
-dat <- pdb_data(dat, info = di)
-
-# Add model to pdb ----
-mi <- list(name = model_name,
-           keywords = model_keywords,
-           title = model_title,
-           prior = list(keywords = model_prior_keywords),
-           description = model_description,
-           urls = model_urls,
-           model_implementations =
-             list(stan = list(model_code = paste0("models/stan/", model_name, ".stan"))),
-           references = model_references,
-           added_date = Sys.Date(),
-           added_by = added_by)
-mi <- pdb_model_info(mi)
-
-# Create stan model----
-sc <- rstan::stan_model(model_name = model_name, model_code = stan_model_code)
-mc <- pdb_model_code(x = sc, info = mi)
-
-# Add posterior to pdb ----
-po <- list(name = paste0(data_name, "-", model_name),
-           keywords = posterior_keywords,
-           urls = posterior_urls,
-           model_name = model_name,
-           data_name = data_name,
-           reference_posterior_name = NULL,
-           references = posterior_references,
-           dimensions = dimensions,
-           model_info = mi,
-           data_info = di,
-           pdb = pdb,
-           added_date = Sys.Date(),
-           added_by = added_by)
-po <- pdb_posterior(po)
-
-# Write objects to pdb ----
-write_pdb(dat, pdb, overwrite = TRUE)
-write_pdb(mc, pdb, overwrite = TRUE)
-write_pdb(po, pdb, overwrite = TRUE)
diff --git a/tests/R/add_reference_posterior_to_db.R b/tests/R/add_reference_posterior_to_db.R
deleted file mode 100644
index 664fda84..00000000
--- a/tests/R/add_reference_posterior_to_db.R
+++ /dev/null
@@ -1,38 +0,0 @@
-library(rstan)
-library(posteriordb)
-library(posterior)
-
-# Setup refernce posterior info object
-mvfp <- file.path(file.path(Sys.getenv("HOME"), ".R"), ifelse(.Platform$OS.type == "windows", "Makevars.win", "Makevars"))
-versions <- list(rstan_version = paste("rstan", utils::packageVersion("rstan")),
-                 r_Makevars = paste(readLines(mvfp), collapse = "\n"),
-                 r_version = R.version.string,
-                 r_session = paste(capture.output(sessionInfo()), collapse = "\n"))
-
-rp_info <- list(name = "eight_schools-eight_schools_noncentered",
-                inference = list(
-                  method = "stan_sampling",
-                  method_arguments =
-                    list(chains = 10,
-                      iter = 20000,
-                      warmup = 10000,
-                      thin = 10,
-                      seed = 4711,
-                      control = list(adapt_delta = 0.95))),
-                diagnostics = NULL,
-                checks_made = NULL,
-                comments = NULL,
-                added_by = "Måns Magnusson",
-                added_date = Sys.Date(),
-                versions = versions)
-rpi <- reference_posterior_info(rp_info)
-
-# Run model
-pdb <- pdb_local()
-rfd <- posteriordb:::compute_reference_posterior_draws_stan_sampling(rpi = rpi, pdb)
-
-# Check the reference posterior for the reference posterior definition
-rpc <- check_reference_posterior_draws(x = rfd)
-
-# Write the reference posterior to DB
-write_pdb(x = rpc, pdb, overwrite = TRUE)
diff --git a/tests/check_posteriordb_content.R b/tests/check_posteriordb_content.R
new file mode 100644
index 00000000..63fc7d36
--- /dev/null
+++ b/tests/check_posteriordb_content.R
@@ -0,0 +1,15 @@
+# remotes::install_github("stan-dev/posteriordb-r")
+library(posteriordb)
+source("tests/check_posteriordb_content_functions.R")
+pdbl <- pdb_local("posterior_database")
+status_code <- check_pdb(pdbl, run_stan_code_checks = FALSE)
+
+# Run Stan code for changed or added models
+added_modified_paths <- strsplit(readLines(con = "added_modified.txt"), " ")[[1]]
+posteriors_to_check <- get_posteriors_from_paths(paths = added_modified_paths, pdbl)
+if(length(posteriors_to_check) > 0){
+  status_code2 <- check_pdb(pdbl, posterior_names_to_check = posteriors_to_check, run_stan_code_checks = TRUE)
+  status_code <- max(status_code, status_code2)
+}
+
+q(status = status_code)
diff --git a/tests/check_posteriordb_content_functions.R b/tests/check_posteriordb_content_functions.R
new file mode 100644
index 00000000..e563bd95
--- /dev/null
+++ b/tests/check_posteriordb_content_functions.R
@@ -0,0 +1,55 @@
+#' Returns posteriors from paths
+#'
+#' @details
+#' The function takes paths to files in the posterior
+#' database and return the posteriors that uses these parts.
+#'
+#' The point is to extract what posteriors that need to be
+#' checked more thorough in the CI.
+#'
+get_posteriors_from_paths <- function(paths, pdb){
+  pns <- posteriordb::posterior_names(pdbl)
+  mns <- posteriordb::model_names(pdbl)
+  dns <- posteriordb::data_names(pdbl)
+
+  full_pns <- character(0)
+  for(i in seq_along(paths)){
+    if(grepl("posterior_database/data/", x = paths[i])){
+      dn <- strsplit(basename(paths[i]), split = "\\.")[[1]][1]
+      pdbd <- try(pdb_data(dn, pdb))
+      if(!inherits(pdbd, "try-error")) full_pns <- c(full_pns, posterior_names(x = pdbd))
+    }
+    if(grepl("posterior_database/models/", x = paths[i])){
+      mn <- strsplit(basename(paths[i]), split = "\\.")[[1]][1]
+      pdbm <- try(pdb_stan_code(mn, pdb))
+      if(!inherits(pdbm, "try-error")) full_pns <- c(full_pns, posterior_names(x = pdbm))
+    }
+    if(grepl("posterior_database/posteriors/", x = paths[i])){
+      po <- strsplit(basename(paths[i]), split = "\\.")[[1]][1]
+      pdbpo <- try(pdb_posterior(po, pdb))
+      if(!inherits(pdbpo, "try-error")) full_pns <- c(full_pns, posterior_names(pdbpo))
+    }
+    if(grepl("posterior_database/reference_posteriors/", x = paths[i])){
+      rpd <- strsplit(basename(paths[i]), split = "\\.")[[1]][1]
+      pdbpo <- try(pdb_posterior(rpd, pdb))
+      if(!inherits(pdbpo, "try-error")) full_pns <- c(full_pns, posterior_names(pdbpo))
+    }
+  }
+  return(unique(full_pns))
+}
+
+if(FALSE){
+  # Test cases
+  pdbl <- pdb_local()
+  paths <- c("posterior_database/data/info/arma.info.json",
+             "posterior_database/models/stan/accel_splines.stan",
+             "posterior_database/posteriors/GLM_Poisson_Data-GLM_Poisson_model.json",
+             "posterior_database/posteriors/arma-arma11.json",
+             "posterior_database/data/data/radon_mn.json.zip",
+             "posterior_database/reference_posteriors/summary_statistics/mean/info/earnings-logearn_logheight_male.info.json")
+  res <- get_posteriors_from_paths(paths, pdb = pdbl)
+
+  paths <- c(".github/workflows/posteriordb_content.yml", "tests/check_posteriordb_content.R", "posterior_database/models/stan/accel_splines.stan")
+  res <- get_posteriors_from_paths(paths, pdb = pdbl)
+
+}