R Under development (unstable) (2023-08-05 r84874 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(efdm) > library(testthat) > statespace <- expand.grid(a=1:2, b=1:2, vol=1:5) > state0 <- statespace > actprob <- statespace > actprob$test <- 1 > state0$area <- 0 > state0$area[1] <- 1 > > > act3 <- define_activity("test", c("vol")) > transprobs(act3) <- data.frame(vol0 = 1:4, vol1=2:5, prob=1) > expect_error(runEFDM(state0, actprob, list(act3), 5), "States with no activity (in list of activities)", fixed=TRUE) [1] "States with no activity (in list of activities):" vol a b test check___ 17 5 1 1 1 0 18 5 2 1 1 0 19 5 1 2 1 0 20 5 2 2 1 0 > expect_error(runEFDM(state0, data.frame(test=1), list(act3), 5), "No state variables in actprob") > > > > transprobs(act3) <- data.frame(vol0 = 1:5, vol1=c(2:6), prob=1) > expect_error(runEFDM(state0, actprob, list(act3), 3), "Activity transitions to state not in actprob") [1] "Activity 'test' caused transitions to state not in actprob:" vol a b test check___ check_1__ 21 6 NA NA NA NA NA > > > expect_error(runEFDM(state0, actprob, list(act3, act3), 3), "States with multiple activities") [1] "States with multiple activities:" vol a b test check___ check_1__ 1 1 1 1 1 2 1 2 1 2 1 1 2 1 3 1 1 2 1 2 1 4 1 2 2 1 2 1 5 2 1 1 1 2 1 6 2 2 1 1 2 1 > > > act4 <- define_activity("test2", c("vol")) > transprobs(act4) <- data.frame(vol0 = 1:5, vol1=c(2:5,5), prob=1) > expect_error(runEFDM(state0, actprob, list(act4), 5), "Activity probabilities for test2 not given.") > > act5 <- define_activity("test", c("vol")) > transprobs(act5) <- data.frame(vol0 = 1:6, vol1=2, prob=1) > expect_error(runEFDM(state0, actprob, list(act5), 5), "Activity transitions from state not in actprob") [1] "Activity transitions from state not in actprob:" vol a b test check___ 21 6 NA NA NA NA > > act6 <- define_activity("test", c("vol")) > expect_error(runEFDM(state0, actprob, list(act6), 1), "Activity 'test' has no transprobs.") > transprobs(act6) <- data.frame(vol0 = 1:5, vol1=2, c=1, prob=1) > expect_error(runEFDM(state0, actprob, list(act6), 1), "Activity 'test' has variable c not in actprob.") > > actprob$test[3] <- NA > expect_error(runEFDM(state0, actprob, list(act3), 5), "Actprob should not have NAs.") > > actprob$test2 <- actprob$test <- 0.5 > expect_error(runEFDM(state0, actprob, list(act3), 5), "Activity probabilities for test2 given, but activities not.") > > proc.time() user system elapsed 1.06 0.10 1.15