This function defines the objective to minimize when fitting a parallelogram.
The objective is to find the smallest parallelogram that includes all points.
Non-finite or non-positive slopes are rejected because the parallelogram
diagnostic is only meaningful for ascending melatonin segments.
Usage
objective(params, x, y, y0, y1)
Arguments
- params
Numeric vector of optimization parameters: x0, x1, slope.
- x
Numeric vector of x-coordinates for data points.
- y
Numeric vector of y-coordinates for data points.
- y0
Numeric. The minimum y-value in the dataset.
- y1
Numeric. The maximum y-value in the dataset.
Value
The computed objective value (area plus penalties for constraint violations).