SSplin | R Documentation |
Self starter for plateau-linear function with parameters a (plateau), xs (break-point), b (slope)
plin(x, a, xs, b)
SSplin(x, a, xs, b)
x |
input vector |
a |
the initial plateau |
xs |
break-point of transition between plateau and linear |
b |
the slope |
Initial plateau with a second linear phase. When x < xs: y = a
and when x >= xs: y = a + b * (x - xs)
.
a numeric vector of the same length as x containing parameter estimates for equation specified
plin: vector of the same length as x using the plateau-linear function
require(ggplot2)
set.seed(123)
x <- 1:30
y <- plin(x, 10, 20, 1) + rnorm(30, 0, 0.5)
dat <- data.frame(x = x, y = y)
fit <- nls(y ~ SSplin(x, a, xs, b), data = dat)
## plot
ggplot(data = dat, aes(x = x, y = y)) +
geom_point() +
geom_line(aes(y = fitted(fit)))
## Confidence intervals
confint(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.