# At which hour of sleep, additional hour will have a negative impact on test score (curvilinear relationship)

Let's assume that there is a curvilinear relationship between test score and number of sleep hours. According to the simple example below, starting from 8 hours, test score goes down. I can see it from data. But, how can I calculate it? how can I calculate that at which point, no. of sleep hour will have negative impact on text score?

Score   **Hr of sleep**
1.20    **1**
3.30    **2**
6.00    **3**
7.00    **4**
12.00   **5**
18.00   **6**
18.00   **7**
16.00   **8**
8.00    **9**
6.00    **10**

• I apologize in advance if I've missed something here and therefore what I'm about to say sounds really stupid :) But, is there a reason you couldn't simply take the first difference of the test score data and locate where it crosses zero (and becomes negative)? If, as Appolonia mentioned, your x-values are discrete and we're assuming that the plot of this data is monotonic, so that there is only one maximum, wouldn't this work as well?
– user56556
Sep 27, 2014 at 23:14

If your "hours of sleep" is discrete and you have a sufficient number of observations, I would create a series of dummy variables "at least x hours of sleep" (maybe group them at the bottom "less than four hours" , more than four hours, more than five hours, more than six hours etc. Then do a regular linear regression with test score as the dependent and the dummys as explanatory variables and finally plot the betas. (Alternatively, if you use Stata like I do, do a regression then check out margins and marginsplot)  Score Hr of sleep more4hours more5hours more6hours etc 1.20 1 0 0 0 3.30 2 0 0 0 6.00 3 0 0 0 7.00 4 0 0 0 12.00 5 1 0 0 18.00 6 1 1 0 18.00 7 1 1 1 16.00 8 1 1 1 8.00 9 1 1 1 6.00 10 1 1 1