tests/testthat/test-roxytest-testexamples-mm.R

# Generated by roxytest: Do not edit by hand!

context("File R/mm.R: @testexamples")

test_that("Function mm() @ L30", {
  
  states <- c("a", "c", "g", "t")
  s <- length(states)
  k <- 1
  init <- rep.int(1 / s, s)
  p <- matrix(c(0, 0, 0.3, 0.4, 0, 0, 0.5, 0.2, 0.7, 0.5, 
                0, 0.4, 0.3, 0.5, 0.2, 0), ncol = s)
  
  # Specify a Markov model of order 1
  markov <- mm(states = states, init = init, ptrans = p, k = k)
  
  expect_true(all(markov$param == p))
  expect_true(all(markov$init == init))
})


test_that("Function simulate.mm() @ L308", {
  
  states <- c("a", "c", "g", "t")
  s <- length(states)
  k <- 2
  init <- rep.int(1 / s ^ k, s ^ k)
  p <- matrix(0.25, nrow = s ^ k, ncol = s)
  
  # Specify a Markov model of order 1
  markov <- mm(states = states, init = init, ptrans = p, k = k)
  
  seqs <- simulate(object = markov, nsim = c(1000, 10000, 2000), seed = 150)
  
  expect_equal(length(seqs), 3)
  expect_equal(sapply(seqs, length), c(1000, 10000, 2000))
  expect_equal(seqs[[1]][995:1000], c("g","c","a","c","a","t"))
})
corentin-dev/smmR documentation built on April 14, 2023, 11:36 p.m.