I have been trying to develop a GAM to predict future subsidence from previous subsidence data. I am new to GAM and have based my code on [this].1 The data looks like this:
Longitude Latitude Time Subsidence YEAR month
81 76.29542 10.05154 2015-10-12 0.02640557 2015 10
82 76.29615 10.05154 2015-10-12 0.02955222 2015 10
83 76.29688 10.05154 2015-10-12 0.02672001 2015 10
84 76.29761 10.05154 2015-10-12 0.02426790 2015 10
221 76.29396 10.05081 2015-10-12 0.02521223 2015 10
222 76.29469 10.05081 2015-10-12 0.02637761 2015 10
These have been extracted from rasters if that is relevant. Also, the time series is not regular. Measurements have been taken at unequal periods.
I used the following code:
library(mgcv)
knots <- list(month = c(0.5, 12.5))
M <- list(c(1, 0.5), NA)
m_test2 <- bam(Subsidence ~
s(month, k = 9, bs = "cc") +
YEAR +
s(Longitude, Latitude, k = 500, bs = "ds", m = c(1, 1)) +
ti(month, YEAR, bs = c("cc", "tp"), k = c(6, 5)) +
ti(Longitude, Latitude, month, d = c(2, 1), bs = c("ds", "cc"), m = M, k = c(125, 6)) +
ti(Longitude, Latitude, YEAR, d = c(2, 1), bs = c("ds", "tp"), m = M, k = c(125, 5)), data = train.data, method = 'fREML',nthreads = 4, discrete = TRUE)
The results were significant:
Parametric coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -44.800334 1.817401 -24.65 <2e-16 ***
YEAR 0.022156 0.000899 24.64 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Approximate significance of smooth terms:
edf Ref.df F p-value
s(month) 6.368 7 8051.95 <2e-16 ***
s(Longitude,Latitude) 483.440 499 272.70 <2e-16 ***
ti(YEAR,month) 10.632 11 142633.62 <2e-16 ***
ti(month,Longitude,Latitude) 289.637 496 25.11 <2e-16 ***
ti(YEAR,Longitude,Latitude) 418.624 496 170.17 <2e-16 ***
Signif. codes: 0 ‘*’ 0.001 ‘’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
R-sq.(adj) = 0.949 Deviance explained = 94.9%
fREML = -7.734e+05 Scale est. = 0.00015087 n = 260248
However the gam.check() plots showed this:

The predictions are also way off. I have changed the k values multiple times and removed outliers, but this has remained the same. This is my first time doing a GAM and I don't know how to proceed.