I am new to Julia, mostly work with R. I am looking for the equivalent of the “segmented” package in R, to fit a piecewise linear (constant in my special case) regression where the knot location is automated. Does this functionality exist in Julia?
Would EllZeroTrendFiltering.jl perhaps fit your bill? I do not think that this package fits the regression models for you, but it solves the most difficult problem, finding the optimal knot points by solving a dynamic-programming problem. With the knot points determined, it should be straightforward to use any of the standard packages for linear regression to fit the models.
Thank you @baggepinnen for a perfect warm welcome! That is super helpful, it got me thinking. I am concerned that the optimal knot locations that emerge for a piecewise constant function may be not be same as the knots for a piecewise linear function. I am wondering if the recursive problem in the piecewise constant case is identical to fitting a 1-D regression tree.
Related: If you first perform an ordinary regression which returns a function for evaluating your regression model, then the problem reduces to finding a piecewise linear approximation to that function. This thread contains several methods for performing adaptive piecewise linear interpolation of an arbitrary function to a user-specified error tolerance.
I have some code for doing linear regressions where the knots are also estimated - all coded up as a NLS/GMM problem. See section 12.2 of these notes (I could probably share the code, if wanted.)