# NOT RUN {
library(ggtrendline)
x<-1:5
y<-c(2,4,8,20,25)
xy<-data.frame(x,y)
getInitial(y ~ SSpower2P(x,a,b), data = xy)
## Initial values are in fact the converged values
fitpower2P <- nls(y~SSpower2P(x,a,b), data=xy)
summary(fitpower2P)
prediction <- predFit(fitpower2P , data.frame(x=x), se.fit = TRUE,
level = 0.95, interval = "confidence")
yfitpower2P <- prediction$fit
yfitpower2P # output a matrix of predictions and bounds with column names fit, lwr, and upr.
# }
Run the code above in your browser using DataLab