I want to fit the following data to a Weibull distribution multiplied by a.
datos: enter link description here
y=b1*(1-exp(-(x/b2)^b3)
However, I could not find a solution using the nls function in R. Could someone guide me down the path to follow in order to find a solution?
The code used is the following:
ajuste_cg<-nls(y~b1*(-exp(-((x/b2)^b3))),data=d,start=list(b1=1000,b2=140,b3=20), trace=T,control = list(maxiter=10000000))
Thanks!
I suggest you to use the package survival
. It is made for implementing parametric survival regressions (Weibull models included, of course). Here's the code:
library(survival)
weibull_model = survreg(Surv(time, event) ~ expalatory_variables, dist="weibull")
The Surv()
object that you see instead of a y
is an R "survival object", and works like your dependent variable in a survival regression. The time
and event
variables must represent duration and event occurrence (0 or 1), respectively. Please replace explanatory_variables
with your appropriate set of variables.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.