I am trying to discretize a continuous variable that does not follow a linear relationship with our response variable. I am trying to find the optimal way to discretize this variable to better capture the nonlinear relationship. The method we are using right now is to cut the variable into numerous quantiles, then conducting t-tests between each neighboring group, and combining the most like neighbors until the highest p-value is below our significance level. Is there any more efficient or accurate way to conduct this process? Many of the discretization methods I have been able to find seem to refer to a binary response.