I am revising a multistate model and I'd like to include environmental covariates. One covariate (temperature) is time varying but constant across space (strata) and the other (gage height) varies in both space and time. I'd like to include these covariates into the transition probabilities among states (Psi), but I'm uncertain of how to incorporate them into the model/design matrix. In a previous version of the model, I added month and season to the design matrix using the following code:

- Code: Select all
`time <- 1:103`

month <- c(6:12, rep(1:12, 8))

season <- character(length = length(month))

for(i in 1:length(season)){

if (month[i] > 5 & month[i] < 9)

season[i] <- 'Summer'

if (month[i] > 8 & month[i] < 12)

season[i] <- 'Autumn'

if (month[i] == 12 | month[i] < 3)

season[i] <- 'Winter'

if (month[i] > 2 & month[i] < 6)

season[i] <- 'Spring'

}

month <- factor(month, levels = c('6', '7', '8', '9', '10', '11', '12',

'1', '2', '3', '4', '5'),

labels = c('Jun', 'Jul', 'Aug', 'Sep',

'Oct', 'Nov', 'Dec', 'Jan',

'Feb', 'Mar', 'Apr', 'May'))

season <- as.factor(season)

design_covariates <- data.frame(time = time,

month = month,

season = season)

# merge design covariates with design data for each parameter

eh_2013_2021_SVC.ddl$S <- merge_design.covariates(eh_2013_2021_SVC.ddl$S,

design_covariates)

eh_2013_2021_SVC.ddl$p <- merge_design.covariates(eh_2013_2021_SVC.ddl$p,

design_covariates)

eh_2013_2021_SVC.ddl$Psi <- merge_design.covariates(eh_2013_2021_SVC.ddl$Psi,

design_covariates)

It seems that adding in temperature (not spatially varying) would be simple, I can add it to the design_covariates data frame and it will align with the other design covariates (1 measurement per occasion), but I'm not sure how to approach the spatially varying gage height (8 measurements per occasion). Any thoughts or resources are appreciated.

Thanks,

Ben