SSlinp | R Documentation |
Self starter for linear-plateau function with parameters a (intercept), b (slope), xs (break-point)
linp(x, a, b, xs)
SSlinp(x, a, b, xs)
x |
input vector |
a |
the intercept |
b |
the slope |
xs |
break-point of transition between linear and plateau |
This function is linear when x < xs: (a + b * x)
and flat (asymptote = a + b * xs
) when x >= xs
.
a numeric vector of the same length as x containing parameter estimates for equation specified
linp: vector of the same length as x using the linear-plateau function
package segmented.
require(ggplot2)
set.seed(123)
x <- 1:30
y <- linp(x, 0, 1, 20) + rnorm(30, 0, 0.5)
dat <- data.frame(x = x, y = y)
fit <- nls(y ~ SSlinp(x, a, b, xs), 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.