1
$\begingroup$

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

PACF plot for subject 19

$\endgroup$
1
  • $\begingroup$ Nick’s answer is the route I would probably go, but does the same issue persist if you eschew the GI decomposition and just fit y ~ subject + s(days, by = subject)? The m = 1 bit 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 the m = 1 thing because it is designed to be orthogonal to the average smooth. $\endgroup$ Commented Apr 9 at 7:55

1 Answer 1

2
$\begingroup$

You can't allow different levels to have different residual autocorrelation structures in most regression interfaces, including gam() or bam(). Rather, I would recommend you look into the {mvgam} 📦 to do this. It can handle many of the predictor features and terms that gam() can, but it can incorporate far more flexible time series options to model the latent residuals.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.