[R-br] ERRO COM VALORES 0 E NAs

Rubem Kaipper Ceratti rubem_ceratti em yahoo.com.br
Terça Fevereiro 21 14:30:17 BRST 2012



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
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://listas.inf.ufpr.br/pipermail/r-br/attachments/20120221/fb54ea6d/attachment.html>


Mais detalhes sobre a lista de discussão R-br