Dear R-users I would like to fit weibull parameters using "Method of moments" in order to provide the inital values of the parameter to de function 'fitdistr' . I don`t have much experience with maths and I don't know how to do it. Can anyone please put me in the rigth direction? Borja [[alternative HTML version deleted]]
On Wed, Oct 22, 2008 at 1:57 PM, Borja Soto Varela <borja.soto at gmail.com> wrote:> Dear R-users > > I would like to fit weibull parameters using "Method of moments" in order to > provide the inital values of the parameter to de function 'fitdistr' . I > don`t have much experience with maths and I don't know how to do it. > > Can anyone please put me in the rigth direction? > > Borja > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >Forget the method of moments here. Reasonable starting values are almost certainly to begin with an exponential model, i.e., give the starting values shape = 1 and scale = mean(X), if X is your data. This is the default behaviour of the functions phreg and aftreg in the package 'eha'. So if you don't like to have to supply starting values, use one of them. -- G?ran Brostr?m
> > I would like to fit weibull parameters using "Method of moments" in order to > provide the inital values of the parameter to de function 'fitdistr' . I > don`t have much experience with maths and I don't know how to do it. > > Can anyone please put me in the rigth direction? >A simple approach is to use survreg.> library(survival) > x <- rweibull(5000, shape=5, scale=pi)> fit <- survreg(Surv(x) ~ 1, dist='weibull') > summary(fit)Value Std. Error z p (Intercept) 1.14 0.0094 121.4 0 Log(scale) -1.61 0.0349 -46.1 0 Scale= 0.2 Weibull distribution Loglik(model)= -499.2 Loglik(intercept only)= -499.2 Number of Newton-Raphson Iterations: 7 n= 500> 1/fit$scale[1] 5.001574> exp(fit$coef)(Intercept) 3.131531 The survreg function imbeds the Weibull in a larger location-scale framework, leading to a different parameterization: 1/(rweibull "shape") = survreg "scale" log(rweibull "scale") = survreg intercept The results are the MLE, so you won't need to follow with fitdistr. Terry Therneau