Search code examples
rgammumin

Fixed terms in dredge function (MuMin) in GAM


I am trying to use MuMIn::dredge()function to build a GAM model. I am working on fish distribution and with the aim to speed up the analysis due the size of the dataset, I want to fix two variables, for example, depth and the interaction (latitude, longitude).

I have read the package documentation and also have looked for any suggestion in this forum but I have not been successful. The following code works,

Allmodels_Presence <- dredge(Gadiculus_Pres, rank=AIC, fixed= ~s(depth, k=4), trace=2)

for but it only has fixed one variable and I don´t know how to fix the other one s(Lon_Proj, Lat_Proj, k=20), even though I have tried several approaches (mainly following the help for subsetting in dredge() ).

Any idea or suggestions will be more than welcome. Thanks in advance.


Solution

  • From the MuMIn documentation:

    fixed - optional, either a single-sided formula or a character vector giving names of terms to be included in all models.

    You need to put the names of the variables, enclosed in '', into a vector:

    Allmodels_Presence <- dredge(Gadiculus_Pres, rank=AIC, 
                                 fixed= c('s(depth, k=4)', 's(Lon_Proj, Lat_Proj, k=20)'), 
                                 trace=2)