0

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!

EBT
  • 17
  • 4
  • it's not clear what you're trying to do. Are you in fact trying to fit a nonlinear time series model (i.e. x is time, y is the amount of something)? It doesn't seem to make much sense to fit a Weibull, and your formula isn't really a Weibull. Also, the formula that you have gives *negative* values for the starting parameters you suggest. Can you give some more context please? How did you choose the starting values? – Ben Bolker Nov 29 '18 at 20:19

1 Answers1

0

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.

Leevo
  • 1,683
  • 2
  • 17
  • 34