Skip to content

Commit

Permalink
Also some tests in hmmmulti
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico authored Oct 3, 2024
1 parent 97b4ecf commit e5316fd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/testthat/test_models_hmmmulti.r
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ options(msm.test.analytic.derivatives=TRUE)
err <- 1e-04

test_that("HMMs with multiple responses from the same distribution",{
skip_if_not_installed("numDeriv")
hmm <- msm(obs ~ time, subject=subject, data=dat, qmatrix=two.q,
hmodel = list(hmmBinom(size=40, prob=0.2),
hmmBinom(size=40, prob=0.2)), fixedpars=TRUE)
Expand All @@ -43,13 +44,15 @@ test_that("HMMs with multiple responses from the same distribution",{
})

test_that("HMMs with multiple responses: cbind() in formula",{
skip_if_not_installed("numDeriv")
hmm <- msm(cbind(obs1, obs2) ~ time, subject=subject, data=dat, qmatrix=two.q,
hmodel = list(hmmBinom(size=40, prob=0.2),
hmmBinom(size=40, prob=0.2)), fixedpars=TRUE)
expect_equal(hmm$minus2loglik, 4387.58552977954, tol=1e-06)
})

test_that("HMMs with multiple responses from different distributions",{
skip_if_not_installed("numDeriv")
hmm <- msm(dobs ~ time, subject=subject, data=dat, qmatrix=two.q,
hmodel = list(hmmMV(hmmBinom(size=40, prob=0.3),
hmmBinom(size=40, prob=0.3)),
Expand All @@ -70,6 +73,7 @@ test_that("HMMs with multiple responses from different distributions",{
})

test_that("HMMs with multiple responses from different distributions: non-default initprobs, different probs",{
skip_if_not_installed("numDeriv")
hmm <- msm(dobs ~ time, subject=subject, data=dat, qmatrix=two.q,
initprobs=c(0.6, 0.4),
hmodel = list(hmmMV(hmmBinom(size=40, prob=0.3),
Expand All @@ -84,6 +88,7 @@ dat$dobsmiss <- dat$dobs
dat$dobsmiss[1:10,2] <- NA

test_that("HMMs with multiple responses from different distributions: missing data",{
skip_if_not_installed("numDeriv")
hmm <- msm(dobsmiss ~ time, subject=subject, data=dat, qmatrix=two.q,
hmodel = list(hmmMV(hmmBinom(size=40, prob=0.3),
hmmBinom(size=40, prob=0.3)),
Expand All @@ -98,6 +103,7 @@ obstimes <- seq(2, 147, by=5) # times when true state is known
dat$obstrue[obstimes] <- dat$state[obstimes]

test_that("HMMs with multiple responses: true state known sometimes",{
skip_if_not_installed("numDeriv")
hmm <- msm(dobs ~ time, subject=subject, data=dat, qmatrix=two.q,
obstrue=obstrue,
hmodel = list(hmmMV(hmmBinom(size=40, prob=0.3),
Expand Down

0 comments on commit e5316fd

Please sign in to comment.