This function fits a sine curve of the form \(y = \text{amp} \cdot \sin\left(\frac{2\pi}{\text{period}} \cdot (x + \text{phase})\right) + \text{offset}\) to time series data using Levenberg-Marquardt optimization from `minpack.lm::nls.lm`.
Usage
fit_sine_curve(
x,
y,
parStart = list(amp = 3, phase = 0, offset = 0, period = 24)
)
Value
A named list with:
- amp
Amplitude (peak distance from baseline).
- phase
Phase shift (horizontal time shift/ scanner rotation) in same units as `tt`.
- offset
Vertical shift (baseline).
- peak
Time position of the peak / scanner rotation position, relative to phase and period.
- period
Distance between peaks
- tss
Total sum of squares.
- rss
Residual sum of squares.
- R2
Coefficient of determination (pseudo R²).
- residual_se
Residual standard error.
- df_residual
Degrees of freedom of the residual.
- predicted
Fitted values.
- residuals
Model residuals.