This function determines the inflection point in a melatonin profile by calling
seek_inflection(), which performs a grid search over a region of interest (ROI).
Usage
get_inflection(
profile_data,
threshold = 2.3,
posix_roi,
fit_type = "linear",
fine_flag = TRUE
)Arguments
- profile_data
A tibble containing melatonin profile data with columns:
datetime(POSIXct): The timestamp of each measurement.melatonin(numeric): The melatonin concentration.base(binary): Indicator for the baseline segment.ascending(binary): Indicator for the ascending segment.intermediate(optional, binary): Indicator for an intermediate segment.
- threshold
Numeric. The threshold value for constraining the fit (default = 2.3).
- posix_roi
A list defining the region of interest (ROI) using POSIXct timestamps:
x_start: Start time of the ROI.x_end: End time of the ROI.y_min: Minimum melatonin concentration in the ROI.y_max: Maximum melatonin concentration in the ROI.
- fit_type
Character. Specifies the type of fit used:
"linear"(default): Uses a linear model."parabolic": Uses a parabolic model for the ascending segment.
- fine_flag
Logical. If
TRUE, enables fine-grid refinement inseek_inflection()(default =TRUE).
Value
A list containing:
inflection_point: The estimated inflection point (x,y).base_params: Parameters of the base segment fit.ascending_params: Parameters of the ascending segment fit.grid_big: The coarse grid used in the first search.res_big: The residuals corresponding togrid_big.grid_small: The fine grid used in the second search (iffine_flag = TRUE).res_small: The residuals corresponding togrid_small(iffine_flag = TRUE).
Details
The ROI is converted from POSIXct format to decimal time using
posixct_to_decimal().If the
profile_datacontains an"intermediate"segment, it is included in the fit.Calls
seek_inflection()to identify the best-fit inflection point.