Olá pessoal,

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.

Minha função é:

n=10000

L<-function(beta){
vv<-matrix(nrow=n,ncol=1)
for(i in 1:n){
L<- -a[i]*log(dnorm(x[i]*beta))
vv[i,1]<-L
}
print(vv)
}

ja tenho definidos o "a" e o "x", quero maximizar essa função para estimar meu beta.

optimize(L,c(-1,1))
Error in optimize(L, c(-1, 1)) : invalid function value in 'optimize'

Alguém tem uma sugestão?

Obrigada

 
--
Daniela Rodrigues Recchia

Master Student of Statistics - Technische Universität Dortmund.

"It is better to have an inexact answer to the right question than a precise one to the wrong question!"
John Tuckey