title: R function for Likelihood
body: <p>I'm trying to analyze repairable systems reliability using growth models. 
  I have already fitted a Crow-Amsaa model but I wonder if there is any package or any code for fitting a  Generalized Renewal Process (Kijima Model I) or type II 
  in R and find it's parameters Beta, Lambda(or alpha) and q.
  (or some other model for the mean cumulative function MCF) </p>
  
  <p>The equation number 15 of <a href="http://arxiv.org/ftp/arxiv/papers/1006/1006.3718.pdf" rel="nofollow noreferrer">this article</a> gives an expression for the 
  Log-likelihood</p>
  
  <p>I tried to create the function like this:</p>
  
  <pre><code>likelihood.G1=function(theta,x){ 
  # x is a vector with the failure times, theta vector of parameters
  a=theta[1]  #Alpha
  b=theta[2]  #Beta
  q=theta[3]  #q
  
  logl2=log(b/a) # First part of the equation
  
  for (i in 1:length(x)){
  logl2=logl2 +(b-1)*log(x[i]/(a*(1+q)^(i-1))) -(x[i]/(a*(1+q)^(i-1)))^b
  }
  return(-logl2)  #Negavite of the log-likelihood
  }
  </code></pre>
  
  <p>And then use some rutine for minimize the -Log(L)</p>
  
  <pre><code>theta=c(0.5,1.2,0.8)  #Start parameters (lambda,beta,q)
  
  nlm(likelihood.G1,theta, x=Data)
  </code></pre>
  
  <p>Or also</p>
  
  <pre><code>optim(theta,likelihood.G1,method="BFGS",x=Data)
  </code></pre>
  
  <p>However it seems to be some mistake, since the parameters it returns has no sense</p>
  
  <p>Any ideas of what I'm doing wrong?</p>
  
  <p>Thanks</p>