Time-varying environmental covariates in marked

questions concerning analysis/theory using the R package 'marked'

Time-varying environmental covariates in marked

Postby kbearden » Tue Feb 06, 2024 6:14 pm

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
kbearden
 
Posts: 7
Joined: Fri Jun 09, 2023 5:04 pm

Re: Time-varying environmental covariates in marked

Postby jlaake » Wed Dec 04, 2024 7:13 pm

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.
jlaake
 
Posts: 1479
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA


Return to analysis help

Who is online

Users browsing this forum: No registered users and 1 guest

cron