Page 1 of 1

simHMM with JS model

PostPosted: Fri Nov 08, 2019 2:06 pm
by SoConfused
Hello,

I'm slowly learning to use the excellent simHMM function to simulate data. Everything works great with a HMMcjs model, but I'm getting an error for a JS specification and I can't figure out why (didn't see any restrictions in the documentation either). Any help to resolve or circumvent would be appreciated.

Example of the issue with some fake data:

Code: Select all
library(dplyr)
library(marked)

df <- structure(list(ch = c("100000000000", "100000000000", "100000000000",
"010000000000", "010000000000", "010000000000", "001000000000",
"001000000000", "001000000000", "000100000000", "000100000000",
"000100000000", "000010000000", "000010000000", "000010000000",
"000001000000", "000001000000"), Group = structure(c(1L,
2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L
), .Label = c("a", "b", "c"), class = "factor"), freq = c(21,
14, 3, 47, 62, 14, 48, 43, 8, 64, 67, 25, 65, 63, 17, 82, 55)), row.names = c(1L,
2L, 3L, 6L, 7L, 8L, 15L, 16L, 17L, 24L, 25L, 26L, 33L, 34L, 35L,
43L, 44L), class = "data.frame")


Then specifying the sim structure
Code: Select all
modelspec <- list(Phi = list(formula = ~ 1),   p = list(formula = ~ 1),
   pent = list(formula = ~ 1), N = list(formula = ~ 1))
dp.sim <- marked::process.data(df, model="JS")
ddl.sim <- marked::make.design.data(dp.sim)
               
phi <- 1
p <- -2.8
pent <- -2.6
N <- 6
   
initial <- list(Phi = phi,   p = p, pent = pent, N = N)
realization <- simHMM(dp.sim, ddl.sim, model = "JS", model.parameters = modelspec, initial = initial)
   

Re: simHMM with JS model

PostPosted: Fri Nov 08, 2019 3:07 pm
by jlaake
No simHMM in RMark. The JS model is not an HMM (Hidden Markov Model) formulation. I don't think any model including N can be formulated as an HMM but I could be wrong about that. You could simulate the entrants and the time first seen and then feed that to the cjshmm to simulate the rest of the capture history. I'll look at code but I thought it would reject model if not an HMM.

--jeff

Re: simHMM with JS model

PostPosted: Fri Nov 08, 2019 5:11 pm
by SoConfused
Ah, I see where I went wrong. I knew that the marked package handled JS models, so just jumped to conclusions. Now have to figure out how to simulate JS data...

Re: simHMM with JS model

PostPosted: Fri Nov 08, 2019 5:14 pm
by cooch
Simple -- use MARK. You can simulate JS (and most other data types) right from within MARK.