My model:
gam(response ~ s(days, k=9) + s(days, by=subject, k=9, m=1) + covariates.
I used this approach https://stackoverflow.com/questions/78182559/autocorrelation-in-gam-r to extract out the subject specific residuals and plot an acf and pacf plot per subject. I noticed for certain subjects that an AR=1 might be useful based on the PACF plots, but this isn't the case for all subjects. How would I go about adjusting for this for only certain subjects? I wasn't sure. Happy to be redirected to another resource. Thank you

y ~ subject + s(days, by = subject)? Them = 1bit is often a source of problems; if you want to keep the GI decomposition, you can use a newer basis “sz”;y ~ s(days) + s(days, subject, bs = "sz"), which avoids them = 1thing because it is designed to be orthogonal to the average smooth. $\endgroup$