[R] How to formulate an analytical gradient?

From: francogrex <francogrex_at_mail.com>
Date: Thu 18 Jan 2007 - 10:19:39 GMT

How to formulate an analytical gradient?

Suppose I have the following function/expression:

fr<-function(x){

x1=x[1]
x2=x[2]
x3=x[3]
x4=x[4]
x5=x[5]

z<-((gamma(x1+n)))/((gamma(x1)*factorial(n))*((1+(e/x2))^x1)*((1+(x2/e))^n)) v<-((gamma(x3+n)))/((gamma(x3)*factorial(n))*((1+(e/x4))^x3)*((1+(x4/e))^n))

sum(log( (x5*z)+ ((1-x5)*v) ))
}

These are a mix of two negative binomial distributions, where n and e are know vectors, and I would like to calculate the maxiumum likelihood estimates of the parameters x1,x2,x3,x4 and X5 I am relying on numerical gradients but I think if I use an analytical one it will be more accurate especially when number of parameters is more than 4.

Thanks.

-- 
View this message in context: http://www.nabble.com/How-to-formulate-an-analytical-gradient--tf3033293.html#a8428063
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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 Thu Jan 18 21:53:41 2007

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 Thu 18 Jan 2007 - 11:30:23 GMT.

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