Syntax for nested random intercept in a GAMM

Hello,

I have a sample design that I'm having trouble translating into the correct syntax in the mgcv package language. My set-up looks like this: We trawl for fish in a bay to see if they're eating or not (empty or not-empty: 1/0) and see if it's linked to the location and/or time of capture. We trawl once per "station" (the location), at 80 stations, once per month, every year. Several stations make-up a zone. If I wanted to know if fish with empty stomachs varied between zones and years, but not stations, would that look something like this? Can a variable be both a fixed and random effect?

library(mgcv)

# fStation = factor location
# fZone = factor zone
# fCYR = factor calendar year
# CYR = year as continuous variable for random slope

bam(empty ~ fZone + 
            fCYR + 
            s(fStation, fZone, fCYR, bs = 're') + # station within zone, within year?
            s(fZone, CYR, bs = 're'),   # Each zone can have its own trend through time?
         data = c_neb4, 
         method = 'fREML', 
         discrete = TRUE,
         family = binomial(link = "logit"), 
         select = TRUE)

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.