Skip to content

Commit

Permalink
adding prior_mixture() and spike-and-slab style model-averaging upg…
Browse files Browse the repository at this point in the history
…rades (#30)

### Features
- adding `prior_mixture()` function for creating a mixture of prior distributions
- adding `as_mixed_posteriors()` and `as_marginal_inference()` functions for a single JAGS models (with spike and slab or mixture priors) to enabling tables and figures based on the corresponding output
- adding `interpret2()` function for another way of creating textual summaries without the need of inference and samples objects
- speedup and improvements to the `runjags_estimates_table()` function

### Fixes
- small fixes for expansion of the RoBMA functionality
  • Loading branch information
FBartos authored Jan 16, 2025
1 parent 9d77cbd commit 4080948
Show file tree
Hide file tree
Showing 213 changed files with 18,159 additions and 2,146 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
^renv$
^renv\.lock$
^.*\.Rproj$
^\.Rproj\.user$
^do-not-share$
Expand Down
5 changes: 5 additions & 0 deletions .Rprofile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if(interactive()){
library(devtools)
library(testthat)
library(vdiffr)
}
152 changes: 68 additions & 84 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,122 +1,105 @@
name: R-CMD-check

on:
push:
branches:
- main
- master
- pre-release
branches: [main, master, pre-release]
pull_request:
branches:
- main
- master
- pre-release

name: R-CMD-check
branches: [main, master, pre-release]

jobs:
R-CMD-check:
build:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'release'}
# - {os: macOS-latest, r: 'release'}
# - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
# - {os: ubuntu-latest, r: 'oldrel-1'}

env:
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_REMOTES_NO_ERRORS_FROM_WARNINGS: false
NOT_CRAN: true

- {os: ubuntu-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}

- uses: r-lib/actions/setup-pandoc@v2

- name: Query dependencies
# Install JAGS and system dependencies on Linux
- name: Install System Dependencies (Linux)
if: runner.os == 'Linux'
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
shell: Rscript {0}

- 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 }}-3-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-3-

- name: Set path for RTools 4.0
if: runner.os == 'Windows'
run: echo "C:/rtools40/usr/bin;C:/rtools40/mingw64/bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8

- name: Install most Windows system dependencies
sudo apt-get update
sudo apt-get install -y \
libssl-dev \
libcurl4-openssl-dev \
libxml2-dev \
libfontconfig1-dev \
libharfbuzz-dev \
libfribidi-dev \
libfreetype6-dev \
libpng-dev \
libtiff5-dev \
libjpeg-dev \
libcairo2-dev \
jags
# Install JAGS on Windows
- name: Install JAGS (Windows)
if: runner.os == 'Windows'
shell: cmd
run: |
pacman -Syu mingw-w64-x86_64-make --noconfirm
g++ --version
Get-Command g++ | Select-Object -ExpandProperty Definition
mingw32-make --version
Get-Command mingw32-make | Select-Object -ExpandProperty Definition
(New-Object System.Net.WebClient).DownloadFile('https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Windows/JAGS-4.3.1.exe', 'C:\JAGS-4.3.1.exe')
shell: powershell
curl -o jags-installer.exe -L https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Windows/JAGS-4.3.1.exe/download
jags-installer.exe /S
del jags-installer.exe
- name: Install JAGS on Windows
# Set JAGS environment variables on Windows
- name: Set JAGS environment variables (Windows)
if: runner.os == 'Windows'
run: C:\JAGS-4.3.1.exe /S
shell: cmd

