This function enforces constraints on a parabolic fit for ascending melatonin concentration data. The constraints ensure that the fitted parabola passes through a specified point of interest (POI) and maintains a positive slope in the ascending segment.
Arguments
- params
A numeric vector of length 3 representing the parabola parameters:
a: Quadratic coefficient.b: Linear coefficient.c: Constant term.
- poi_x
Numeric. The x-coordinate of the point of interest (POI).
- poi_y
Numeric. The y-coordinate of the POI.
- x
Numeric vector of x-values representing the ascending segment.
Value
A list containing:
pass_poi: The squared deviation from the constraint that the parabola must pass through the POI.pos_grad: The squared deviation from the constraint ensuring a positive slope at the last ascending point.
Details
The function imposes two constraints:
Passing through POI: Ensures the fitted parabola satisfies \(y = ax^2 + bx + c\) at
poi_x, poi_y.Positive Slope: Ensures \(\frac{dy}{dx} = 2ax + b\) remains non-negative at the last x-value.
If the minimum slope at the last ascending point is negative, it is forced to zero as a penalty.
See also
objective_function, which utilizes these constraints during optimization.