I am trying to solve the following problem in MATHEMATICA:


I was reading this paper: McShane et al. "Count Models Based on Weibull Interarrival Times" (2008) Link:http://www.blakemcshane.com/Papers/jbes_weibull.pdf

This paper a new counting model using a Weibull distribution is implemented.In page 5, it shows the derivation of the final results:

enter image description here

How is it possible to implement this Weibull count process in Mathematica?

I made some tests, but I am not sure if it is correct: For example this is the alfa:

ClearAll["Global`*"] (*Clear all the variables*)
f[xx_, jj_, gino_] := 
  If[xx == 0, ((cc*jj)!)/(jj!), 
   Sum[(((cc*jj - cc*mm)!)/((jj - mm)!))*gino, {mm, xx - 1, jj - 1}]];

Alfajjxx[xx_] = 
  f[xx, jj, 
   f[xx - 1, jj, 
    f[xx - 2, jj, 
     f[xx - 3, jj, 
      f[xx - 4, jj, 
       f[xx - 5, jj, 
        f[xx - 6, jj, 
         f[xx - 7, jj, 
          f[xx - 8, jj, f[xx - 9, jj, f[xx - 10, jj, gino]]]]]]]]]]];
(* how is it possible to implement the above equation using Nest \

(*show the test results*)
f[0, jj, gino]
f[1, jj, f[0, jj, gino]]
f[2, jj, f[1, jj, f[0, jj, gino]]]
f[3, jj, f[2, jj, f[1, jj, f[0, jj, f[0, jj, gino]]]]]

(*implementing the WeibullCountModel*)
wcd[xx_] = 
 Sum[((((-1)^(xx + jj)) ((lb*(t^cc))^jj))*
     Alfajjxx[xx])/((cc*jj)!), {jj, xx, 5}](*Weibull Count Model*)

I do not know if it is correct the implementation, moreover I would use the Nest function to define the alfa coefficient.

Can anyone help me, plese? Thank you very much


1 Answer 1


I have just solved it.

I found a Python code implementing this Weibull Count model.

Here there are the Mathematica code:

A[xx_, jj_] = 
 If[xx == 0, A[xx, jj] = (Gamma[cc*jj + 1])/(Gamma[jj + 1]), 
  A[xx, jj] = 
   Sum[A[xx - 1, 
      mm]*(Gamma[cc jj - cc mm + 1]/Gamma[jj - mm + 1]), {mm, xx - 1, 
     jj - 1}]]
A[0, 20]

Cn[t_, xx_] = 
 Sum[(((-1)^(xx + jj))*(((ll*(t^cc)))^jj)*A[xx, jj])/(Gamma[
     cc*jj + 1]), {jj, xx, 20}]
Cn[1, 0]
Cn[1, 1]
Cn[1, 2]
Cn[1, 3]
Cn[1, 4]
Cn[1, 5]
Cn[1, 6]
Cn[1, 7]
Cn[1, 8]

The link is the following: https://stats.stackexchange.com/questions/89985/how-to-write-this-cost-equation/90007?noredirect=1#comment176209_90007

Now I have a new question, is it possible to use that equation for the regression analysis?

Thanks a lot!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.