Using derivatives with random smooths by individual #242
-
Hello, I have been trying to get the first derivatives for each individual fit from the following model: gam.smooth <- gam(TV ~ groupID + 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. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
I will take a closer look later, but initial thoughts are that you need |
Beta Was this translation helpful? Give feedback.
-
I'll also add that I doubt the derivative will be that informative if you set |
Beta Was this translation helpful? Give feedback.
-
Thank you for your answer! fdSmooth <- derivatives(gam.smooth, n = 1000, term = "s(time, animalID)", partial_match = TRUE) |
Beta Was this translation helpful? Give feedback.
-
I have just noticed that if I remove the space between time and animalID, I get a different error message: derivatives(gam.smooth, n = 1000, term = "s(time,animalID)", partial_match = TRUE) |
Beta Was this translation helpful? Give feedback.
-
I can't reproduce the issue with an example that is similar to the one you describe: see the example I posted in #243 I may have inadvertently fixed this. I'm going to close #243 now. If your problem persists with the CRAN version of gratia, please follow up here or in #243, but I'm going to need a reproducible example I think. |
Beta Was this translation helpful? Give feedback.
I can't reproduce the issue with an example that is similar to the one you describe: see the example I posted in #243
I may have inadvertently fixed this. I'm going to close #243 now. If your problem persists with the CRAN version of gratia, please follow up here or in #243, but I'm going to need a reproducible example I think.