piecewise.linear {SiZer} | R Documentation |
Fit a degree 1 spline with 1 knot point where the location of the knot point is unknown.
piecewise.linear(x, y, middle = 1, CI = FALSE, bootstrap.samples = 1000, sig.level = 0.05)
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. |
bootstrap.samples |
The number of bootstrap samples to take. |
sig.level |
What significance level to use for the confidence intervals. |
The bootstrap samples are taken by resampling the raw data points. Often a more appropriate bootstrap sample would be to calculate the residuals and then add a randomly selected residual to each y-value.
A list of 5 elements is returned:
change.point |
The estimate of α. |
model |
The resulting lm object once α 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. |
...
Derek Sonderegger
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.
~~objects to See Also as help
, ~~~
data(Arkansas) x <- Arkansas$year y <- Arkansas$sqrt.mayflies model <- piecewise.linear(x,y, CI=FALSE) plot(model) print(model) predict(model, 2001)