sinreg {ShellChron} | R Documentation |
Function that carries out a sinusoidal regression
Description
Fits a sinusoid through data provided as an x
and y
vector and returns a list containing both the fitted curve and the
parameters of that curve.
Used to produce initial values for modeling data windows and later
to find peaks in modeled julian day values to align the result to
a cumulative age timeline.
Usage
sinreg(x, y, fixed_period = NA, plot = FALSE)
Arguments
x |
Vector of |
y |
Vector of |
fixed_period |
Optional variable for fixing the period of the sinusoid
in the depth domain. Defaults to |
plot |
Should the fitting result be plotted? |
Value
A list containing a vector of parameters of the fitted sinusoid
and the fitted values belonging to each x
value.
Fitting parameters:
I
= the mean annual value of the sinusoid (height)
A
= the amplitude of the sinusoid
Dper
= the period of the sinusoid in x
domain
peak
= the location of the peak in the sinusoid
R2adj
= the adjusted R^2
value of the fit
p
= the p-value of the fit
Examples
# Create dummy data
x <- seq(1000, 11000, 1000)
y <- sin((2 * pi * (seq(1, 11, 1) - 8 + 7 / 4)) / 7)
sinlist <- sinreg(x, y, plot = FALSE) # Run the function