I want to model the rate of change of Y as (ΔY=Yt-Yt-1) as a function of x1, x2. For that I'm using a GAM model with an interaction as following:
mod <- gam (ΔY~te(x2,log(x1+1)), data=mydata)
I'm interested in particular in the interaction term, so in principle I am not planning to use the model in a predictive way. The plots for the interaction term look relatively fine, in terms of the patterns that I expected. However, when looking in more detail the summary and the predicted values, I realised that the fitted values are far from the observed values..and also the R-sq. are very low (0.022), so I'm concern that my model is not working well, (even if the my expectation on how the interaction term is OK, which is my main focus for now.)
The gam.check looks as follows:
and a small sample for the fitted(blue) and observed values (black line):
My main concern and question is, is this model with the lag variable in the dependent term correct? even obtained such a low R-adj? Can I justify that the interaction term is OK ? I've work already with lagged variables in linear regression, but always as a predictor term..but now I want to model ΔY, and with a non-linear interaction.
Also, another small question I have, I'm using vis.gam to look at the interaction term as: vis.gam(mod, view=c("x1","x2"), plot.type="contour", color="terrain") but since I used log(x2+1), the option "too.far" is not working... I guess I should modify myself the function to exclude those parts, right? or work with a variable log(x2+1)??
I'd appreciate if anyone can give some advice here.
Thanks in advance,


family = scat()option works better for these data. That said, because you have differences the response you've removed a lot of the structure in it (differencing is used to detrend time series for example) and kind of centred the variable, so, perhaps there's nothing much for the GAM to work with other than spread around 0, which is variance. – Gavin Simpson Jan 16 '20 at 15:33