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.