# Estimation can use observed transitions with different levels of factors.
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
# With by=c("a", "b") there are two observations: one from prior and the other
# from the exact combination of class levels.
probs <- estimatetransprobs("vol", pairdata, statespace, by=c("a", "b"), prior="nochange")
act1 <- define_activity("test", c("vol"), probs)
runEFDM(state0, actprob, list(act1), 1)
probs <- estimatetransprobs("vol", pairdata, statespace, factors="a", by="b", prior="nochange")
act2 <- define_activity("test", c("vol"), probs)
runEFDM(state0, actprob, list(act2), 1)
probs <- estimatetransprobs("vol", pairdata, statespace, factors="b", by="a", prior="nochange")
act3 <- define_activity("test", c("vol"), probs)
runEFDM(state0, actprob, list(act3), 1)
# The order of variables in factors argument specifies the order of importance.
# Observation that differ in the first variable are counted more times.
probs <- estimatetransprobs("vol", pairdata, statespace, factors=c("a", "b"), prior="nochange")
act4 <- define_activity("test", c("vol"), probs)
runEFDM(state0, actprob, list(act4), 1)
probs <- estimatetransprobs("vol", pairdata, statespace, factors=c("b", "a"), prior="nochange")
act5 <- define_activity("test", c("vol"), probs)
runEFDM(state0, actprob, list(act5), 1)
Run the code above in your browser using DataLab