glm - Prediction of Exponential Decay or Logistic Growth in R -
i'm trying predict in r, , i'm not sure syntax should use. know that, polynomial, can do:
predict(glm(y ~ x +i(x^2) + i(x^3) +... i(x^n),data=mydata))
which have been successful with, wondering how predict equations of form
y = c(1-e^(-kx))
or
y = a/(1 + b*e^(-kx)), k>0
i'm not sure example data can give illustrate well...
an example:
set.seed(1234) # parameters simulated data c<-1 k<-2 # set x values , compute y them x<-seq(-100,120,1)/100 y<-c*(1-exp(-k*x))+rnorm(length(x),sd=0.1) # plot points plot(x,y); grid() # fit fit<-nls(y ~ c*(1-exp(-k*x)), data=data.frame(y,x), start=list(c=5,k=5)) # plot fit lines(x, predict(fit, list=(x=x)), col="red")
> fit nonlinear regression model model: y ~ c * (1 - exp(-k * x)) data: data.frame(y, x) c k 1.022 1.987 residual sum-of-squares: 2.147 number of iterations convergence: 8 achieved convergence tolerance: 1.338e-07
Comments
Post a Comment