[R] quadratic model with plateau
Gabor Grothendieck
ggrothendieck at gmail.com
Sat Apr 7 21:58:54 CEST 2012
On Fri, Apr 6, 2012 at 9:42 PM, help ly <help.ly2005 at gmail.com> wrote:
> Dear All,
>
> I would like to make a quadratic with a plateau model in R. Is there a
> package in R doing this? The bentcableAR package seems won't work.
>
> The link below describes what I am looking for in R exactly:
> http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_nlin_sect033.htm
>
Use nls directly:
y <- c(0.46, 0.47, 0.57, 0.61, 0.62, 0.68, 0.69, 0.78, 0.7, 0.74,
0.77, 0.78, 0.74, 0.8, 0.8, 0.78)
x <- seq_along(x)
Mean <- function(x, alpha, beta, gamma) {
pmin(alpha + beta*x + gamma*x*x, alpha - beta^2/(4 * gamma))
}
fm <- nls(y ~ Mean(x, alpha, beta, gamma), start = list(alpha = 0.45,
beta = 0.05, gamma = -0.0025))
fm
summary(fm)
plot(y ~ x)
lines(fitted(fm) ~ x)
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
More information about the R-help
mailing list