I'm working with a dataset of 56 samples, so I am trying to keep the complexity of the regression model down. However, I have rather complex non linear relationships between some of the predictors and variables. I also have spatial autocorrelation in the model residuals. Thus, I'm using gamm
with a spatial correlation structure . I use this formula:
gamm(y ~ s(x, k=-1), correlation=corSpher(form=~x+y), data=d)
Estimated degrees of freedom is total=7.98. The residual plot looks ok with this model (fig1). However, if I constrain k to a smaller number (k=7), the residual plot looks messed up (fig2). See plots below.
I'm thinking that constraining the number of knots to a lower number, is not a good idea because of the residuals. But isn't it also problematic to have a high number of knots, when the sample size is rather small? Does anyone have any advice on how to deal with this?