What's up fellows... I am a begginer in R and i am trying to find the parameters of one likelihood function, but when i otimize it, always appers a error or advertisement and the solve does not occur. The problem seems like that:
"lMix<-function(pars,y){ beta1<-pars[1] beta2<-pars[2] beta3<-pars[3] beta4<-pars[4] beta5<-pars[5] alfa1<-pars[6] Fsp<-log(1/(1+exp(beta1*y[,10]+beta2*y[,3]+beta3*y[,3]+beta4*y[,5]+beta5*y[,6]+alfa1*y[,11]))) Frp<-log(1/(1+exp(beta1*y[,10]+beta2*y[,3]+beta3*y[,3]+beta4*y[,5]+beta5*y[,6]))) logl<- sum((y[,15]*Fsp)+(y[,19]*Frp)) return(-logl) } optim(c(1,1,1,1,1,1), llMix, y=Mix, method="CG") Erro em optim(c(1, 1, 1, 1, 1, 1), llMix, y = Mix, method = "CG") : Função não pode ser calculada nos parâmetros iniciais optimize(c(1,1,1,1,1,1),llMix,y=Mix, method="CG") Erro em min(interval) : invalid 'type' (closure) of argument optim(llMix,pars=c(0,0,0,0,1,1),y=Mix, method="CG") Erro em optim(llMix, pars = c(0, 0, 0, 0, 1, 1), y = Mix, method = "CG") : cannot coerce type 'closure' to vector of type 'double' " What is it happen? Any one can fix it for me or give me suggestions? I have also tried the maxLik package and it does not make the first interaction on the maximization process. Thanks a lot, Gildemir [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.