0

I am trying to run gamm models with multiple variable combinations in dredge (MuMIn) framework, with a cutoff based TRUE/FALSE correlation matrix as subset.

Problem is, my full model is quite complex with random effects, >20 predictor variables including 3 fixed effects, and therefore won't converge. My predictors are highly correlated, as mentioned I included a TRUE/FALSE correlation matrix as subset. Due a low correlation cutoff I expect very few combinations and not really interested in the full model.

However, my construction of gamm (or uGamm) full model, which includes 20+ predictors (smoothed terms and fixed effects, random effects) does not converge. This essentially means that dredge won't run since the full model doesn't converge, even though I am not interested in the full model per se, rather in the single models and a few combinations.

It also appears that I cant use fm1 <- gamm(y ~ (.), data = Cement) option, as this gives the following error:

Error in s(.) : s(.) not yet supported

Is there a way to bypass the full model which will not converge and have my variable combinations regardless? and/Or is there a way to avoid the above error with (.)?

Any suggestions? my data is too large to include here.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Joe
  • 347
  • 5
  • 20

1 Answers1

3

You can trick dredge by replacing the formula in a simpler model, and then use that model as a "global model". Assign the full model formula to <gam.model> $ gam $ formula. For example:

# fit some simple model
fm <- uGamm(y ~ s(x1), ...) # add other arguments as in the proper full model
fm$gam$formula <- y ~ x0 + s(x1) + s(x2) + ... + s(xn)
dredge(fm) 
Kamil Bartoń
  • 1,482
  • 9
  • 10
  • how would you trick dredge r rather code this..assuming the full model is "fmgs1 <- gamm4(y ~ x0+ s(x1) + s(x2) + s(x3)...s(xn), family = poisson, + data = dat, random = ~(1 | fac))" – Joe Feb 26 '15 at 23:11
  • I actually used 'fmgs1 <- uGamm(y ~ x0, ...)' and this model wont converge, hence my original question on whether there is a way around this – Joe Feb 27 '15 at 12:53
  • You have to find some formulation that converges. Otherwise, if none of your subset models converge, the whole procedure doesn't make sense. – Kamil Bartoń Feb 27 '15 at 12:56
  • I first fit the simple model as you suggested 'fm <- uGamm(y ~ x0 + s(x1), family = poisson, data = dat, random = ~(1 | fac), ...)' , second I fit the full model with 'fm$gam$formula' as the prefix, obviously it failed to converge. dredge(fm) returned outputs for only the simple model..it wasnt tricked afterall – Joe Feb 27 '15 at 13:10
  • yes indeed the simple model did converge...I meant the full model didnt converge..and after following your instructions as I have described above, dredge returns outputs for the simple model :( – Joe Feb 27 '15 at 13:21
  • seems to be running..i didnt follow your instructions correctly. the second bit..fm$gam$formula..shouldnt include 'other model arguments'. Do you reckon subsets arguments in dredge will work fine in this trick? – Joe Feb 27 '15 at 13:40
  • The global model terms in `"gamm"` are taken from the `gam$formula` element, so once you have replaced it, `dredge` should work as if it was a valid model. – Kamil Bartoń Feb 27 '15 at 14:28
  • dredge model appears to be running fine but it has been now running for the last 10 hrs and still going! yet I have only 25 variables and I have set my m.max= 2, including a subset option. I suspect there is a problem – Joe Feb 28 '15 at 04:15
  • You can check whether the generated model calls are correct by setting arguments `evaluate=FALSE` or `trace=TRUE`. – Kamil Bartoń Feb 28 '15 at 10:55
  • Works fine now. I want to save the object returned by dredge and be able to read it in later,,is there such a functionality? couldn't find anythng in the documentation.. – Joe Mar 01 '15 at 11:08