Skip to content

Commit

Permalink
Initialise in the first phase, rather than spreading over phases
Browse files Browse the repository at this point in the history
  • Loading branch information
chjackson committed Nov 18, 2024
1 parent 46d2687 commit 0537c44
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions R/msmbayes_internal.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,14 @@ form_initprobs <- function(em, dat, pm){
state_new <- match(state_old, pm$pdat$oldinds)
initprobs[cbind(iprow,state_new)] <- 1

## else for phased states, set prob of potential states to 1/nphases
## for phased states, start in first phase
## (previously set equal prob in each phase
## could let user set if they really want this model)
iprow <- which(initstate %in% pm$phased_states)
state_old <- initstate[initstate %in% pm$phased_states]
for (i in seq_along(iprow)){
state_new <- which(pm$pdat$oldinds==state_old[i])
nphases <- length(state_new)
initprobs[iprow[i],state_new] <- 1/nphases
firstphase <- min(which(pm$pdat$oldinds==state_old[i]))
initprobs[iprow[i],firstphase] <- 1
}
} else {
initprobs[,1] <- 1
Expand Down

0 comments on commit 0537c44

Please sign in to comment.