rnbinom.inar1: Generate Time Series with Negative Binomial Distribution and...

Description Usage Arguments Details Value Source References Examples

View source: R/rnbinom.inar1.r

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

1
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.

Details

The generated marginal negative binomial distribution with mean mu = μ and size = η has density

(μ/(μ+η))^x Γ(x + η)/(Γ(x+1)Γ(η)) (η/(μ+η))^η

for 0 < μ, 0 < η and x=0, 1, 2, ....

Within the NB-INAR(1) model, the correlation between two time points t and s for rho = ρ is given through

ρ^|t-s|

for 0 ≤ ρ ≤ 1.

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.

Source

rnbinom.inar1 computes a reparametrization of the NB-INAR(1) model by McKenzie 1986 using code contributed by Thomas Asendorf.

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

1
2
3
4
5
6
7
8
9
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))

spass documentation built on Jan. 13, 2021, 7:57 p.m.

Related to rnbinom.inar1 in spass...