2
$\begingroup$

Suppose I have a data vector v, in which all values are greater than zero.

Now, I want to see if it follows a shifted Poisson distribution.

Can I do it by shifting everything to the left first, and fitting a Poisson in the usual fashion? For example, in R I can fit a Poisson by using the "fitdistr" function. Can I do vec <- v - 1 to shift everything to the left first (so that we can treat it like normal Poisson distribution)? And then run fitdistr(vec, "poisson").

Second Question: Now suppose I want to carry out a chisq.test(). The frequency table of the actual data vector vecis as follow:

table(vec)
   0    1    2    3    4    5    6    7    8    9   10   11   12   13   14   16   17   18   19   20   21   22 
 611 1297 1893 2730 2759 2198 1525  927  456  243   75   39   18    7    2    1    2    4   12   20   34   34 
  23   24   25   26   27   30   34   35   36   37   38   39   40   41   42   43   44   47   48   52   54   55 
  19   13    8    2    1    3    1    4    7    7   10    8    5    2    8    3    3    3    1    1    1    2 
  56   57   58   67   70   71   75  188 
   2    1    3    1    1    1    1    1  

And to construct chi-squared goodness of fit test, I did:

p1 <- dpois(0:188, lambda = 4.33657562) 
p1 <- c(p1, 1 - sum(p1))
names(p1) <- c(0:188, "more")
chisq.test(table(factor(vec, levels = c(0:188, "more") )), p = p1)

I do not know why I got p value = NA at the end. Please explain to me what is going wrong here ?

X-squared = NaN, df = 189, p-value = NA

The distribution of discrete data is as follows, with the purple line - the shifted poisson distribution ($\lambda = 4.33$)

$\endgroup$
  • $\begingroup$ Suddenly, this looks very familiar. Is this for some class? $\endgroup$ – Glen_b -Reinstate Monica Sep 8 '13 at 5:56
  • $\begingroup$ No, but I am preparing myself for class in future $\endgroup$ – user1769197 Sep 8 '13 at 6:00
  • $\begingroup$ Then it would appear to count as self-study, but perhaps it's not absolutely critical here. $\endgroup$ – Glen_b -Reinstate Monica Sep 8 '13 at 6:01
  • $\begingroup$ I have been stuck in this p value = NA problem for almost the whole day. I just wanted to know what went wrong. It would be helpful, if you can give me some help in this problem, because I think I am still not grasping the concept of chisq test well enough. $\endgroup$ – user1769197 Sep 8 '13 at 6:04
  • $\begingroup$ Try working out the contribution to chi-square of the last cell by hand. That would be my guess as to why you get NA. Incidentally, I think the occurrence of a value of 188 with that sample size rules out a Poisson(4.33) pretty comprehensively. $\endgroup$ – Glen_b -Reinstate Monica Sep 8 '13 at 6:06
1
$\begingroup$

Yes, that strategy - shifting back, then estimating in the usual way - should work fine (with the proviso that you then need to shift the resulting fitted distribution back again if you want to write it as a shifted Poisson on the original data).

An example in R, using fitdistr:

 v <- rpois(110,3.2)+1  # make up some data
 library(MASS)
 vfit <- fitdistr(v-1,"poisson")
 vfit
    lambda  
  3.1909091 
 (0.1703181)
 obf <- as.vector(table(v)/sum(table(v)))
 plot(1:8,obf,type="h",lwd=2,xlim=c(0,10),ylim=c(0,0.25))
 lines((1:10)+.05,dpois(0:9,3.191),col=2,type="h",lwd=2)
 abline(h=0,col=8)

shifted Poisson, observed and fitted

$\endgroup$
  • $\begingroup$ Thanks. Actually, there is one more question I want to ask. Please see edited question in 30 minutes. $\endgroup$ – user1769197 Sep 8 '13 at 5:29
  • $\begingroup$ I hope the discussion in comments under the question is now sufficient to cover that issue for you. $\endgroup$ – Glen_b -Reinstate Monica Sep 8 '13 at 16:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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