Skip to content

Commit

Permalink
use predict in get_probs, fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
helske committed Sep 8, 2024
1 parent ec5270e commit 7630082
Show file tree
Hide file tree
Showing 32 changed files with 229 additions and 289 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ vignettes/jss.cls
^\.github$
^codecov\.yml$
^.covrignore
^\.covrignore$
1 change: 0 additions & 1 deletion .covrignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ R/ssp-deprecated.R
R/ssplot-deprecated.R
R/ssplotM-deprecated.R
R/SSplotter-deprecated.R

4 changes: 4 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
# this sets the env variable to true or false depending on whether the
# commit message contains text 'run-extended'
SEQHMM_EXTENDED_TESTS: ${{contains(github.event.head_commit.message, 'run-extended')}}


steps:
- uses: actions/checkout@v3
Expand Down
30 changes: 22 additions & 8 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,61 @@ on:
push:
branches: [main, stan]
pull_request:
branches: [main, master]
branches: [main, stan]

name: test-coverage.yaml

name: test-coverage
permissions: read-all

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
# this sets the env variable to true or false depending on whether the
# commit message contains text 'run-extended'
SEQHMM_EXTENDED_TESTS: ${{contains(github.event.head_commit.message, 'run-extended')}}

steps:
- uses: actions/checkout@v3
- 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
extra-packages: any::covr, any::xml2
needs: coverage

- name: Test coverage
run: |
covr::codecov(
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
file: ./cobertura.xml
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ LinkingTo:
rstan (>= 2.18.1),
StanHeaders (>= 2.18.0)
Depends:
R (>= 3.5.0)
R (>= 4.1.0)
Imports:
checkmate,
cli,
Expand Down
2 changes: 1 addition & 1 deletion R/average_marginal_prediction.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ average_marginal_prediction <- function(
)
} else {
stopifnot_(
is.null(model$data),
!is.null(model$data),
"Model does not contain original data and argument {.arg newdata} is
{.var NULL}."
)
Expand Down
2 changes: 1 addition & 1 deletion R/build_hmm.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#' "joblessness", "school", "training"
#' )
#' mvad_scodes <- c("EM", "FE", "HE", "JL", "SC", "TR")
#' mvad_seq <- seqdef(mvad, 17:86,
#' mvad_seq <- seqdef(mvad, 15:86,
#' alphabet = mvad_alphabet, states = mvad_scodes,
#' labels = mvad_labels, xtstep = 6
#' )
Expand Down
2 changes: 1 addition & 1 deletion R/build_lcm.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
#' "joblessness", "school", "training"
#' )
#' mvad_scodes <- c("EM", "FE", "HE", "JL", "SC", "TR")
#' mvad_seq <- seqdef(mvad, 17:86,
#' mvad_seq <- seqdef(mvad, 15:86,
#' alphabet = mvad_alphabet, states = mvad_scodes,
#' labels = mvad_labels, xtstep = 6
#' )
Expand Down
2 changes: 1 addition & 1 deletion R/build_mm.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#' "joblessness", "school", "training"
#' )
#' mvad_scodes <- c("EM", "FE", "HE", "JL", "SC", "TR")
#' mvad_seq <- seqdef(mvad, 17:86,
#' mvad_seq <- seqdef(mvad, 15:86,
#' alphabet = mvad_alphabet,
#' states = mvad_scodes, labels = mvad_labels, xtstep = 6,
#' cpal = colorpalette[[6]]
Expand Down
2 changes: 1 addition & 1 deletion R/build_mmm.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#' "joblessness", "school", "training"
#' )
#' mvad_scodes <- c("EM", "FE", "HE", "JL", "SC", "TR")
#' mvad_seq <- seqdef(mvad, 17:86,
#' mvad_seq <- seqdef(mvad, 15:86,
#' alphabet = mvad_alphabet, states = mvad_scodes,
#' labels = mvad_labels, xtstep = 6
#' )
Expand Down
2 changes: 1 addition & 1 deletion R/build_mnhmm.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ build_mnhmm <- function(
nobs = attr(out$observations, "nobs"),
df = out$extras$n_pars,
type = paste0(out$extras$multichannel, "mnhmm_", out$extras$model_type),
intercept_only = intercept_only
intercept_only = out$extras$intercept_only
)
}
2 changes: 1 addition & 1 deletion R/build_nhmm.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ build_nhmm <- function(
nobs = attr(out$observations, "nobs"),
df = out$extras$n_pars,
type = paste0(out$extras$multichannel, "nhmm_", out$extras$model_type),
intercept_only = intercept_only
intercept_only = out$extras$intercept_only
)
}
19 changes: 10 additions & 9 deletions R/estimate_mnhmm.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@
#' @examples
#' data("mvad", package = "TraMineR")
#'
#' mvad_alphabet <-
#' c("employment", "FE", "HE", "joblessness", "school", "training")
#' mvad_labels <- c("employment", "further education", "higher education",
#' "joblessness", "school", "training")
#' mvad_scodes <- c("EM", "FE", "HE", "JL", "SC", "TR")
#' mvad_seq <- seqdef(mvad, 17:86, alphabet = mvad_alphabet,
#' states = mvad_scodes, labels = mvad_labels, xtstep = 6,
#' cpal = unname(colorpalette[[6]]))
#' d <- reshape(mvad, direction = "long", varying = list(15:86),
#' v.names = "activity")
#'
#' \dontrun{
#' set.seed(1)
#' fit <- estimate_mnhmm(mvad_seq, n_states = 3, n_clusters = 2)
#' fit <- estimate_mnhmm("activity", n_states = 3, n_clusters = 2,
#' data = d, time = "time", id = "id",
#' cluster_formula = ~ male + catholic + gcse5eq + Grammar +
#' funemp + fmpr + livboth + Belfast +
#' N.Eastern + Southern + S.Eastern + Western,
#' initial_formula = ~ 1, emission_formula = ~ male + catholic + gcse5eq,
#' transition_formula = ~ male + gcse5eq, inits = "random"
#' )
#' }
estimate_mnhmm <- function(
observations, n_states, n_clusters, initial_formula = ~1,
Expand Down
2 changes: 1 addition & 1 deletion R/estimate_nhmm.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#' mvad_labels <- c("employment", "further education", "higher education",
#' "joblessness", "school", "training")
#' mvad_scodes <- c("EM", "FE", "HE", "JL", "SC", "TR")
#' mvad_seq <- seqdef(mvad, 17:86, alphabet = mvad_alphabet,
#' mvad_seq <- seqdef(mvad, 15:86, alphabet = mvad_alphabet,
#' states = mvad_scodes, labels = mvad_labels, xtstep = 6,
#' cpal = unname(colorpalette[[6]]))
#'
Expand Down
2 changes: 1 addition & 1 deletion R/fit_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
#' "joblessness", "school", "training"
#' )
#' mvad_scodes <- c("EM", "FE", "HE", "JL", "SC", "TR")
#' mvad_seq <- seqdef(mvad, 17:86,
#' mvad_seq <- seqdef(mvad, 15:86,
#' alphabet = mvad_alphabet,
#' states = mvad_scodes, labels = mvad_labels, xtstep = 6,
#' cpal = colorpalette[[6]]
Expand Down
Loading

0 comments on commit 7630082

Please sign in to comment.