I have a count data and I need to do time series analysis using Dynamic negative binomial regression as the data has autocorrelation and Overdispersion issues. I did an online search for any R package that I can use but I was not able to find one.
I would appreciate any help.
An example of my data:
>St1
[1] 17 9 28 7 23 16 17 12 11 16 19 29 5 40 13 27 13 11 10 14 13 23 21 24 9 42 14 22 17 9
>Years
[1] 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006
[23] 2007 2008 2009 2010 2011 2012 2013 2014
>library(AER)
>library(stats)
>rd <- glm(St1 ~ Years, family = poisson)
>dispersiontest(rd)
Overdispersion test
data: rd
z = 2.6479, p-value = 0.00405
alternative hypothesis: true dispersion is greater than 1
sample estimates:
dispersion
4.305539
#Autocorrelation
>Box.test (St1, lag=ceiling(log(length(St1))), type = "Ljung")
Box-Ljung test
data: St1
X-squared = 13.612, df = 4, p-value = 0.008641