I have a ggm4 object produced by (for example) the following:
fit<-gamm4(formula=mass~s(hemato)+s(frass)+s(protos),random=~(1|nest)+(1|year),data=dat2)
If I extract the random formula from this object by specifying:
formula(fit$mer,random=T)
then it produces the following, which is also a formula object:
~(1 | Xr) + (1 | Xr.0) + (1 | Xr.1) + (1 | nest) + (1 | year)
I only want to extract the original random function that was specified in the call to gamm4 (i.e. ~(1|nest)+(1|year) while ignoring the parts of this formula that refer to to smoothing terms (i.e. (1 | Xr) etc.).
Context: This will be done repeatedly from inside another function in which fixed and random formulae will change.
Question: How can I do this?
I tried:
x<-formula(fit$mer,random=T)
y<-out[do.call(match,arg=list(x=x,table=c("1 | nest","1 | year")))]
but this doesn't work.