title: How to compute residuals of a point process in python
body: <p>I am trying to reproduce the work from <a href="http://jheusser.github.io/2013/09/08/hawkes.html" rel="noreferrer">http://jheusser.github.io/2013/09/08/hawkes.html</a> in python except with different data.  I have written code to simulate a Poisson process as well as the Hawkes process they describe. </p>
  
  <p>To do the Hawkes model MLE I define the log likelihood function as</p>
  
  <pre><code>def loglikelihood(params, data):
      (mu, alpha, beta) = params
      tlist = np.array(data)
      r = np.zeros(len(tlist))
      for i in xrange(1,len(tlist)):
          r[i] = math.exp(-beta*(tlist[i]-tlist[i-1]))*(1+r[i-1])
      loglik  = -tlist[-1]*mu
      loglik = loglik+alpha/beta*sum(np.exp(-beta*(tlist[-1]-tlist))-1)
      loglik = loglik+np.sum(np.log(mu+alpha*r))
      return -loglik
  </code></pre>
  
  <p>Using some dummy data, we can compute the MLE for the Hawkes process with</p>
  
  <pre><code>atimes=[58.98353497,   59.28420225,   59.71571013,   60.06750179,   61.24794134,
  61.70692463,   61.73611983,   62.28593814,   62.51691723,   63.17370423
  ,63.20125152,   65.34092403,  214.24934446,  217.0390236,   312.18830525,
  319.38385604,  320.31758188,  323.50201334,  323.76801537,  323.9417007]
  
  res = minimize(loglikelihood, (0.01, 0.1,0.1),method='Nelder-Mead',args = (atimes,))
  print res
  </code></pre>
  
  <p>However, I don't know how to do the following  things in python.</p>
  
  <ol>
  <li>How can I do the equivalent of evalCIF to get a similar fitted versus empirical intensities plot as they have?</li>
  <li>How can I compute the residuals for the Hawkes model to  make the equivalent of the QQ plot they have. They say they use an R package called ptproc but I can't find a python equivalent.</li>
  </ol>