From f4d4120e2d2bc678db03ec174244e4cae44ee152 Mon Sep 17 00:00:00 2001 From: "George G. Vega Yon" Date: Mon, 15 Dec 2025 16:55:12 +0000 Subject: [PATCH 1/6] Preparing for CRAN release --- .devcontainer/Containerfile | 2 +- .devcontainer/devcontainer.json | 3 +- .github/workflows/copilot-setup-steps.yml | 42 +++++++++++++++++++++ .github/workflows/coverage.yaml | 35 ++++++++++++++++++ .github/workflows/r.yml | 24 +++++++++++- DESCRIPTION | 8 ++-- Makefile | 11 ++---- NEWS.md | 7 ++++ README.md | 45 +++++++++++++---------- README.qmd | 9 ++++- inst/NEWS | 5 --- 11 files changed, 152 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/copilot-setup-steps.yml create mode 100644 .github/workflows/coverage.yaml delete mode 100644 inst/NEWS diff --git a/.devcontainer/Containerfile b/.devcontainer/Containerfile index 9490c90..cca92c4 100644 --- a/.devcontainer/Containerfile +++ b/.devcontainer/Containerfile @@ -1,4 +1,4 @@ -FROM rocker/tidyverse:4.5.1 +FROM ghcr.io/rocker-org/devcontainer/tidyverse:4.5 # RUN \ # echo 'options(repos=c(CRAN="https://packagemanager.posit.co/cran/__linux__/bookworm/latest"))' >> ~/.Rprofile && \ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b2065b7..1a6709d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -11,7 +11,8 @@ "reditorsupport.r", "rdebugger.r-debugger", "quarto.quarto", - "tianyishi.rmarkdown" + "tianyishi.rmarkdown", + "github.vscode-github-actions" ] } }, diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml new file mode 100644 index 0000000..27eaa75 --- /dev/null +++ b/.github/workflows/copilot-setup-steps.yml @@ -0,0 +1,42 @@ +name: "Copilot Setup Steps" + +# Automatically run the setup steps when they are changed to allow for easy validation, and +# allow manual testing through the repository's "Actions" tab +on: + workflow_dispatch: + push: + paths: + - .github/workflows/copilot-setup-steps.yml + pull_request: + paths: + - .github/workflows/copilot-setup-steps.yml + +jobs: + # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot. + copilot-setup-steps: + runs-on: ubuntu-latest + + # Set the permissions to the lowest permissions possible needed for your steps. + # Copilot will be given its own token for its operations. + permissions: + # If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete. + contents: read + + # You can define any steps you want, and they will run before the agent starts. + # If you do not check out your code, Copilot will do this for you. + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up R + uses: r-lib/actions/setup-r@v2 + with: + r-version: 'release' + + - name: Install dependencies + uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: | + any::rcmdcheck + any::tinytest + needs: check diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml new file mode 100644 index 0000000..8807b99 --- /dev/null +++ b/.github/workflows/coverage.yaml @@ -0,0 +1,35 @@ +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: Coverage + +jobs: + coverage: + runs-on: ubuntu-latest + name: Coverage + + steps: + - uses: actions/checkout@v5 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2.9.0 + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: | + any::covr + needs: check + + - name: Running coverage + run: | + # Run coverage + covr::codecov( + token = Sys.getenv("CODECOV_TOKEN") + ) + shell: Rscript {0} + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/r.yml b/.github/workflows/r.yml index eeb40fd..1412d0d 100644 --- a/.github/workflows/r.yml +++ b/.github/workflows/r.yml @@ -13,6 +13,28 @@ on: name: R-CMD-check jobs: + R-binary: + runs-on: ubuntu-latest + + name: R binary version + steps: + - uses: actions/checkout@v5 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + + - name: Build package + run: R CMD build . + + - name: Upload artifact + uses: actions/upload-artifact@v6 + with: + name: defm-ubuntu-tar-gz + path: defm_*.tar.gz + R-CMD-check: runs-on: ${{ matrix.config.os }} @@ -39,7 +61,7 @@ jobs: R_KEEP_PKG_SOURCE: yes steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: r-lib/actions/setup-pandoc@v2 diff --git a/DESCRIPTION b/DESCRIPTION index aa4a513..f2016f6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -9,7 +9,11 @@ Authors@R: c( "Department of Veterans Affairs - Rehabilitation, Research, and Development Service", role = "fnd", comment = "Award/W81XWH-18-PH/TBIRP-LIMBIC under Award No. I01 RX003443" - )) + ), + person( + "U.S. Army Medical Research Acquisition Activity", role = "fnd", + comment = "ORION project, Award #W81XWH1910615") + ) Description: Multi-binary response models are a class of models that allow for the estimation of multiple binary outcomes simultaneously. This package provides functions to estimate and simulate these models using the Discrete Exponential-Family Models [DEFM] framework. In it, we implement the models described in Vega Yon, Valente, and Pugh (2023) . DEFMs include Exponential-Family Random Graph Models [ERGMs], which characterize graphs using sufficient statistics, which is also the core of DEFMs. Using sufficient statistics, we can describe the data through meaningful motifs, for example, transitions between different states, joint distribution of the outcomes, etc. URL: https://github.com/UofUEpiBio/defm, https://uofuepibio.github.io/defm/ @@ -28,5 +32,3 @@ Depends: stats4 Suggests: texreg, tinytest, barry -Remotes: - USCBiostats/barryr diff --git a/Makefile b/Makefile index 1b58a73..d589c94 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,6 @@ help: @echo " make debug Install package with debug flags" @echo " make clean Clean up generated files" @echo " make README.md Generate README.md from README.Rmd" - @echo " make inst/NEWS Generate inst/NEWS from NEWS.md" @echo " make docker-run Run a docker container with R and barry installed" @echo " make docker-check All checks inside a docker container" @@ -33,15 +32,8 @@ clean: Rscript --vanilla -e 'devtools::clean_dll()'; \ rm -rf *.Rcmdcheck -README.md: README.Rmd - Rscript --vanilla -e 'rmarkdown::render("README.Rmd")' - .PHONY: build update clean -inst/NEWS: NEWS.md - Rscript -e "rmarkdown::pandoc_convert('NEWS.md', 'plain', output='inst/NEWS')" && \ - head -n 80 inst/NEWS - docker-run: docker run --rm -ti -v $(PWD):/mnt -w/mnt gvegayon/defm:latest bash @@ -59,3 +51,6 @@ docker-check-all: RD CMD build . && \ DEFM_CONFIG="-DBARRY_DEBUG" _R_CHECK_FORCE_SUGGESTS_=false \ RD CMD check defm_*.tar.gz + +README.md: README.qmd + quarto render README.qmd \ No newline at end of file diff --git a/NEWS.md b/NEWS.md index 088f151..910594c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ +# defm 0.2.1.0 + +* Returning to CRAN. + +* The `defm` now uses the same versioning as the [`barry`](https://github.com/USCbiostats/barry) library (first three numbers). The last number is the patch. + + # defm 0.1-1 * Added a `NEWS.md` file to track changes to the package. diff --git a/README.md b/README.md index 9c73a40..f92f653 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,14 @@ -[![CRAN -status](https://www.r-pkg.org/badges/version/defm)](https://CRAN.R-project.org/package=defm) -[![Grand -total](https://cranlogs.r-pkg.org/badges/grand-total/defm)](https://CRAN.R-project.org/package=defm) +[![CRAN status](https://www.r-pkg.org/badges/version/defm)](https://CRAN.R-project.org/package=defm) [![R-CMD-check](https://github.com/UofUEpiBio/defm/actions/workflows/r.yml/badge.svg)](https://github.com/UofUEpiBio/defm/actions/workflows/r.yml) -[![defm status -badge](https://uofuepibio.r-universe.dev/defm/badges/version)](https://uofuepibio.r-universe.dev/defm) +[![CRANlogs downloads](https://cranlogs.r-pkg.org/badges/grand-total/defm)](https://cran.r-project.org/package=defm) +[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/UofUEpiBio/defm/blob/master/LICENSE.md) +[![codecov](https://codecov.io/gh/UofUEpiBio/defm/graph/badge.svg?token=N27VLID83M)](https://codecov.io/gh/UofUEpiBio/defm) +[![status](https://tinyverse.netlify.app/badge/defm)](https://CRAN.R-project.org/package=defm) +[![defm status badge](https://uofuepibio.r-universe.dev/defm/badges/version)](https://uofuepibio.r-universe.dev/defm) + Discrete exponential family models (DEFM) have a long tradition with @@ -193,7 +194,7 @@ summary(ans) #> Estimate Std. Error #> Num. of ones -2.009506 0.01435063 #> Num. of ones x x1 2.020209 0.01592262 -#> Motif {y0+}⇨{y0+, y1+} 5.051076 0.04649922 +#> Motif {y0+}>{y0+, y1+} 5.051076 0.04649922 #> #> -2 log L: 54960.47 ``` @@ -259,7 +260,7 @@ Num. of ones x x1 -Motif {y0+}⇨{y0+, y1+} +Motif {y0+}\>{y0+, y1+} @@ -331,7 +332,7 @@ N We can also see the counts -| id | y0 | y1 | y2 | x0 | x1 | Num. of ones | Num. of ones x x1 | Motif {y0+}⇨{y0+, y1+} | +| id | y0 | y1 | y2 | x0 | x1 | Num. of ones | Num. of ones x x1 | Motif {y0+}\>{y0+, y1+} | |---:|---:|---:|---:|---:|---:|---:|---:|---:| | 1 | 0 | 0 | 0 | 0.51 | 0.95 | NA | NA | NA | | 1 | 0 | 0 | 1 | 0.16 | 0.25 | 1 | 0.25 | 0 | @@ -499,16 +500,16 @@ d_model_formula #> Arrays in powerset : 2048 #> Transform. Fun. : no #> Model terms (11) : -#> - Motif {y0+, y1-}⇨{y0-, y1+} -#> - Motif {y1+, y2-}⇨{y1-, y2+} -#> - Motif {y2+, y3-}⇨{y2-, y3+} -#> - Motif {y3+, y4-}⇨{y3-, y4+} -#> - Motif {y4+, y5-}⇨{y4-, y5+} -#> - Motif {y5+, y6-}⇨{y5-, y6+} -#> - Motif {y6+, y7-}⇨{y6-, y7+} -#> - Motif {y7+, y8-}⇨{y7-, y8+} -#> - Motif {y8+, y9-}⇨{y8-, y9+} -#> - Motif {y0-, y9+}⇨{y0+, y9-} +#> - Motif {y0+, y1-}>{y0-, y1+} +#> - Motif {y1+, y2-}>{y1-, y2+} +#> - Motif {y2+, y3-}>{y2-, y3+} +#> - Motif {y3+, y4-}>{y3-, y4+} +#> - Motif {y4+, y5-}>{y4-, y5+} +#> - Motif {y5+, y6-}>{y5-, y6+} +#> - Motif {y6+, y7-}>{y6-, y7+} +#> - Motif {y7+, y8-}>{y7-, y8+} +#> - Motif {y8+, y9-}>{y8-, y9+} +#> - Motif {y0-, y9+}>{y0+, y9-} #> - Num. of ones #> Model rules (1) : #> - Markov model of order 1 @@ -571,6 +572,12 @@ necessarily reflect the views of the U.S. Government, the U.S. Department of Veterans Affairs or the Department of Defense and no official endorsement should be inferred. +The package is part of the ORION project, supported by the U.S. Army +Medical Research Acquisition Activity Award, Contact \#W81XWH1910615. +This study was approved by the University of Utah Institutional Review +Board (IRB \#137948) and at each of the military treatment facility +sites. + # Code of Conduct Please note that the `defm` project is released with a [Contributor Code diff --git a/README.qmd b/README.qmd index 218ddce..6f58288 100644 --- a/README.qmd +++ b/README.qmd @@ -17,10 +17,15 @@ knitr::opts_chunk$set( # defm: Fit and simulate discrete binary exponential family models +```{=markdown} [![CRAN status](https://www.r-pkg.org/badges/version/defm)](https://CRAN.R-project.org/package=defm) -[![Grand total](https://cranlogs.r-pkg.org/badges/grand-total/defm)](https://CRAN.R-project.org/package=defm) [![R-CMD-check](https://github.com/UofUEpiBio/defm/actions/workflows/r.yml/badge.svg)](https://github.com/UofUEpiBio/defm/actions/workflows/r.yml) +[![CRANlogs downloads](https://cranlogs.r-pkg.org/badges/grand-total/defm)](https://cran.r-project.org/package=defm) +[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/UofUEpiBio/defm/blob/master/LICENSE.md) +[![codecov](https://codecov.io/gh/UofUEpiBio/defm/graph/badge.svg?token=N27VLID83M)](https://codecov.io/gh/UofUEpiBio/defm) +[![status](https://tinyverse.netlify.app/badge/defm)](https://CRAN.R-project.org/package=defm) [![defm status badge](https://uofuepibio.r-universe.dev/defm/badges/version)](https://uofuepibio.r-universe.dev/defm) +``` Discrete exponential family models (DEFM) have a long tradition with extensive @@ -329,6 +334,8 @@ image(as(Y_sim_formula, "dgCMatrix")) This work was supported by the Assistant Secretary of Defense for Health Affairs endorsed by the Department of Defense, through the Psychological Health/Traumatic Brain Injury Research Program Long-Term Impact of Military-Relevant Brain Injury Consortium (LIMBIC) Award/W81XWH-18-PH/TBIRP-LIMBIC under Award No. I01 RX003443. The U.S. Army Medical Research Acquisition Activity, 839 Chandler Street, Fort Detrick MD 21702-5014 is the awarding and administering acquisition office. Opinions, interpretations, conclusions and recommendations are those of the author and are not necessarily endorsed by the Department of Defense. Any opinions, findings, conclusions, or recommendations expressed in this publication are those of the author(s) and do not necessarily reflect the views of the U.S. Government, the U.S. Department of Veterans Affairs or the Department of Defense and no official endorsement should be inferred. +The package is part of the ORION project, supported by the U.S. Army Medical Research Acquisition Activity Award, Contact \#W81XWH1910615. This study was approved by the University of Utah Institutional Review Board (IRB \#137948) and at each of the military treatment facility sites. + # Code of Conduct Please note that the `defm` project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms. diff --git a/inst/NEWS b/inst/NEWS deleted file mode 100644 index f34d68f..0000000 --- a/inst/NEWS +++ /dev/null @@ -1,5 +0,0 @@ -defm 0.1-1 - -- Added a NEWS.md file to track changes to the package. - -- Change how nobs.DEFM is documented (per CRAN) From 534f91b098b79ed4e8557d712c42fb8216fedf37 Mon Sep 17 00:00:00 2001 From: "George G. Vega Yon" Date: Mon, 15 Dec 2025 19:44:35 +0000 Subject: [PATCH 2/6] Adding a few tests --- inst/tinytest/test_sim_defm.R | 60 +++++++++++++++++++++++++++++++++++ src/defm-object.cpp | 4 +++ 2 files changed, 64 insertions(+) create mode 100644 inst/tinytest/test_sim_defm.R diff --git a/inst/tinytest/test_sim_defm.R b/inst/tinytest/test_sim_defm.R new file mode 100644 index 0000000..6bef411 --- /dev/null +++ b/inst/tinytest/test_sim_defm.R @@ -0,0 +1,60 @@ +n_K <- 1L +n_Y <- 4 +n_id <- 2L +n_T <- 4L + +set.seed(31231) +id <- cbind(rep(1L:n_id, each = n_T)) +Y <- matrix(0L, nrow = n_T * n_id, ncol = n_Y) +X <- matrix(rnorm(n_K * n_T * n_id), ncol = n_K) + +expect_error({ + d_model_formula <- new_defm(id = id, Y = Y, X = X, order = 1) +}) + +colnames(X) <- paste0("col", 1:n_K) +colnames(Y) <- paste0("y", 1:n_Y) + +d_model_formula <- new_defm(id = id, Y = Y, X = X, order = 1) + +td_logit_intercept( + d_model_formula +) + +init_defm(d_model_formula) + +set.seed(331) +expect_silent({ + Y_sim <- sim_defm( + d_model_formula, + par = c(-1, -.5, .5, 1) + ) +}) + +# We now create a new model using the new output +d_model_formula <- new_defm(id = id, Y = Y_sim, X = X, order = 1) + +td_logit_intercept( + d_model_formula +) + +init_defm(d_model_formula) + +expect_silent({ + Y_stats <- get_stats(d_model_formula) +}) + +expect_true(ncol(Y_stats) == length(get_counters(d_model_formula))) +expect_true(ncol(Y_stats) == n_Y) + +# We know this counter matches the data. +Y_sim[c(1, 5),] <- NA +expect_equivalent(Y_stats, Y_sim) + +expect_stdout( + print_stats(d_model_formula), + "counts: " +) + +expect_equal(get_Y_names(d_model_formula), colnames(Y_sim)) +expect_equal(get_X_names(d_model_formula), colnames(X)) \ No newline at end of file diff --git a/src/defm-object.cpp b/src/defm-object.cpp index 5061621..f1075ad 100644 --- a/src/defm-object.cpp +++ b/src/defm-object.cpp @@ -308,6 +308,10 @@ IntegerMatrix sim_defm( } + // Adding a name + CharacterVector names = wrap(ptr->get_Y_names()); + Rcpp::colnames(res) = names; + return res; } From 94ca8e87c2730d5e46d2d2afe27be2dd236ccda8 Mon Sep 17 00:00:00 2001 From: "George G. Vega Yon" Date: Mon, 15 Dec 2025 20:27:39 +0000 Subject: [PATCH 3/6] Adding tests and refactor pkgdown action --- .github/workflows/pkgdown.yaml | 62 ++++++++++++++++++++++++++++------ inst/tinytest/test_defm.R | 14 ++++++++ inst/tinytest/test_sim_defm.R | 56 +++++++++++++++++++++++++++++- 3 files changed, 120 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 5d7b975..68c1a7b 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -11,16 +11,27 @@ on: name: pkgdown +# Sets permissions of the GITHUB_TOKEN +permissions: + contents: read + pages: write + id-token: write + pull-requests: write + actions: read + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + jobs: - pkgdown: + build: runs-on: ubuntu-latest - # Only restrict concurrency for non-PR jobs - concurrency: - group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - uses: r-lib/actions/setup-pandoc@v2 @@ -39,10 +50,39 @@ jobs: run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) shell: Rscript {0} - - name: Deploy to GitHub pages 🚀 - if: github.event_name != 'pull_request' - uses: JamesIves/github-pages-deploy-action@v4.4.1 + # Upload artifact for GitHub Pages deployment (only for pushes to main/master) + - name: Upload Pages artifact + if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') + uses: actions/upload-pages-artifact@v3 with: - clean: false - branch: gh-pages - folder: docs + path: docs + + # Upload artifact for PR preview (only for pull requests) + - name: Upload PR artifact + if: github.event_name == 'pull_request' + uses: actions/upload-artifact@v4 + with: + name: pkgdown-site + path: docs + + # Post comment with link to artifact on PRs + - name: Post artifact link to PR + if: github.event_name == 'pull_request' + uses: CDCgov/cfa-actions/post-artifact@v1.2.0 + with: + artifact-name: pkgdown-site + gh-token: ${{ secrets.GITHUB_TOKEN }} + message: 'Thank you for your contribution @${{ github.actor }} :rocket:! The pkgdown site preview is ready for review :point_right: [Download here]({ artifact-url }) :point_left:!' + + # Deployment job - only runs on pushes to main/master + deploy: + if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 \ No newline at end of file diff --git a/inst/tinytest/test_defm.R b/inst/tinytest/test_defm.R index f750f84..487d4e6 100644 --- a/inst/tinytest/test_defm.R +++ b/inst/tinytest/test_defm.R @@ -12,6 +12,20 @@ init_defm(mymodel) ans <- defm_mle(mymodel) +# Checking texreg fancy +expect_stdout({ + print(texreg_fancy( + ans, texreg::screenreg, + skip_intercept = TRUE + )) +}, "Model 1") + +expect_stdout({ + print(summary_table(ans)) + }, + "pvalues" +) + # Fitting individual models for each outcome ans_alcohol <- glm( alcohol ~ Hispanic, data = valentesns, diff --git a/inst/tinytest/test_sim_defm.R b/inst/tinytest/test_sim_defm.R index 6bef411..8e98242 100644 --- a/inst/tinytest/test_sim_defm.R +++ b/inst/tinytest/test_sim_defm.R @@ -8,6 +8,10 @@ id <- cbind(rep(1L:n_id, each = n_T)) Y <- matrix(0L, nrow = n_T * n_id, ncol = n_Y) X <- matrix(rnorm(n_K * n_T * n_id), ncol = n_K) +# ------------------------------------------------------------------------------ +# new_defm +# ------------------------------------------------------------------------------ + expect_error({ d_model_formula <- new_defm(id = id, Y = Y, X = X, order = 1) }) @@ -40,6 +44,10 @@ td_logit_intercept( init_defm(d_model_formula) +# ------------------------------------------------------------------------------ +# Stats +# ------------------------------------------------------------------------------ + expect_silent({ Y_stats <- get_stats(d_model_formula) }) @@ -57,4 +65,50 @@ expect_stdout( ) expect_equal(get_Y_names(d_model_formula), colnames(Y_sim)) -expect_equal(get_X_names(d_model_formula), colnames(X)) \ No newline at end of file +expect_equal(get_X_names(d_model_formula), colnames(X)) + +# ------------------------------------------------------------------------------ +# Motif census +# ------------------------------------------------------------------------------ +expect_stdout({ + print(motif_census(d_model_formula, c(0,1))) +}, "census for variable") + + +# ------------------------------------------------------------------------------ +# Log odds +# ------------------------------------------------------------------------------ +expect_silent({ + lo <- logodds(d_model_formula, c(-1, -.5, .5, 1), i=1, j=1) +}) + + +# ------------------------------------------------------------------------------ +# Counters +# ------------------------------------------------------------------------------ +expect_stdout({ + print(get_counters(d_model_formula)) +}, "Counters \\(4\\)") + +expect_stdout({ + print(get_counters(d_model_formula)[1]) +}, "Counter[:]") + + +set_counter_info( + counter = get_counters(d_model_formula)[1], + new_name = "lame", new_desc = "whatever" + ) + +tmp <- get_counters(d_model_formula)[1] |> + as.list() + +expect_equal( + list(name = "lame", description = "whatever"), + tmp[[1]] +) + +# ------------------------------------------------------------------------------ +# Misc +# ------------------------------------------------------------------------------ +expect_inherits(as.list(get_counters(d_model_formula)), "list") \ No newline at end of file From d60e01f0629ba4e3892e52bbb3d6ddcc9c952cac Mon Sep 17 00:00:00 2001 From: "George G. Vega Yon" Date: Mon, 15 Dec 2025 20:30:51 +0000 Subject: [PATCH 4/6] Minor fix in tests --- inst/tinytest/test_sim_defm.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/tinytest/test_sim_defm.R b/inst/tinytest/test_sim_defm.R index 8e98242..f07d58c 100644 --- a/inst/tinytest/test_sim_defm.R +++ b/inst/tinytest/test_sim_defm.R @@ -105,7 +105,7 @@ tmp <- get_counters(d_model_formula)[1] |> expect_equal( list(name = "lame", description = "whatever"), - tmp[[1]] + tmp ) # ------------------------------------------------------------------------------ From 74777572137bbd3d84f2eebc4dee37fe98418399 Mon Sep 17 00:00:00 2001 From: "George G. Vega Yon" Date: Tue, 10 Feb 2026 18:43:05 +0000 Subject: [PATCH 5/6] Addressing CRAN comment --- README.md | 100 ++++++++++++++++++++++++++--------------------------- README.qmd | 2 +- 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index f92f653..771a009 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ [![R-CMD-check](https://github.com/UofUEpiBio/defm/actions/workflows/r.yml/badge.svg)](https://github.com/UofUEpiBio/defm/actions/workflows/r.yml) [![CRANlogs downloads](https://cranlogs.r-pkg.org/badges/grand-total/defm)](https://cran.r-project.org/package=defm) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/UofUEpiBio/defm/blob/master/LICENSE.md) -[![codecov](https://codecov.io/gh/UofUEpiBio/defm/graph/badge.svg?token=N27VLID83M)](https://codecov.io/gh/UofUEpiBio/defm) +[![codecov](https://codecov.io/gh/UofUEpiBio/defm/graph/badge.svg?token=N27VLID83M)](https://app.codecov.io/gh/UofUEpiBio/defm) [![status](https://tinyverse.netlify.app/badge/defm)](https://CRAN.R-project.org/package=defm) [![defm status badge](https://uofuepibio.r-universe.dev/defm/badges/version)](https://uofuepibio.r-universe.dev/defm) @@ -166,13 +166,13 @@ sim_par <- c(-2, 2, 5) d_model <- build_model(id, Y, X, order = 1L, par. = sim_par) simulated_Y <- sim_defm(d_model, sim_par) head(cbind(id, simulated_Y)) -#> id -#> [1,] 1 0 0 0 -#> [2,] 1 0 0 1 -#> [3,] 1 0 0 0 -#> [4,] 1 1 1 1 -#> [5,] 2 0 1 0 -#> [6,] 2 1 1 0 +#> id y0 y1 y2 +#> [1,] 1 0 0 0 +#> [2,] 1 0 0 1 +#> [3,] 1 0 0 0 +#> [4,] 1 1 1 1 +#> [5,] 2 0 1 0 +#> [6,] 2 1 1 0 ``` Now, let’s see if we can recover the parameters using MLE: @@ -439,27 +439,27 @@ td_ones(d_model) init_defm(d_model) set.seed(33) (Y_sim <-sim_defm(d_model, par = c(rep(200, n_y), -5))) -#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] -#> [1,] 1 0 0 0 0 0 0 0 0 0 -#> [2,] 0 1 0 0 0 0 0 0 0 0 -#> [3,] 0 0 1 0 0 0 0 0 0 0 -#> [4,] 0 0 0 1 0 0 0 0 0 0 -#> [5,] 0 0 0 0 1 0 0 0 0 0 -#> [6,] 0 0 0 0 0 1 0 0 0 0 -#> [7,] 0 0 0 0 0 0 1 0 0 0 -#> [8,] 0 0 0 0 0 0 0 1 0 0 -#> [9,] 0 0 0 0 0 0 0 0 1 0 -#> [10,] 0 0 0 0 0 0 0 0 0 1 -#> [11,] 1 0 0 0 0 0 0 0 0 0 -#> [12,] 0 1 0 0 0 0 0 0 0 0 -#> [13,] 0 0 0 0 0 0 0 0 0 0 -#> [14,] 0 0 0 0 0 0 0 0 0 0 -#> [15,] 0 0 0 0 0 0 0 0 0 0 -#> [16,] 0 0 0 0 0 0 0 0 0 0 -#> [17,] 0 0 0 0 0 0 0 0 0 0 -#> [18,] 0 0 0 0 0 0 0 0 0 0 -#> [19,] 0 0 0 0 0 0 1 0 0 0 -#> [20,] 0 0 0 0 0 0 0 0 0 0 +#> y0 y1 y2 y3 y4 y5 y6 y7 y8 y9 +#> [1,] 1 0 0 0 0 0 0 0 0 0 +#> [2,] 0 1 0 0 0 0 0 0 0 0 +#> [3,] 0 0 1 0 0 0 0 0 0 0 +#> [4,] 0 0 0 1 0 0 0 0 0 0 +#> [5,] 0 0 0 0 1 0 0 0 0 0 +#> [6,] 0 0 0 0 0 1 0 0 0 0 +#> [7,] 0 0 0 0 0 0 1 0 0 0 +#> [8,] 0 0 0 0 0 0 0 1 0 0 +#> [9,] 0 0 0 0 0 0 0 0 1 0 +#> [10,] 0 0 0 0 0 0 0 0 0 1 +#> [11,] 1 0 0 0 0 0 0 0 0 0 +#> [12,] 0 1 0 0 0 0 0 0 0 0 +#> [13,] 0 0 0 0 0 0 0 0 0 0 +#> [14,] 0 0 0 0 0 0 0 0 0 0 +#> [15,] 0 0 0 0 0 0 0 0 0 0 +#> [16,] 0 0 0 0 0 0 0 0 0 0 +#> [17,] 0 0 0 0 0 0 0 0 0 0 +#> [18,] 0 0 0 0 0 0 0 0 0 0 +#> [19,] 0 0 0 0 0 0 1 0 0 0 +#> [20,] 0 0 0 0 0 0 0 0 0 0 ``` The simulation should produce a nice-looking figure: @@ -528,27 +528,27 @@ d_model_formula # Simulating set.seed(33) (Y_sim_formula <- sim_defm(d_model_formula, par = c(rep(200, n_y), -5))) -#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] -#> [1,] 1 0 0 0 0 0 0 0 0 0 -#> [2,] 0 1 0 0 0 0 0 0 0 0 -#> [3,] 0 0 1 0 0 0 0 0 0 0 -#> [4,] 0 0 0 1 0 0 0 0 0 0 -#> [5,] 0 0 0 0 1 0 0 0 0 0 -#> [6,] 0 0 0 0 0 1 0 0 0 0 -#> [7,] 0 0 0 0 0 0 1 0 0 0 -#> [8,] 0 0 0 0 0 0 0 1 0 0 -#> [9,] 0 0 0 0 0 0 0 0 1 0 -#> [10,] 0 0 0 0 0 0 0 0 0 1 -#> [11,] 1 0 0 0 0 0 0 0 0 0 -#> [12,] 0 1 0 0 0 0 0 0 0 0 -#> [13,] 0 0 0 0 0 0 0 0 0 0 -#> [14,] 0 0 0 0 0 0 0 0 0 0 -#> [15,] 0 0 0 0 0 0 0 0 0 0 -#> [16,] 0 0 0 0 0 0 0 0 0 0 -#> [17,] 0 0 0 0 0 0 0 0 0 0 -#> [18,] 0 0 0 0 0 0 0 0 0 0 -#> [19,] 0 0 0 0 0 0 1 0 0 0 -#> [20,] 0 0 0 0 0 0 0 0 0 0 +#> y0 y1 y2 y3 y4 y5 y6 y7 y8 y9 +#> [1,] 1 0 0 0 0 0 0 0 0 0 +#> [2,] 0 1 0 0 0 0 0 0 0 0 +#> [3,] 0 0 1 0 0 0 0 0 0 0 +#> [4,] 0 0 0 1 0 0 0 0 0 0 +#> [5,] 0 0 0 0 1 0 0 0 0 0 +#> [6,] 0 0 0 0 0 1 0 0 0 0 +#> [7,] 0 0 0 0 0 0 1 0 0 0 +#> [8,] 0 0 0 0 0 0 0 1 0 0 +#> [9,] 0 0 0 0 0 0 0 0 1 0 +#> [10,] 0 0 0 0 0 0 0 0 0 1 +#> [11,] 1 0 0 0 0 0 0 0 0 0 +#> [12,] 0 1 0 0 0 0 0 0 0 0 +#> [13,] 0 0 0 0 0 0 0 0 0 0 +#> [14,] 0 0 0 0 0 0 0 0 0 0 +#> [15,] 0 0 0 0 0 0 0 0 0 0 +#> [16,] 0 0 0 0 0 0 0 0 0 0 +#> [17,] 0 0 0 0 0 0 0 0 0 0 +#> [18,] 0 0 0 0 0 0 0 0 0 0 +#> [19,] 0 0 0 0 0 0 1 0 0 0 +#> [20,] 0 0 0 0 0 0 0 0 0 0 ``` The new simulation… diff --git a/README.qmd b/README.qmd index 6f58288..22cd9e9 100644 --- a/README.qmd +++ b/README.qmd @@ -22,7 +22,7 @@ knitr::opts_chunk$set( [![R-CMD-check](https://github.com/UofUEpiBio/defm/actions/workflows/r.yml/badge.svg)](https://github.com/UofUEpiBio/defm/actions/workflows/r.yml) [![CRANlogs downloads](https://cranlogs.r-pkg.org/badges/grand-total/defm)](https://cran.r-project.org/package=defm) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/UofUEpiBio/defm/blob/master/LICENSE.md) -[![codecov](https://codecov.io/gh/UofUEpiBio/defm/graph/badge.svg?token=N27VLID83M)](https://codecov.io/gh/UofUEpiBio/defm) +[![codecov](https://codecov.io/gh/UofUEpiBio/defm/graph/badge.svg?token=N27VLID83M)](https://app.codecov.io/gh/UofUEpiBio/defm) [![status](https://tinyverse.netlify.app/badge/defm)](https://CRAN.R-project.org/package=defm) [![defm status badge](https://uofuepibio.r-universe.dev/defm/badges/version)](https://uofuepibio.r-universe.dev/defm) ``` From d0058c5fb06de3b2a68ab626b2ba65c52ef2f68e Mon Sep 17 00:00:00 2001 From: "George G. Vega Yon" Date: Tue, 10 Feb 2026 19:04:52 +0000 Subject: [PATCH 6/6] Changed to contributor covenant v 3 --- README.md | 2 +- README.qmd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 771a009..faea09b 100644 --- a/README.md +++ b/README.md @@ -582,5 +582,5 @@ sites. Please note that the `defm` project is released with a [Contributor Code of -Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). +Conduct](https://contributor-covenant.org/version/3/0/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms. diff --git a/README.qmd b/README.qmd index 22cd9e9..08f0a5d 100644 --- a/README.qmd +++ b/README.qmd @@ -338,4 +338,4 @@ The package is part of the ORION project, supported by the U.S. Army Medical Res # Code of Conduct - Please note that the `defm` project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms. + Please note that the `defm` project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/3/0/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.