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) > pairdata <- data.frame(a=c(1,1,2,2), b=c(1,2,1,2), vol0=c(1,1,1,1), vol1=c(2,3,4,5)) > state0 <- statespace > actprob <- statespace > actprob$test <- 1 > state0$area <- 0 > state0$area[1] <- 1 > > act1 <- define_activity("test", c("vol")) > transprobs(act1) <- estimatetransprobs("vol", pairdata, statespace, by=c("a", "b"), prior="nochange") > A <- transprobs(act1) > res0 <- runEFDM(state0, actprob, list(act1), 1) > > transprobs(act1) <- A > res1 <- runEFDM(state0, actprob, list(act1), 1) > expect_identical(res0, res1) > > act2 <- define_activity("test", c("vol")) > transprobs(act2) <- A > res2 <- runEFDM(state0, actprob, list(act2), 1) > expect_identical(res0, res2) > > A$asdf <- 1 > transprobs(act1) <- A > expect_error(runEFDM(state0, actprob, list(act1), 1, check=FALSE), + "Variable 'asdf' required by activity 'test' not present in state.") > expect_error(runEFDM(state0, actprob, list(act1), 1), + "Activity 'test' has variable asdf not in actprob.") > > > act3 <- define_activity("test", c("vol")) > transprobs(act3) <- data.frame(vol0 = 1:5, vol1=c(2:5, 5), prob=1) > res3 <- runEFDM(state0, actprob, list(act3), 3) > # Test something? > > proc.time() user system elapsed 0.9 0.1 1.0