Dear: Continuing the issue of 'ifelse'! I selecting the data whose 'x2'=1 for maximizing likelihood. I used two way to do this but the results are different. 1.Way one I use the data for x2=1 and run the program. It works for me. Tthe program is described as below: function (parameters,y1,x11) { p<-parameters[1] alpha1<-parameters[2] beta1<-parameters[3] delta1<-parameters[4] lamda1<-parameters[5]
mu<-alpha1*((x11)^beta1)*exp(-delta1*(x11^lamda1)) ifelse(y1>0|x11>0, L<-lgamma(y1+p)+p*(log(p)-log(mu+p))+y1*(log(mu)-log(mu+p))-lfactorial(y1)-lgamma(p) ,Inf) L } This is working for me. 2 Way two: I select the data whose x2=1 in the whole range of data. It works but it is not right comparing the value of MLE. the program is: function (parameters,y,x1,x2) { p<-parameters[1] alpha1<-parameters[2] beta1<-parameters[3] delta1<-parameters[4] alpha2<-parameters[5] mu<-alpha1*((x1)^beta1)*exp(-delta1*(x1^alpha2)) if(x1>0 & x2==1) { L<-lgamma(y+p)+p*(log(p)-log(mu+p))+y*(log(mu)-log(mu+p))-lfactorial(y)-lgamma(p) } else L } The reason why I edit the program by the second way is I want to use one program for getting results of the different range of data. Anyone can help? Please! Thanks! Xin Shi [[alternative HTML version deleted]] ______________________________________________ R-help@stat.math.ethz.ch 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.