Originally posted by **TSeuH** December 6, 2023
Hello,
I have been trying to get the first derivatives for each individual fit from the following model:
gam.smooth <- gam(TV ~ groupID +
s(time, by = groupID) +
s(time, animalID, bs = "fs", m = 1),
data = dataTV, method = "REML")
fdSmooth <- derivatives(gam.smooth, n = 1000, term = "s(time)", partial_match = TRUE)
I see a column "fs_var" in fdSmooth, and I was assuming it would contain "animalID", just like by_var contains "groupID". I thought I could get the first derivative for each animalID, but with this code, I only get the first derivative for each groupID, regardless of the animalID.
Would it be possible to have the derivatives by animalID without changing the GAM?
Thank you.
Discussed in https://github.com/gavinsimpson/gratia/discussions/242