1
$\begingroup$

I am looking for a way to find the maximum in a quadratic regression. Specifically, I have two variables X and Y. Y is a discrete and commonly used scale representing the severity of a disease, ranging from 0 to 20 and X is a biological parameter. Since I expect the relationship between X and Y to take on an inverted u-shape, I want to find out at what level of disease severity X is greatest (e.g., let's say the maximum of X lies at Y = 13, then we can expect X to increase and then decrease before and after a disease severity of 13). I would also like to find out the predicted value of X and get a confidence interval for X. Since I have unbalanced multi-panel data, I am looking for an approach using the nlme or lme4 packages.

Any ideas?

edit

I found the "two-line test" (Simonsohn, 2016), which fits a segmented regression based on a breakpoint (i.e. the maximum in quadratic regression) identified with a particular algorithm. However, the procedure does not account for random variance.

$\endgroup$
2
  • $\begingroup$ "the maximum of X lies at Y = 13, then we can expect X to increase and then decrease before and after a disease severity of 13" I think you've got X and Y the wrong way round. If not, then I don't understand your question. $\endgroup$
    – Nick Cox
    Commented Aug 9 at 15:57
  • 2
    $\begingroup$ A similar question Confidence interval for GLM or the maximum of a function? $\endgroup$ Commented Aug 10 at 1:22

1 Answer 1

1
$\begingroup$

If you've fitted $$\hat y = b_0 + b_1 x + b_2 x^2$$ then the gradient of that quadratic curve vanishes when $$d\hat y / dx = b_1 + 2 b_2 x = 0$$ whence at that turning point $$x = -b_1 / 2 b_2,$$ which you can calculate simply from your parameter estimates.

Naturally you should always check that

a. the model is a good idea -- by plotting the data and the fitted curve together and judging the suitability of a quadratic

b. the turning point is indeed a minimum

and

c. the turning point occurs within the data range or at least is a plausible value of $x$.

It's unclear to me why or how having unbalanced multi-panel data complicates the question, unless

  1. Lack of balance and/or other heterogeneity makes a single model moot

  2. You really fitted a more complicated model, in which case there isn't likely to be a simple minimum but at best the minimum is a set of points on some more complicated prediction surface. In fact, your mention of those R packages is worrying insofar as it implies that you did that.

Detail: Statistically speaking $x$ is here a variable, and not a parameter, the last term being better reserved for the quantities $\beta_0, \beta_1, \beta_2$ of which $b_0, b_1, b_2$ are estimates.

$\endgroup$
6
  • 2
    $\begingroup$ To avoid the problems with estimating the standard error of $-\hat b_1/(2\hat b_2),$ I suggest analyzing the question of testing the contrast $2(x-x^*)\hat b_2 + \hat b_1$ where $x^*$ is the estimated peak location and $x$ is any other location. Intuitively, values of $x$ for which this test does not reject the null hypothesis are consistent with being a possible peak location, thereby producing fiducial limits for $x^*.$ This is sometimes known as inverse regression., q.v. $\endgroup$
    – whuber
    Commented Aug 9 at 16:06
  • $\begingroup$ Thanks for your answer, @Nick Cox. Regarding the multi-panel nature, the dataset contains data from patients and some of them were tested over multiple years. I wanted to do something as an LMM to incorporate random effects (and possibly covariates). How could I statistically test the maximum of x? $\endgroup$ Commented Aug 9 at 16:27
  • $\begingroup$ also thanks for your comment, @whuber . $\endgroup$ Commented Aug 9 at 16:28
  • 1
    $\begingroup$ Your question about testing can't be answered well without an explicit mention of whatever model you fitted. Indeed what is X and what is Y still seems confused to me. $\endgroup$
    – Nick Cox
    Commented Aug 9 at 16:33
  • $\begingroup$ I am thinking of a model such as lmer(Y ~ X + I (X^2) + random(1 | patient)) , @NickCox. Y is expected to decrease linearly (disease severity will only get worse over time), while X, the biological variable, will increase as the disease worsens, but will decrease after a certain disease stage is passed. $\endgroup$ Commented Aug 9 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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