Fits a bent-cable model to the given data by exhaustively searching
the 2-dimensional parameter space to find the maximum likelihood
estimators for α and γ.
Usage
bent.cable(x, y, grid.size=100)
Arguments
x
The independent variable
y
The dependent variable
grid.size
How many α and gamma values to examine. The total number of
parameter combinations examined is grid.size squared.
Details
Fit the model which is essentially a piecewise linear model with a quadratic curve of length 2γ
connecting the two linear pieces.
The reason for searching the space exhaustively is because the bent-cable model often has a likelihood surface with a very
flat ridge instead of definite peak. While the exhaustive search is slow, at least it is possible to examine the contour plot
of the likelihood surface.
Value
A list of 7 elements:
log.likelihood
A matrix of log-likelihood values.
SSE
A matrix of sum-of-square-error values.
alphas
A vector of alpha values examined.
gammas
A vector of gamma values examined.
alpha
The MLE estimate of alpha.
gamma
The MLE estimate of gamma.
model
The lm fit after alpha and gamma are known.
Author(s)
Derek Sonderegger
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
piecewise.linear
Examples
data(Arkansas)
x <- Arkansas$year
y <- Arkansas$sqrt.mayflies
# For a more accurate estimate, increase grid.size
model <- bent.cable(x,y, grid.size=20)
plot(x,y)
x.grid <- seq(min(x), max(x), length=200)
lines(x.grid, predict(model, x.grid), col='red')
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(SiZer)
Loading required package: splines
Loading required package: boot
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/SiZer/bent.cable.Rd_%03d_medium.png", width=480, height=480)
> ### Name: bent.cable
> ### Title: Fits a bent-cable model to the given data
> ### Aliases: bent.cable logLik.bent_cable predict.bent_cable
> ### Keywords: regression
>
> ### ** Examples
>
> data(Arkansas)
> x <- Arkansas$year
> y <- Arkansas$sqrt.mayflies
>
> # For a more accurate estimate, increase grid.size
> model <- bent.cable(x,y, grid.size=20)
> plot(x,y)
> x.grid <- seq(min(x), max(x), length=200)
> lines(x.grid, predict(model, x.grid), col='red')
>
>
>
>
>
> dev.off()
null device
1
>