[R] ifelse command

From: Xin <jasonshi510_at_hotmail.com>
Date: Sat 22 Jul 2006 - 22:25:39 EST


Dear:

   I try to revise the maximum likelihood function below using something constrains. But it seems something wrong with it. Becasue R would not allow me to edit the function like this. It is very appreciate if you can help.   

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(y>0 & 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

if(y>0 & x1>0 & x2==2,

L<-lgamma(y+p)+p*(log(p)-log(mu+p))+y*(log(mu)-log(mu+p))-lfactorial(y)-lgamma(p)

)

else

if(y>0 & x1>0 & x2==3,

L<-lgamma(y+p)+p*(log(p)-log(mu+p))+y*(log(mu)-log(mu+p))-lfactorial(y)-lgamma(p)

)

else

L

}

Thanks a lot!

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. Received on Sat Jul 22 22:31:22 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sun 23 Jul 2006 - 06:16:55 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.