Oscillating second derivative computed from gratia package #325
Replies: 1 comment 4 replies
-
In general there would be two suggestions:
But, the estimated smooth in your example is linear and thus has 0 second derivative everywhere. Te second derivative is the rate of change in the slope of the estimated smooth. As you smooth doesn't change slope anywhere because it is linear, there is no change in slope and hence the second derivative is 0. That the values are not exactly zero is likely just the loss of precision coming from the floating point arithmetic used by computers (and also the tiny value of |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there, I have a problem when applying gratia package's derivatives function for my analysis.
I am using only one simple smooth term called BIS(computed by integrating task accuracy and response time), which is a scale for behavioural measurement. And my dependent variable is brain activation value from a cortical area. So the gam is simply:
Brain activation value ~ s(BIS)
Please see the graph for the relationship between a specific brain area (R_V1 region) and BIS:
You can see the first derivative is basically positive, and it is indeed a constant when calculated by gratia's derivatives(), around 2.647:
But for the second derivative, I notice that the value start to oscillate around 0, which is very weird and hard to understand for me. I really hope someone could explain why this happens. Please see the chart for second derivative:
My code for calculating the first and second derivative looks something like this:
where the model_all is a gam model:
Thank you so much for your attention on this post!
Beta Was this translation helpful? Give feedback.
All reactions