Page 1 of 1

Time-varying environmental covariates in marked

PostPosted: Tue Feb 06, 2024 6:14 pm
by kbearden
I am trying to add a time-varying environmental covariate using the probitcjs function in marked. Does anyone have an example of how to code this into the design matrix to then be used when constructing your models?

I am trying to estimate the affects of open river (OR) conditions on apparent survival and transition probabilities for a group of tagged fish (n = 191). I have calculated the total number of open river days and have an estimate for each state of the 8 states during all 48 time periods. So, my resulting data frame with the ch, sex, total length, and each of the OR estimates is 191 by 387.

Below is the code that I have tried ... I was modifying code found in the marked vignette.

Code: Select all
pdfh4 <- cbind(pdfh1, pdfh3) # Data frame with ch and newly named OR columns

pdfh4.proc <- process.data(pdfh4, model = "Multistrata") # Process the data

design.S <- list(time.varying = c("OR"))
design.Psi <- list(time.varying = c("OR"))
design.parameters <- list(S = design.S, Psi = design.Psi)
ddl <- make.design.data(pdfh4.proc, parameters = design.parameters)
names(ddl$S)
names(ddl$Psi)
model.parameters <- list(Psi = list(formula = ~ OR),
                         S = list(formula = ~ OR))
MCMCfit <- crm(pdfh4, model = "probitCJS",
               model.parameters = model.parameters,
               burnin = 1000, iter = 5000)


And this is the error that I am getting when I run the above model:

Code: Select all
Error in process.data(data, begin.time = begin.time, model = model, mixtures = 1,  :
 
Incorrect ch values in data:0GHFEBACD


Any help or suggestions would be greatly appreciated!! I can provide additional code or files if needed.

Thank you,
Katie

Re: Time-varying environmental covariates in marked

PostPosted: Wed Dec 04, 2024 7:13 pm
by jlaake
Not sure if this post was answered offline or not. The error message was because strata.labels were not specified and didn't have anything to do with time varying covariates. Sorry if I missed this one.