Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • compare poisson dist with normal approx.

    Hi,
    PoissonNormal.do
    I was taking a stats class in which R is the official or recommended language but I have sticked with Stata. So whenever I have questions, it's a bit tricky to bring them to the prof since she doesn't use stata. Hope I could get some help here. I posted a question below. My problem is that the poisson model with lamda = 10 never converges based on the code i wrote and I am not confident about the normal approximation code either. Please help. Thanks.

    *i want to compare the Poisson cdf and the normal approx. for lamda = 10
    *poisson
    clear
    set obs 30
    gen n = _n -1
    gen prob_poisson = exp(-10)*[(10^n)/exp(lnfactorial(n))]
    gen cum_prob_poisson = sum(prob_poisson)
    list
    *reference material source: http://www.biostat-edu.com/files/Sta...s_for_Ch05.pdf
    set obs 30
    gen z=(n-10.5)/sqrt(10)
    gen cum_prob_norm=normal(z)
    *Compare the Poisson cdf and the normal approximation for (a) λ = 10,
    list
    Thanks.
    Cheng

  • #2
    So, I don't know what you mean here by "never converges." None of these commands involve iteration (at least not explicitly).

    Just perusing the code, I notice a couple of things. First, I don't understand why you have 10.5 instead of 10 in the -gen z = - command. The theorems I am familiar with about the asymptotic limit of the Poisson distribution with mean mu as mu becomes large is that it approaches the normal distribution with mean mu and standard deviation sqrt(mu). So the 10.5 mystifies me.

    Next, unless you specifically want to use the code shown at the link to help reinforce your knowledge of the Poisson distribution's density function, or have to do so because you are using an ancient version of Stata, there is an easier way to get the Poisson distribution:

    Code:
    gen cum_prob_poisson = poisson(10, n)
    See -help density_functions##poisson- for more information about this and other functions related to the Poisson distribution available in Stata.

    Also, the second -set obs 30- command in your code serves no purpose. I suppose it does no harm, but if you try to do this for a larger value of mu that requires more observations, you will need to change that command twice instead of just once. So I would delete it.

    Finally, I'll just comment that 10 is a pretty small number. If you are expecting the Poisson(mu = 10) and Normal(mu = 10, sd = sqrt(10)) distributions to closely track each other, you are going to be disappointed. The asymptotics don't really kick in that soon. On the other hand, if you try this same thing with mu = 100, you will find the distributions are barely distinguishable. (Though you will need more than 30 observations to accommodate that.)

    Comment

    Working...
    X