<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span>Olá pessoal,</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span><br></span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span>estou tentando maximizar uma função usando o optmize, mas recebo sempre uma mensagem de erro. Já olhei o help mas não percebo onde estou errando.</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span><br></span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">Minha função
 é:</div><div><div><br></div><div>n=10000</div><div><br></div><div>L<-function(beta){</div><div>vv<-matrix(nrow=n,ncol=1)</div><div>for(i in 1:n){</div><div>L<- -a[i]*log(dnorm(x[i]*beta))</div><div>vv[i,1]<-L</div><div>}</div><div>print(vv)</div><div>}</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">ja tenho definidos o "a" e o "x", quero maximizar essa função para estimar meu beta.</div></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div>optimize(L,c(-1,1))</div><div>Error in optimize(L, c(-1, 1)) : invalid function value in 'optimize'<br></div><div><br></div><div>Alguém tem uma sugestão?</div><div><br></div><div>Obrigada</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div
 style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "> </div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">-- <br>Daniela Rodrigues Recchia</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">Master Student of Statistics - Technische Universität Dortmund.</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">"It is better to have an inexact answer to the right question than a precise one to the wrong question!"</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;
 ">John Tuckey</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "> </div></div></body></html>