
21 Fev
2012
21 Fev
'12
16:30
Vanúcia, Neste caso, creio que a mensagem de aviso (que não é de erro) pode ser relevada. Veja o exemplo abaixo: x<-rweibull(1e3,1,1) ll<-function(th,x){ sh<-th[1]; sc<-th[2] l<-dweibull(x,sh,sc,log=T) -sum(l) } # Valores iniciais -- função 'fitdistr' lx <- log(x) m <- mean(lx) v <- var(lx) shape <- 1.2/sqrt(v) scale <- exp(m + 0.572/shape) ini<-c(shape,scale) # Limites dos parâmetros inf<-rep(1e-3,2) sup<-rep(Inf,2) fit<-optim(ini,ll,method="L-BFGS-B",lower=inf,upper=sup,hessian=T,x=x) fit$par # Estimativa sqrt(diag(solve(fit$hessian))) # Erro padrão library(MASS) fitdistr(x,densfun="weibull") Att., Rubem