<html><body><div style="color:#000; background-color:#fff; font-family:Courier New, courier, monaco, monospace, sans-serif;font-size:10pt"><div><span><font face="arial, helvetica, sans-serif">Pedro,</font><font face="arial, helvetica, sans-serif"><br></font></span></div><div><span><font face="arial, helvetica, sans-serif"><br></font></span></div><div><span><font face="arial, helvetica, sans-serif">neste c</font></span><span><font face="arial, helvetica, sans-serif">aso, vc precisa usar method="L-BFGS-B".</font><br></span></div><div><span><font face="arial, helvetica, sans-serif"><br></font></span></div><div><span><font face="arial, helvetica, sans-serif">Att.,<br></font></span></div><div><span><font face="arial, helvetica, sans-serif">Rubem<br></font></span></div><div><br></div> <div style="font-size: 10pt; font-family: "Courier New", "courier", "monaco", monospace, sans-serif"> <div style="font-size: 12pt; font-family:
"times new roman", "new york", "times", serif"> <div dir="ltr"> <font size="2" face="Arial"> <hr size="1"> <b><span style="font-weight:bold;">De:</span></b> Pedro Rafael <pedro.rafael.marinho@gmail.com><br> <b><span style="font-weight: bold;">Para:</span></b> r-br@listas.c3sl.ufpr.br <br> <b><span style="font-weight: bold;">Enviadas:</span></b> Quarta-feira, 21 de Março de 2012 20:48<br> <b><span style="font-weight: bold;">Assunto:</span></b> Re: [R-br] [Dúvida] Máxima Verossimilhança no R.<br> </font> </div> <br>Realmente Benilton. Existia um problema na minha função de log-verossimilhança.<br><br>Correção:<br><br>########################################<br>dados = rbeta(1000000,1,3) # onde p = 1 e q = 3.<br>hist(dados) # Cara dos dados.<br>log.verossimilhanca <- function(teta,y){<br> p = teta[1]<br> q = teta[2]<br> logl <-sum((p-1)*log(y)+(q-1)*log(1-y)+log(gamma(p+q))
-<br>log(gamma(q)) - log(gamma(p)))<br> return(-logl)<br>}<br>optim(theta <- c(1,1),fn =<br>log.verossimilhanca,y=dados,method="Nelder-Mead", lower =<br>c(0.001,0.001),<br> upper = c(40,40))<br><br><br><br> </div> </div> </div></body></html>