sandwich2: Generate Time Series with Negative Binomial Distribution and...

Description Usage Arguments Details Value Source References Examples

View source: R/sandwich2.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
sandwich2(sigma, rho, theta, k, Time, dropout, Model)

Arguments

sigma

assymptotic standard deviation for Full and subpupulation

rho

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

theta

correlation absorption coefficient if tinepoints are farther appart

k

sample size allocation factor between groups: see 'Details'.

Time

vector of measured timepoints

dropout

vector describing the percentage of dropout in every timepoint

Model

either 1 or 2, describing if 4-regressor or 3-regressor model was used.

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 sandwich2 in spass...