By the way, in my last post I forgot to return negative of llfn, hence the llfn will be as follows:
llfn <- function(param) { bx <- param[1] b1 <- param[2] b2 <- param[3] b3 <- param[4] b <- param[5] lL1 <- log(L1(bx,b1,b2,b,tt)) lL2 <- log(L2(bx,b1,b2,b3,b,tt)) lL3 <- log(L3(bx,b1,b2,b3,b,tt)) llfn <- (a==1)*lL1+(a==2)*lL2+(a==3)*lL3 return(-llfn) } However, it does not fix the problem, I still receive the same error.. -- View this message in context: http://r.789695.n4.nabble.com/Discrete-choice-model-maximum-likelihood-estimation-tp4629877p4629930.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.