Say I am tracking my sleep for 1 week and these are the number of hours I sleep each night:

(5, 6, 9, 4, 8, 9, 6)

everyday that I track my sleep I am also taking a test that measures how well my brain is working these were my scores:

(45, 23, 33, 48, 68, 19, 26)

The higher the score the better.

Given these numbers, I would like to find out the optimal number of hours I would have to sleep to score the highest on this test. For example, the answer could be X amount of hours would give me the best chance of scoring highest on this test. I would like to know how to find X.

Any help that points me in the right direction would be incredibly appreciated!


Now, I am assuming you just pulled those numbers out of a hat, because when I plotted them, I saw absolutely NO relationship between them.

Theoretically, you will first need to have an idea of the underlying model, or a reasonably accurate approximation. For example, a quadratic model for the mean test score might be useful since it can accommodate linear (no limits to the benefit of sleep) and non-linear (diminishing or negative effects of too much sleep).

Then you will need to determine the form of the variability. I doubt normality will hold, so you may want to examine the residuals for a least squares fit to give you some ideas, then use a generalized linear model with the proper mean-variance relationship and a strictly positive range.

The alternative is to use a non-parametric regression...which is a vast field of techniques.

  • $\begingroup$ Thanks for this answer, I am going to try to apply it and I will get back to you. $\endgroup$ – ahat91 Oct 3 '14 at 14:09
  • $\begingroup$ I am having difficulty, I realize this is a lot to ask for but is there anyway you can show me an actual example using similar numbers to the ones above? I am creating a mobile application and finding the answer to this question is a cornerstone to my app. This would be greatly appreciated! I'd love to talk with you more if you have any further questions. $\endgroup$ – ahat91 Oct 3 '14 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.