[R] need help in using Hessian matrix

2009-11-02 Thread Laila Alkhalfan
Hi
I need to find the Hessian matrix for a complicated function from a certain
kind of data but i keep getting this error
Error in f1 - f2 : non-numeric argument to binary operator

the data is given by

  U-runif(n)
  Us-sort(U)
  tau1- 2
  F1tau- pgamma((tau1/theta1),shape,1)
  N1-sum(UsF1tau)
  X1- Us[1:N1]
  Ti- theta1*qgamma(Us[1:N1],shape,1)
  w=N1+1
  V- Us[w:r]
  N2- length(V)
  V1-theta2*qgamma(V,shape,1)
  Tj-V1+tau1-(theta2/theta1)*tau1
  c1-matrix(Ti,ncol=1)
  c2-matrix(Tj,ncol=1)
  cc-data.frame(rbind(c1,c2))[,1]

require(numDeriv)
m1- function(x)  #a function that generates the estimates
{
   loglik-function(alpha,theta1,theta2){
   -(
log(factorial(n)/(factorial(N1)*factorial(N2)))-r*lgamma(alpha)-alpha*N1*log(theta1)

-alpha*(r-N1)*log(theta2)+(alpha-1)*sum(log(cc[1:N1]))+(alpha-1)*sum(log(cc[w:r]-tau1+

(theta2/theta1)*tau1))-(1/theta1)*sum(cc[1:N1])-(1/theta2)*sum(cc[w:r]-tau1+(theta2/theta1)*tau1)+

(n-r)*log(1-pgamma((max(cc)-tau1+(theta2/theta1)*tau1)/theta2,alpha,1)))
   }}

H-hessian(m1, cc)

Thank you and take care.
Laila

[[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.


[R] intigrate function and absolute error

2009-11-01 Thread Laila Alkhalfan
Hi
 Can we get the result of an intigration without the absolute error?
for example
f1-function(x1){(1/gamma(alpha))*x1^(alpha-1)*exp(-x1)*log(x1)}
I1-integrate(f1, 0, (max(cc)-tau1+(theta2/theta1)*tau1)/theta2)
I1
0.08007414 with absolute error  7.2e-05
 I need the answer  0.08007414 withou the other part(with absolute error
7.2e-05)
how can we do that?
thank you and take care
Laila

[[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.