3

I am trying to do model selection for generalized additive mixed models (made using gamm4 using the MuMIn package in R. I am essentially trying to follow this piece of literature for model selection with MuMIn and gamm4.

I am creating a model with 9 variables, and a random individual effect - which looks likes this:

library(gamm4)
library(MuMIn)
SouthFull = gamm4(OtoWidth ~ s(Ages) + 
                 LagFinFSLdat_AnnEsts +
                 FSL_months_Feb +
                 LagFSLdat_Annual +
                 LagFSLdat_Spring +
                 LagFSL_months_Oct+
                 FinFSLdat_SummerDat +
                 FinFSLdat_AutumnDat +
                 LagFSL_months_Nov , random = ~(1|FishName), data = South)

But when I try to use the dredge function, it fails with the error message:

(dd <- dredge(global.model=SouthFull))
Error in dredge(global.model = SouthFull) : result is empty

    In addition: There were 50 or more warnings (use warnings() to see the first 50)
    > warnings()
    Warning messages:
    1: In gamm4::gamm4(...) : family not recognized (model 1 skipped)
    ...
    50: In gamm4::gamm4(...) : family not recognized (model 50 skipped)

Is this due to a problem with MuMIn not recognizing the gamm4 model family?

Full code & data can be found at my GitHub repository and the specific issue is in the code gamm_analysis.R, with the specific warnings found at line 81.

Thank you in advance

www
  • 38,575
  • 12
  • 48
  • 84
emboylen
  • 137
  • 2
  • 13
  • 1
    Please include all relevant information in the post. – Roman Luštrik Mar 17 '15 at 08:29
  • Is that a little better? Anything I missed? – emboylen Mar 17 '15 at 08:57
  • Seems that your code has been written to work with some **very** old version of MuMIn. Try without including "Extgamm4.R" and read `?uGamm`. – Kamil Bartoń Mar 17 '15 at 10:46
  • Ok, now I noticed that you're referring to MuMIn's vignette from 2011 (which has long been removed but obviously is still available through R-Forge's svn). So you definitely should use and follow the manual for the current version. – Kamil Bartoń Mar 17 '15 at 10:51
  • 1
    OK thank you @Kamil Barton - I have tried running my scrip without "Extgamm4.R". Now when I run `dredge(SouthFull)` I get the error message: `Error in nobs.default(global.model) : no 'nobs' method is available` - any advice? – emboylen Mar 23 '15 at 05:04
  • have you read `?uGamm`? – Kamil Bartoń Mar 23 '15 at 13:59
  • Yes I did, but I obviously didn't read it closely enough @KamilBartoń. I have updated my script after reading `?uGamm`, so now it looks like this: `Stest = uGamm(SouthFull)` `getCall(Stest)` `update(Stest)` `dredge(Stest)` – emboylen Mar 24 '15 at 05:34
  • 1
    Did you solve the problem? I am havig the same issue with gamm4. `Error in nobs.default(global.model) : no 'nobs' method is available` – JMarcelino Jan 15 '20 at 16:20
  • I'm also having the same problem, did anyone ever figure it out? – leslie roberson Nov 11 '21 at 21:25

1 Answers1

1

I think that there is something wrong with the package. I have the same error. Then, I tried to run the example available in the help of the function dredge of the MumIn package to see what I am doing differently and I get the same error even using the example below:

fm1 <- lm(y ~ ., data = Cement)
dd <- dredge(fm1)

The error message is:

Error in nobs.default(global.model) : no 'nobs' method is available
BSMP
  • 4,596
  • 8
  • 33
  • 44
  • This does not happen normally. Perhaps try the example in a clean workspace. – Kamil Bartoń Oct 01 '18 at 19:49
  • I always get this result. I was trying in Rstudio before and now I tried in R without using Rstudio, just copying and pasting the example and still get the same error... I don't know what is happening... – Caryne Braga Oct 02 '18 at 11:10
  • Interesting. Are you using a current version of R and MuMIn? You can also check if `nobs(fm1)` works (R should not look for `nobs.default` but rather for `nobs.lm`). – Kamil Bartoń Oct 02 '18 at 11:38