- name: Install Linux system dependencies
if: runner.os == 'Linux'
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
sudo apt-get install -y libglpk-dev
Rscript -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
sudo -s apt-get install jags
sudo -s apt-get install libv8-dev
sudo -s apt-get install libnode-dev
sudo -s apt-get install libcurl4-openssl-dev
echo JAGS_ROOT=C:\Program Files\JAGS\JAGS-4.3.1>> %GITHUB_ENV%
echo JAGS_MAJOR_VERSION=4>> %GITHUB_ENV%
echo PATH=C:\Program Files\JAGS\JAGS-4.3.1\bin;%PATH%>> %GITHUB_ENV%
- name: Install Mac system dependencies
# Install JAGS on macOS
- name: Install JAGS (macOS)
if: runner.os == 'macOS'
run: |
rm '/usr/local/bin/gfortran'
brew install automake jags
- name: Install dependencies
if: runner.os != 'macOS'
brew update
brew install jags
# Find and Set JAGS Paths
- name: Set Environment Variables (macOS)
if: runner.os == 'macOS'
run: |
remotes::install_deps(dependencies = TRUE, type = ifelse(tolower(Sys.info()["sysname"]) == "linux", "source", "binary"))
remotes::install_cran("rcmdcheck")
shell: Rscript {0}
JAGS_BIN=$(brew --prefix jags)/bin
echo "JAGS_ROOT=$(brew --prefix jags)" >> $GITHUB_ENV
echo "PATH=$JAGS_BIN:$PATH" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=$(brew --prefix jags)/lib/pkgconfig" >> $GITHUB_ENV
- name: Install dependencies (macOS)
# Create Symlink for jags-terminal (if necessary)
- name: Create Symlink for jags-terminal (macOS)
if: runner.os == 'macOS'
run: |
remotes::install_deps(dependencies = TRUE, type = ifelse(tolower(Sys.info()["sysname"]) == "linux", "source", "binary"))
install.packages("rjags", type = "source")
remotes::install_cran("rcmdcheck")
sudo mkdir -p $(brew --prefix)/libexec
sudo ln -s $(brew --prefix jags)/bin/jags $(brew --prefix)/libexec/jags-terminal
# Install the package
- name: Install the required packages
run: |
options(repos = c(CRAN = "https://cloud.r-project.org"))
install.packages('devtools')
install.packages('rcmdcheck')
install.packages(c('BayesFactor', 'RoBMA', 'runjags', 'rjags', 'rstan', 'scales', 'vdiffr', 'testthat', 'covr', 'pandoc'))
devtools::install()
shell: Rscript {0}

- name: Check
if: runner.os != 'Windows'
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
run: |
options(crayon.enabled = TRUE)
rcmdcheck::rcmdcheck(
args = c("--no-manual", "--as-cran", "--ignore-vignettes"),
build_args = c("--no-build-vignettes"),
Expand All @@ -131,16 +114,17 @@ jobs:
JAGS_ROOT: "/c/progra~1/JAGS/JAGS-4.3.1"
JAGS_MAJOR_VERSION: 4
run: |
options(crayon.enabled = TRUE)
rcmdcheck::rcmdcheck(
args = c("--no-manual", "--as-cran", "--ignore-vignettes"),
build_args = c("--no-build-vignettes"),
error_on = "warning",
check_dir = "check")
shell: Rscript {0}"
shell: Rscript {0}

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
path: check
89 changes: 33 additions & 56 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -1,87 +1,64 @@
name: pkgdown

on:
push:
branches:
- main
- master
tags:
-'*'

name: pkgdown
- '*'

jobs:
pkgdown:
build:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
- {os: windows-latest, r: 'release'}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}

- uses: r-lib/actions/setup-pandoc@v2

- name: Install harfbuzz freetype2 fribidi Headers
if: runner.os == 'Linux'
run: sudo apt-get install libharfbuzz-dev libfribidi-dev


- name: Query dependencies
# Install JAGS on Windows
- name: Install JAGS (Windows)
if: runner.os == 'Windows'
shell: cmd
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Restore R package cache
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
curl -o jags-installer.exe -L https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Windows/JAGS-4.3.1.exe/download
jags-installer.exe /S
del jags-installer.exe
- name: Install system dependencies
if: runner.os == 'Linux'
run: |
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
- name: Install JAGS (windows-latest)
# Set JAGS environment variables on Windows
- name: Set JAGS environment variables (Windows)
if: runner.os == 'Windows'
run: |
curl.exe -o wjags.exe --url https://deac-fra.dl.sourceforge.net/project/mcmc-jags/JAGS/4.x/Windows/JAGS-4.3.1.exe
wjags.exe /S
del wjags.exe
shell: cmd
run: |
echo JAGS_ROOT=C:\Program Files\JAGS\JAGS-4.3.1>> %GITHUB_ENV%
echo JAGS_MAJOR_VERSION=4>> %GITHUB_ENV%
echo PATH=C:\Program Files\JAGS\JAGS-4.3.1\bin;%PATH%>> %GITHUB_ENV%
- name: Install JAGS (macOS-latest)
if: runner.os == 'macOS'
run : |
rm '/usr/local/bin/gfortran'
brew install automake jags
- name: Install dependencies
# Install Pandoc
- name: Setup Pandoc
uses: r-lib/actions/setup-pandoc@v2

# Install the package and its dependencies
- name: Install required packages
run: |
remotes::install_deps(dependencies = TRUE)
install.packages("pkgdown")
options(repos = c(CRAN = "https://cloud.r-project.org"))
install.packages('devtools')
install.packages('pkgdown')
install.packages(c('BayesFactor', 'RoBMA', 'runjags', 'rjags', 'rstan', 'scales', 'vdiffr', 'testthat', 'covr', 'pandoc'))
devtools::install()
shell: Rscript {0}

- name: Install package
run: R CMD INSTALL .

- name: Deploy package
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
Loading

0 comments on commit 4080948

Please sign in to comment.