Skip to content

Commit

Permalink
230223: updated github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
AnestisTouloumis committed Feb 23, 2023
1 parent a536070 commit 4074876
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 63 deletions.
78 changes: 23 additions & 55 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches:
- main
- master
branches: [main, master]
pull_request:
branches:
- main
- master
branches: [main, master]

name: R-CMD-check

Expand All @@ -22,63 +18,35 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

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

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

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

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

- name: Query dependencies
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: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v2
- uses: r-lib/actions/setup-r-dependencies@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-

- 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 dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}

- name: Check
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}
extra-packages: any::rcmdcheck
needs: check

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
- uses: r-lib/actions/check-r-package@v2
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
upload-snapshots: true
args: 'c("--as-cran")'
error-on: '"warning"'
check-dir: '"check"'
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ knitr::opts_chunk$set(
# SimCorMultRes: Simulates Correlated Multinomial Responses

[![Github version](`r paste0("https://img.shields.io/badge/GitHub%20-", as.vector(read.dcf('DESCRIPTION')[, 'Version']),"-orange.svg")`)]("commits/master")
[![R-CMD-check](https://github.com/AnestisTouloumis/SimCorMultRes/workflows/R-CMD-check/badge.svg)](https://github.com/AnestisTouloumis/SimCorMultRes/actions)
[![R-CMD-check](https://github.com/AnestisTouloumis/SimCorMultRes/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/AnestisTouloumis/SimCorMultRes/actions/workflows/R-CMD-check.yaml)
[![Project Status: Active The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)
[![Codecov test coverage](https://codecov.io/gh/AnestisTouloumis/SimCorMultRes/branch/master/graph/badge.svg)](https://codecov.io/gh/AnestisTouloumis/SimCorMultRes?branch=master)

Expand Down
5 changes: 3 additions & 2 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
\name{NEWS}
\title{NEWS file for the \pkg{SimCorMultRes} package}

\section{Changes in Version 1.8.2 (2022-09-27)}{
\section{Changes in Version 1.8.3 (2023-02-23)}{
\subsection{MINOR CHANGES}{
\itemize{
\item{Added R journal paper as vignette.}
\item{Improved README.}
\item{Improved vignette.}
\item{Reinstated code coverage using \pkg{covr}.}
\item{Updated GitHub Actions.}
}
}
}
Expand All @@ -21,7 +22,7 @@
\item{Removed \pkg{markdown} dependency.}
\item{Created NEWS.Rd.}
\item{Fixed ORCID in DESCRIPTION.}
\item{Migrating from travis-ci to github actions.}
\item{Migrating from Travis-CI to GitHub Actions.}
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions vignettes/SimCorMultRes.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -473,20 +473,19 @@ apply(simulated_nominal_dataset$Ysim, 2, table) / sample_size

## Notes on NORTA

The NORTA method, as implemented in `SimCorMultRes`, does not require specification of the correlation matrix of the latent variable. Instead the user defines the correlation matrix of the multivariate normal distribution, say $\mathbf R$, that appears in the intermediate step of the NORTA method.
In `SimCorMultRes`, the user specifies the correlation matrix of the multivariate normal distribution, denoted by $\mathbf R$, that is used in the intermediate step of the NORTA method. This is justified by the observation that when all the marginal distributions of the correlated latent variables are logistic, $\mathbf R$ is expected to approximate well their true but unknown correlation matrix [@Touloumis2016].

When the marginal distribution of the correlated responses is the logistic distribution, @Touloumis2016 argued that $\mathbf R$ is expected to approximate well the true but unknown correlation matrix of the correlated responses.

A simulation study was carried out assess the validity of this claim. For a fixed sample size $N$ and a correlation parameter $\rho$, $N$ independent bivariate random vectors $\mathbf y_{1}, \ldots, \mathbf y_{N}$ from a bivariate normal distribution with mean vector the zero vector and covariance matrix the correlation matrix
To evaluate the validity of approximation study, a simulation study was conducted. For a fixed sample size $N$ and a correlation parameter $\rho$, $N$ independent bivariate random vectors $\{\mathbf y_{i}: i = 1, \ldots, N \}$ from a bivariate normal distribution with mean vector the zero vector and covariance matrix the correlation matrix
\[
\mathbf R = \begin{bmatrix}
1 & \rho\\
\rho & 1
\end{bmatrix}
\]
were drawn. The sample correlation was used to estimate $\rho$. Next, the NORTA method was applied to obtain bivariate random vectors $\mathbf z_{1}, \ldots, \mathbf z_{N}$ so that their marginal distribution is a logistic distribution. Their correlation parameter, say $\rho_{z}$, was estimated using the sample correlation based on $\mathbf z_{1}, \ldots, \mathbf z_{N}$. Then, the NORTA method was applied to obtain bivariate random vectors $\mathbf w_{1}, \ldots, \mathbf w_{N}$ so that their marginal distribution is the gumbel distribution. Their correlation parameter, say $\rho_{w}$, was estimated using the sample correlation based on $\mathbf w_{1}, \ldots, \mathbf w_{N}$. This procedure was replicated $10,000,000$ times. The three correlation parameters $\rho$, $\rho_z$ and $\rho_w$ were estimated using the corresponding Monte Carlo counterparts $\widehat{\rho}$, $\widehat{\rho}_z$ and $\widehat{\rho}_w$, respectively. To reduce the sample variability, we set $N=10,000$. Finally, we considered $\rho= 0, 0.01,0.02,\ldots, 0.99$.
were drawn. The sample correlation was used to estimate $\rho$. Next, the NORTA method was applied to obtain bivariate random vectors $\{\mathbf z_{i}: i = 1, \ldots, N \}$ so that their marginal distribution is a logistic distribution. Their correlation parameter, say $\rho_{z}$, was estimated using the corresponding sample correlation. Then, the NORTA method was applied to obtain bivariate random vectors $\{\mathbf w_{i}: i = 1, \ldots, N \}$ so that their marginal distribution is the Gumbel distribution. Their correlation parameter, say $\rho_{w}$, was estimated using their sample correlation. This procedure was replicated $10,000,000$ times. The three correlation parameters $\rho$, $\rho_z$ and $\rho_w$ were estimated using the corresponding Monte Carlo estimates $\widehat{\rho}$, $\widehat{\rho}_z$ and $\widehat{\rho}_w$, respectively. To reduce the sample variability, we set $N=10,000$. Finally, we considered $\rho= 0, 0.01,0.02,\ldots, 0.99$.

The dataframe `simulation` contains the simulation results. As expected, $\widehat{\rho}$ is a good estimator of $\rho$ regardless of the strength of the correlation parameter. For the logistic case, the average difference between $\rho$ and $\widehat{\rho}_z$ is `r rho = simulation$rho; logistic = simulation$logistic; round(mean(rho - logistic), 4)`, taking the maximum value of `r round(max(rho - logistic), 4)` at $\rho = `r rho[which.max(rho - logistic)]`$. These imply that $\rho$ is a good approximation of $\rho_{z}$ (at least in 2 decimal points). For the gumbel case, the average difference between $\rho$ and $\widehat{\rho}_w$ is `r gumbel = simulation$gumbel; round(mean(rho - gumbel), 4)`, taking the maximum value of `r round(max(rho - gumbel), 4)` at $\rho = `r rho[which.max(rho - gumbel)]`$. Now $\rho$ appears again to approximate $\rho_{w}$ but it less accurate than that of the logistic case.
The dataframe `simulation` contains the true correlation parameter $\rho$ and the Monte Carlo estimates $\widehat{\rho}$, $\widehat{\rho}_z$ and $\widehat{\rho}_w$ of the simulation study. As expected, $\widehat{\rho} \approx \rho$ regardless of the strength of the correlation parameter. For the logistic case, the average difference between $\rho$ and $\widehat{\rho}_z$ is `r rho = simulation$rho; logistic = simulation$logistic; round(mean(rho - logistic), 4)`, taking the maximum value of `r round(max(rho - logistic), 4)` at $\rho = `r rho[which.max(rho - logistic)]`$. Thus, $\rho$ appears to approximate $\rho_{z}$ 2 decimal points. For the Gumbel case, the average difference between $\rho$ and $\widehat{\rho}_w$ is `r gumbel = simulation$gumbel; round(mean(rho - gumbel), 4)`, taking the maximum value of `r round(max(rho - gumbel), 4)` at $\rho = `r rho[which.max(rho - gumbel)]`$. Again, $\rho$ appears to approximate $\rho_{w}$ but there is some accuracy loss compared to $\rho_{z}$.


```{r echo = FALSE, fig.cap= "Difference between the correlation parameters of the bivariate normal distribution and of the latent variables for three different marginal distributions."}
Expand Down

0 comments on commit 4074876

Please sign in to comment.