Description Usage Arguments Details Value Examples
View source: R/make.markov.chain.r
Generate Markov chains from a set of transition matrices
1 | make.markov.chain(boxtrans = boxtrans, s.init = 3, sorder = rep(1:4, 1000))
|
boxtrans |
list of transition matrices. Ususally this will be seasonal; winter, spring, summer and fall |
s.init |
starting area |
sorder |
order of the seasons. 1-4 is winter, spring, summer and fall |
need to make sure not to get into an impossible scenario where the prob is zero of moving out of the current area... this happens for fish going into the Med from the West
a vector of area categories corresponding to the boxes used in the simulation phase
1 2 3 4 5 6 | # simulate 100 chains (fish) for 100 cycles (years) with randomized starting seasons
xx = sapply(sample(1:4, 100, replace = T ), function(x) make.markov.chain(boxtrans, s.init = x, sorder = rep(1:4, 1000)))
# plot two chains (fish) for 50 cycles (years)
image.plot(1:200, 1:2,(xx[1:200,1:2]), nlevel = 7, zlim = c(1,7), xlab = 'cycle', ylab = 'chain (fish)', axes = T)
barplot(table(xx[1:200,]))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.