spass (version 1.2)

rnbinom.inar1: Generate Time Series with Negative Binomial Distribution and Autoregressive Correlation Structure of Order One: NB-INAR(1)

Description

rnbinom.inar1 generates one or more independent time series following the NB-INAR(1) model. The generated data has negative binomial marginal distribution and an autoregressive covariance structure.

Usage

rnbinom.inar1(n, size, mu, rho, tp)

Arguments

n

number of observations. If length(n) > 1, the length is taken to be the number required.

size

dispersion parameter (the shape parameter of the gamma mixing distribution). Must be strictly positive, need not be integer.

mu

parametrization via mean: see 'Details'.

rho

correlation coefficient of the underlying autoregressive correlation structure. Must be between 0 and 1.

tp

number of observed time points.

Value

rnbinom.inar1 returns a matrix of dimension n x tp with marginal negative binomial distribution with mean mu and dispersion parameter size, and an autoregressive correlation structure between time points.

Details

The generated marginal negative binomial distribution with mean mu = \(\mu\) and size = \(\eta\) has density $$(\mu/(\mu+\eta))^x \Gamma(x + \eta)/(\Gamma(x+1)\Gamma(\eta)) (\eta/(\mu+\eta))^\eta$$ for \(0 < \mu\), \(0 < \eta\) and \(x=0, 1, 2, ...\).

Within the NB-INAR(1) model, the correlation between two time points \(t\) and \(s\) for rho = \(\rho\) is given through $$\rho^|t-s|$$ for \(0 \le \rho \le 1\).

References

McKenzie Ed (1986), Autoregressive Moving-Average Processes with Negative-Binomial and Geometric Marginal Distributions. Advances in Applied Probability Vol. 18, No. 3, pp. 679-705.

Examples

Run this code
# NOT RUN {
set.seed(8)
random<-rnbinom.inar1(n=1000, size=0.6, mu=2, rho=0.8, tp=6)
cor(random)

#Check the marginal distribution of time point 3
plot(table(random[,3])/1000, xlab="Probability", ylab="Observation")
lines(0:26, dnbinom(0:26, mu=2, size=0.6), col="red")
legend("topright",legend=c("Theoretical Marginal Distribution", "Observed Distribution"), 
col=c("red", "black"), lty=1, lwd=c(1,2))

# }

Run the code above in your browser using DataLab