## Infinite Sum

Occasional Contributor
Posts: 9

# Infinite Sum

Is there are formula for computing an infinite sum in SAS?

I can compute an approximation for convergent sum by using a DO-WHILE-LOOP  but I am trying to do MLE for a PDF using PROC NLMIXED; the parameters are dependent on an infinite sum and will not converge if I use a loop for the infinite sum.  Is there a better way to do it?

thanks

-john

Respected Advisor
Posts: 2,655

## Re: Infinite Sum

Posted in reply to GoBrewers14

This definitely sounds interesting, but more info would be helpful.  The first thing that occurs to me is perhaps reparameterizing so that the optimization within NLMIXED handles the convergence.  Can you share the existing code?

The other is to move to PROC IML, where you could code the series and apply some of the optimization functions available to the likelihood function.  See some of the posts by Rick Wicklin on this topic.

Steve Denham

Occasional Contributor
Posts: 9

## Re: Infinite Sum

Posted in reply to SteveDenham

here is an example of what the data would look like:

=====================================

data abc;

input n count_n;

datalines;

0 20

1 65

2 84

3 72

4 45

5 17

6 6

7 1

8 1

;

run;

====================================

I want to use some type of parameter estimation to fit this data to a modified Poisson distribution called the Conway-Maxwell-Poisson distribution ( Conway–Maxwell–Poisson distribution - Wikipedia, the free encyclopedia )

so the proc step would look like...

=====================================

PROC NLMIXED data = abc;

parms m = 0.5 v=0.5;

/* here is where I need to include a infinite sum Z(m,v) = ??? */

ll = count_n*(n*log(m)-v*log(fact(n))-log(Z));

model count_n ~ general(ll);

run;

======================================

thanks,

-john

Respected Advisor
Posts: 2,655

## Re: Infinite Sum

Posted in reply to GoBrewers14

Hi John,

Questions:

1. What does your DOW loop look like?

2a. Do you have PROC IML licensed?

2b. Have you ever used R packages?

The first question may make it possible to do in NLMIXED.  It looks like the programming statements within NLMIXED support looping, so you might be able to get a close approximation that way (although it seems not from your post).

Question 2 addresses a work-around.  There is an R package (compoisson) that will do what you are asking.  If you want to run from SAS, though, you will need IML/IML plus to access R.  There may also be a "pure" IML approach.  Check the postings and blog of .

Steve Denham

Occasional Contributor
Posts: 9

## Re: Infinite Sum

Posted in reply to SteveDenham

i used the approximation suggested in the next post and then compared it the solutions given by the package you suggested in R.

the approximations are very close.

thank you for your help

Esteemed Advisor
Posts: 5,519

## Re: Infinite Sum

Posted in reply to GoBrewers14

Hi John, Have you considered using the approximation given in:

http://www.stat.washington.edu/research/reports/2013/tr615.pdf

PG

PG
Occasional Contributor
Posts: 9

## Re: Infinite Sum

this works well.  thanks for the suggestion.

Discussion stats
• 6 replies
• 352 views
• 6 likes
• 3 in conversation