piecewise.linear: Creates a piecewise linear model
Description
Fit a degree 1 spline with 1 knot point where the location of the
knot point is unknown.
Usage
piecewise.linear(
x,
y,
middle = 1,
CI = FALSE,
bootstrap.samples = 1000,
sig.level = 0.05
)
Value
A list of 5 elements is returned:
change.point
The estimate of \(\alpha\).
model
The resulting lm object once \(\alpha\) is known.
x
The x-values used.
y
The y-values used.
CI
Whether or not the confidence interval was calculated.
intervals
If the CIs where calculated, this is a matrix of the
upper and lower intervals.
Arguments
x
Vector of data for the x-axis.
y
Vector of data for the y-axis
middle
A scalar in \([0,1]\). This represents the range that the change-point
can occur in. \(0\) means the change-point must occur at the middle of the range of
x-values. \(1\) means that the change-point can occur anywhere along the range of the
x-values.
CI
Whether or not a bootstrap confidence interval should be calculated. Defaults to
FALSE because the interval takes a non-trivial amount of time to calculate
bootstrap.samples
The number of bootstrap samples to take when calculating the CI.
sig.level
What significance level to use for the confidence intervals.
Details
The bootstrap samples are taken by resampling the raw data points.
Sometimes a more appropriate bootstrap sample would be to calculate the residuals and
then add a randomly selected residual to each y-value.
References
Chiu, G. S., R. Lockhart, and R. Routledge. 2006. Bent-cable regression
theory and applications. Journal of the American Statistical Association
101:542-553.
Toms, J. D., and M. L. Lesperance. 2003. Piecewise regression: a tool for
identifying ecological thresholds. Ecology 84:2034-2041.
See Also
The package segmented has a much more general implementation
of this analysis and users should preferentially use that package.