Error in nobs.default(x) : no 'nobs' method is available with MuMIn::model.sel()

216 views Asked by At

I am trying to select top models from a list of model outputs. The models were run using uGamm(), the wrapper function that is supposed to allow gamm4 models to be used with the MuMIn model selection and averaging functions.

Example model:

fit <- 
    uGamm(y~ s(x1) + s(x2, bs = 'cc') + s(x3) +  s(X,Y, bs= 'ts') + s(r1, bs = 're') +s (r2, bs = 're') + s(r3, bs = 're'),
          data = dat,
          lme4 = TRUE)

There are 3 random effects (r1, r2, and r3). I tried to load in the model outputs, and each output consists of a mer object and a gam object. I wanted to run the model selection on the gam objects.

gamm_list <- list()

for (i in 1:length(mod_names){
  mod <- readRDS(mod_names[[i]])
  #keeping only the gam object, otherwise the objects are too large to load into env
  gamm_list[[i]] <- mod$gam
}

model.sel <- model.sel(gamm_list)

But I keep generating "Error in nobs.default(x) : no'nobs' method is available". This error does not occur if I do the same code above using the mod$mer object instead of mod$gam. The ultimate goal is to identify the top models to generate predictions with predict().

0

There are 0 answers