# Choosing the right regression

I'm trying to analyze my sleep using regression analysis. Each night is rated (dependent variable). I'm trying to explain this rating with, for example, my sleep duration and each night's bed time's deviation from a moving average of bed times over n periods (independent variables).

The maximum rating I can give is 5. From a logical point of view, a longer sleep duration does not necessarily result in a higher sleep rating (=> better sleep) so I assume that there's a bell shaped kind of curve with the peak being the ideal sleep duration everything else held equal.

My understanding of a linear regression is that "more is better" and that a polynomial regression gives me a formula that maps this bell shaped curve more accurately. Is that correct?

If so, I'm guessing that I need to run a polynomial regression. Since I've got more than one independent variable, I need a multivariate polynomial regression. My understanding of this is that a polynomial regression takes only one independent variable. Is my understanding correct? What's the best way to go about this and how would others approach this problem? How do I restrict the dependent variable to a value [0..5] in the resulting regression formula?

Per request, here's a sample set of my data:

**Rating    *Sleep duration *Bed time dev.  *Wake up time dev.
3,5         7,033333333     0               0
2           5,533333333     -0,021527778    -0,516666667
1,5         5               -0,044907407    -1,077777778
1           6,9             0,016319444     0,391666667
2,5         8,966666667     0,843055556     1,033333333
3           7,516666667     -0,057291667    2,625
2,5         8,033333333     -0,062797619    1,921428571

• Linear regression is, as an example, F = a + b X + c Y + d Z in which F is the dependent variables and X, Y, Z .. are the independent variables, whatever they are. Could you post data of your own ? Nov 1, 2013 at 14:46
• @ClaudeLeibovici I've added a sample set. Nov 1, 2013 at 15:03
• If you are interested in fitting to a function of the form, $y=ax^r$, you can take a logarithm of the data and try to fit it to a linear regression since $\ln y=\ln a+r\ln x$. Nov 1, 2013 at 15:31
• I wonder if regression would be of any help. Just look at the values of the second variable : it is almost zero except for one point. As far as I know, there are parts of statistics which use qualitative data instead of quantitative. But this is really not my area. Sorry for that ! Have good nights ! Nov 1, 2013 at 15:42
• "More is better" is a mistake at best. By adding a large number of irrelevant predictors, one can obtain a perfect fit. Google the term "overfitting". If you take the residuals from regression of $y$ on $x$, and regress those one $(x-\bar x)^2$, where $\bar x$ is the mean observed $x$ value, then a Student's $t$-test might tell you whether the quadratic term should be included. However, I think the posted answer involving ordinal logit regression might be a better thing to do. Nov 1, 2013 at 16:37

Since a subjective rating usually does not have cardinal meaning, but rather an ordinal meaning (higher score is better, but the difference $3-2$ is not necessarily equal to the difference $2-1$), I would recommend using Ordinal Logit instead of linear regression. With either model you can use a, say, second degree polynomial of your sleep duration as explanatory variable, along with bed time deviation (and probably also autoregressive terms, i.e., how much you slept the night before to control for "tiredness").
Try something like $$\text{Rating}_t=f(\alpha+\beta_1 \text{Duration}_t+\beta_2 \text{Duration}_t^2+\beta_3 \text{Duration}_{t-1}+\gamma \mathbf{X}),$$ where $f$ is the ordinal logit function (appropriate statistics programs have this pre-programmed), $\beta_3$ is the effect of previous night's sleep duration and $X$ is a vector of other explanatory variables. In particular, you can also try and include Rating$_{t-1}$ (but then exclude Duration$_{t-i}$, since it is collinear with it). I would expect sleep to be better after a night with bad sleep.