-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/brandmaier/semtree # Conflicts: # DESCRIPTION
- Loading branch information
Showing
29 changed files
with
1,443 additions
and
1,292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
on: | ||
workflow_dispatch | ||
|
||
name: Tests | ||
|
||
jobs: | ||
document: | ||
name: run tests | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
cache-version: 2 | ||
extra-packages: | | ||
any::testthat | ||
any::devtools | ||
# needs: pr-document | ||
- name: install package | ||
run: devtools::install_github("brandmaier/semtree") | ||
|
||
- name: run test | ||
run: testthat::test_dir("tests/testthat/") | ||
shell: Rscript {0} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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@v3 | ||
|
||
- 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(Sys.getenv("RUNNER_TEMP"), "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@v3 | ||
with: | ||
name: coverage-test-failures | ||
path: ${{ runner.temp }}/package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,41 @@ | ||
#' Wrapper function for computing the maxLR corrected p value | ||
#' from strucchange | ||
#' | ||
#' | ||
#' @param maxLR maximum of the LR test statistics | ||
#' @param q number of free SEM parameters / degrees of freedom | ||
#' @param covariate covariate under evaluation. This is important to get the level of | ||
#' measurement from the covariate and the bin size for ordinal and | ||
#' categorical covariates. | ||
#' @param from numeric from interval (0, 1) specifying start of trimmed | ||
#' sample period. With the default | ||
#' sample period. With the default | ||
#' from = 0.15 the first and last 15 percent of observations are | ||
#' trimmed. This is only needed for continuous covariates. | ||
#' @param to numeric from interval (0, 1) specifying end of trimmed | ||
#' sample period. By default, to is 1. | ||
#' @param nrep numeric. Number of replications used for simulating from the asymptotic | ||
#' @param nrep numeric. Number of replications used for simulating from the asymptotic | ||
#' distribution (passed to efpFunctional). Only needed for ordinal | ||
#' covariates. | ||
#' | ||
# | ||
#' @author Manuel Arnold | ||
#' @return Numeric. p value for maximally selected LR statistic | ||
|
||
computePval_maxLR <- function(maxLR, q, covariate, from, to, nrep) { | ||
# Level of measurement | ||
if (!is.factor(covariate)) { # metric | ||
pval <- strucchange::supLM(from = from, to = to)$computePval(x = maxLR, nproc = q) | ||
} else { | ||
covariate <- sort(covariate) # sort covariate | ||
covariate <- droplevels(covariate) | ||
if (is.ordered(covariate)) { # ordinal | ||
pval <- strucchange::ordL2BB(freq = covariate, nproc = q, | ||
nrep = nrep)$computePval(x = maxLR, nproc = q) | ||
} else { # categorical | ||
pval <- strucchange::catL2BB(covariate)$computePval(x = maxLR, nproc = q) | ||
} | ||
computePval_maxLR <- function(maxLR, q, covariate, from, to, nrep) { | ||
# Level of measurement | ||
if (!is.factor(covariate)) { # metric | ||
pval <- strucchange::supLM(from = from, to = to)$computePval(x = maxLR, nproc = q) | ||
} else { | ||
covariate <- sort(covariate) # sort covariate | ||
covariate <- droplevels(covariate) | ||
if (is.ordered(covariate)) { # ordinal | ||
pval <- strucchange::ordL2BB( | ||
freq = covariate, nproc = q, | ||
nrep = nrep | ||
)$computePval(x = maxLR, nproc = q) | ||
} else { # categorical | ||
pval <- strucchange::catL2BB(covariate)$computePval(x = maxLR, nproc = q) | ||
} | ||
|
||
pval | ||
|
||
} | ||
|
||
|
||
pval | ||
} |
Oops, something went wrong.