diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 0000000..21b8a93 --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,50 @@ +# 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] + pull_request: + branches: [main, master] + +name: test-coverage + +jobs: + test-coverage: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::covr + needs: coverage + + - name: Test coverage + run: | + covr::codecov( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") + ) + shell: Rscript {0} + + - name: Show testthat output + if: always() + run: | + ## -------------------------------------------------------------------- + find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v4 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package diff --git a/DESCRIPTION b/DESCRIPTION index 2b06afe..e0638a3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: iprior Title: Regression Modelling using I-Priors -Version: 0.7.3.9001 +Version: 0.7.4 Authors@R: person("Haziq", "Jamil", email = "haziq.jamil@gmail.com", role = c("aut", "cre")) Encoding: UTF-8 diff --git a/R/Kernel_loader.R b/R/Kernel_loader.R index 41d444a..149a45b 100644 --- a/R/Kernel_loader.R +++ b/R/Kernel_loader.R @@ -74,6 +74,7 @@ #' should be used for training, and the remaining used for testing. #' @param test.samp (Optional) Similar to \code{train.samp}, but on test samples #' instead. +#' @param intercept (Optional) Intercept for response variables. #' #' @return An \code{ipriorKernel} object which contains the relevant material to #' be passed to the \code{iprior} function for model fitting. @@ -205,7 +206,7 @@ if (as.numeric(nystrom[1]) > 0 & as.numeric(nystrom[1]) != n) { if (!is.null(nys.seed)) set.seed(nys.seed) nys.samp <- sample(seq_along(y)) } - + y.tmp <- y[nys.samp] mostattributes(y.tmp) <- attributes(y) y <- y.tmp diff --git a/README.md b/README.md index 3f8ccfe..4ec73ea 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,14 @@ [![R-CMD-check](https://github.com/haziqj/iprior/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/haziqj/iprior/actions/workflows/R-CMD-check.yaml) - +[![test-coverage](https://github.com/haziqj/iprior/actions/workflows/test-coverage.yaml/badge.svg)](https://github.com/haziqj/iprior/actions/workflows/test-coverage.yaml) [![CRAN_Status_Badge_version_ago](http://www.r-pkg.org/badges/version-ago/iprior)](https://cran.r-project.org/package=iprior) [![CRAN downloads](http://cranlogs.r-pkg.org/badges/grand-total/iprior)](https://cran.r-project.org/package=iprior) - + Based on the manuscript entitled "Regression and Classification with I-priors" by Wicher Bergsma (2018, [arXiv:1707.00274](https://arxiv.org/abs/1707.00274)). In a general regression setting, priors can be assigned to the regression function in a vector space framework, and the posterior estimate of the regression function obtained. diff --git a/man/kernL.Rd b/man/kernL.Rd index 4fd5c2a..71be1bf 100644 --- a/man/kernL.Rd +++ b/man/kernL.Rd @@ -115,6 +115,8 @@ should be used for training, and the remaining used for testing.} \item{test.samp}{(Optional) Similar to \code{train.samp}, but on test samples instead.} +\item{intercept}{(Optional) Intercept for response variables.} + \item{formula}{The formula to fit when using formula interface.} \item{data}{Data frame containing variables when using formula interface.} diff --git a/vignettes/iprior_paper.pdf b/vignettes/iprior_paper.pdf new file mode 100644 index 0000000..ac92ee8 Binary files /dev/null and b/vignettes/iprior_paper.pdf differ diff --git a/vignettes/tecator.Rmd b/vignettes/tecator.Rmd index 2e4b4ee..17966be 100644 --- a/vignettes/tecator.Rmd +++ b/vignettes/tecator.Rmd @@ -4,7 +4,7 @@ author: "Haziq Jamil" date: "`r Sys.Date()`" output: rmarkdown::html_vignette vignette: > - %\VignetteIndexEntry{Cross-validation analysis of the Tecator data set} + %\VignetteIndexEntry{Regression with a functional covariate: Cross-validation analysis of the Tecator data set} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} %\VignetteDepends{iprior,caret}