Package 'spINAR'

Title: (Semi)Parametric Estimation and Bootstrapping of INAR Models
Description: Semiparametric and parametric estimation of INAR models including a finite sample refinement (Faymonville et al. (2022) <doi:10.1007/s10260-022-00655-0>) for the semiparametric setting introduced in Drost et al. (2009) <doi:10.1111/j.1467-9868.2008.00687.x>, different procedures to bootstrap INAR data (Jentsch, C. and Weiß, C.H. (2017) <doi:10.3150/18-BEJ1057>) and flexible simulation of INAR data.
Authors: Maxime Faymonville [aut, cre] , Javiera Riffo [aut] , Jonas Rieger [aut] , Carsten Jentsch [aut] , Christian H. Weiß [ctb]
Maintainer: Maxime Faymonville <[email protected]>
License: GPL (>= 3)
Version: 0.2.0
Built: 2025-03-04 04:34:41 UTC
Source: https://github.com/mfaymon/spinar

Help Index


(Semi)parametric estimation and bootstrapping of INAR models

Description

Semiparametric and parametric estimation of INAR models including a finite sample refinement for the semiparametric setting, different procedures to bootstrap INAR data and flexible simulation of INAR data.

Semiparametric INAR Model

The package provides a flexible simulation of INAR data by inserting a user-defined pmf argument in the spinar_sim function. Using spinar_est, it allows for semiparametric estimation of the INAR model along Drost et al. (2009) and additionally, it includes a small sample refinement spinar_penal (Faymonville et al., 2022) together with a validation of the upcoming penalization parameters (spinar_penal_val). Furthermore, it contains a semiparametric INAR bootstrap procedure implemented in spinar_boot (Jentsch and Weiß, 2017).

Parametric INAR Model

In addition to the semiparametric model, the package also allows for parametric simulation (spinar_sim), parametric estimation (spinar_est_param) and parametric bootstrapping (spinar_boot) of INAR data.

Author(s)

Maintainer: Maxime Faymonville [email protected] (ORCID)

Authors:

Other contributors:

References

Faymonville, M., Riffo, J., Rieger, J. and Jentsch, C. (2024). "spINAR: An R Package for Semiparametric and Parametric Estimation and Bootstrapping of Integer-Valued Autoregressive (INAR) Models". Journal of Open Source Software 9(97), pp. 5386. doi:10.21105/joss.05386.

Faymonville, M., Jentsch, C., Weiß, C.H. and Aleksandrov, B. (2022). "Semiparametric Estimation of INAR Models using Roughness Penalization". Statistical Methods & Applications. doi:10.1007/s10260-022-00655-0.

Jentsch, C. and Weiß, C. H. (2017), "Bootstrapping INAR Models". Bernoulli 25(3), pp. 2359–2408. doi:10.3150/18-BEJ1057.

Drost, F., Van den Akker, R. and Werker, B. (2009), "Efficient estimation of auto-regression parameters and innovation distributions for semiparametric integer-valued AR(p) models". Journal of the Royal Statistical Society. Series B 71(2), pp. 467–485. doi:10.1111/j.1467-9868.2008.00687.x.

See Also

Useful links:


(Semi)parametric INAR bootstrap procedure

Description

INAR bootstrap procedures for the semiparametric and the parametric INAR setting, where the latter allows for moment- and maximum likelihood-based estimation and Poisson, geometrically and negative binomially distributed innovations.

Usage

spinar_boot(
  x,
  p,
  B,
  setting,
  type = "mom",
  distr = "poi",
  M = 100,
  level = 0.05,
  progress = TRUE
)

Arguments

x

[integer]
vector with integer observations.

p

[integer(1)]
order of the INAR model, where p{1,2}\code{p} \in \{1,2\}.

B

[integer(1)]
number of bootstrap repetitions.

setting

[string(1)]
estimation setting {"sp", "p"}\in \code{\{"sp", "p"\}}, where "sp" defines a semiparametric setting and "p" a parametric setting.

type

[string(1)]
type of estimation {"mom", "ml"}\in \code{\{"mom", "ml"\}}, where "mom" (default) performs moment-based estimation and "ml" maximum likelihood-based estimation.

distr

[string(1)]
parametric family of innovation distribution {"poi", "geo", "nb"}\in \code{\{"poi", "geo", "nb"\}}, where "poi" (default) denotes Poi(lambda), "geo" Geo(prob) and "nb" NB(r, prob) distributions.

M

[integer(1)]
upper limit for the innovations.

level

[numeric(1)]
level for the bootstrap confidence intervals (percentile interval and Hall's percentile interval (bootstrap-t-interval without studentization)).

progress

[logical(1)]
Should a nice progress bar be shown? Turning it off, could lead to significantly faster calculation. Default is TRUE.

Value

[named list] with entries

x_star

[matrix] of bootstrap observations with length(x) rows and B columns.

parameters_star

[matrix] of bootstrap estimated parameters with B rows. If setting = "sp", each row contains the estimated coefficients alpha1,...,alphap\code{alpha}_1,...,\code{alpha}_p and the estimated entries of the pmf pmf0,pmf1\code{pmf}_0, \code{pmf}_1, ... where pmfi\code{pmf}_i represents the probability of an innovation being equal to ii. If setting = "p", each row contains the estimated coefficients alpha1,...,alphap\code{alpha}_1,...,\code{alpha}_p and the estimated parameter(s) of the innovation distribution.

bs_ci_percentile

[named matrix] with the lower and upper bounds of the bootstrap percentile confidence intervals for each parameter in parameters_star.

bs_ci_hall

[named matrix] with the lower and upper bounds of Hall's bootstrap percentile confidence intervals for each parameter in parameters_star.

Examples

# generate data
dat1 <- spinar_sim(n = 200, p = 1, alpha = 0.5,
                   pmf = c(0.3, 0.3, 0.2, 0.1, 0.1))
dat2 <- spinar_sim(n = 200, p = 2, alpha = c(0.2, 0.3),
                   pmf = dgeom(0:60, 0.5))


# semiparametric INAR(1) bootstrap
spinar_boot(x = dat1, p = 1, B = 50, setting = "sp")
# parametric Geo-INAR(2) bootstrap using moment-based estimation
spinar_boot(x = dat2, p = 2, B = 50, setting = "p", type = "mom", distr = "geo")

Semiparametric estimation of INAR models

Description

Semiparametric estimation of the autoregressive parameters and the innovation distribution of INAR(p) models, p{1,2}\code{p} \in \{1,2\}. The estimation is conducted by maximizing the conditional likelihood of the model.

Usage

spinar_est(x, p)

Arguments

x

[integer]
vector with integer observations.

p

[integer(1)]
order of the INAR model, where p{1,2}\code{p} \in \{1,2\}.

Value

Vector containing the estimated coefficients alpha1,...,alphap\code{alpha}_1,...,\code{alpha}_p and the estimated entries of the pmf pmf0,pmf1\code{pmf}_0, \code{pmf}_1,... where pmfi\code{pmf}_i represents the probability of an innovation being equal to ii.

Examples

# generate data
dat1 <- spinar_sim(n = 200, p = 1, alpha = 0.5,
                   pmf = c(0.3, 0.3, 0.2, 0.1, 0.1))
dat2 <- spinar_sim(n = 200, p = 2, alpha = c(0.2, 0.3),
                   pmf = c(0.25, 0.2, 0.15, 0.1, 0.1, 0.1, 0.1))


# semiparametric estimation of INAR(1) model
spinar_est(x = dat1, p = 1)
# semiparametric estimation of INAR(2) model
spinar_est(x = dat2, p = 2)

Parametric estimation of INAR models

Description

Parametric estimation of the autoregressive parameters and the innovation distribution of INAR(p) models, p{1,2}\code{p} \in \{1,2\}, with Poisson, geometrically or negative binomially distributed innovations. The estimation can either be moment- or maximum likelihood-based.

Usage

spinar_est_param(x, p, type, distr)

Arguments

x

[integer]
vector with integer observations.

p

[integer(1)]
order of the INAR model, where p{1,2}\code{p} \in \{1,2\}.

type

[string(1)]
type of estimation {"mom", "ml"}\in \code{\{"mom", "ml"\}}, where "mom" performs moment-based estimation and "ml" maximum likelihood-based estimation.

distr

[string(1)]
parametric family of innovation distribution {’poi’, ’geo’, ’nb’}\in \code{\{'poi', 'geo', 'nb'\}}, where "poi" denotes Poi(lambda), "geo" Geo(prob) and "nb" NB(r, prob) distributions.

Value

Named vector containing the estimated coefficients alpha1,...,alphap\code{alpha}_1,...,\code{alpha}_p and the estimated parameter(s) of the innovation distribution.

Examples

# generate data
# Poi-INAR(1) data
dat1 <- spinar_sim(n = 200, p = 1, alpha = 0.5, pmf = dpois(0:20, 1))
# Geo-INAR(2) data
dat2 <- spinar_sim(n = 200, p = 2, alpha = c(0.2, 0.3),
                   pmf = dgeom(0:60, 0.5))
# NB-INAR(1) data
dat3 <- spinar_sim(n = 200, p = 1, alpha = 0.5, pmf = dnbinom(0:40, 2, 2/3))

# moment-based parametric estimation of Poi-INAR(1) model
spinar_est_param(x = dat1, p = 1, type = "mom", distr = "poi")
# moment-based parametric estimation of Geo-INAR(2) model
spinar_est_param(x = dat2, p = 2, type = "mom", distr = "geo")
# maximum likelihood-based parametric estimation of NB-INAR(1) model
spinar_est_param(x = dat3, p = 1, type = "ml", distr = "nb")

Penalized semiparametric estimation of INAR models

Description

Semiparametric penalized estimation of the autoregressive parameters and the innovation distribution of INAR(p) models, p{1,2}\code{p} \in \{1,2\}. The estimation is conducted by maximizing the penalized conditional likelihood of the model. If both penalization parameters are set to zero, the function coincides to the spinar_est function of this package.

Usage

spinar_penal(x, p, penal1 = 0, penal2 = 0)

Arguments

x

[integer]
vector with integer observations.

p

[integer(1)]
order of the INAR model, where p{1,2}\code{p} \in \{1,2\}.

penal1

L1L_1 penalization parameter (default value zero results in no L1L_1 penalization)

penal2

L2L_2 penalization parameter (default value zero results in no L2L_2 penalization)

Value

Vector containing the penalized estimated coefficients alpha1,...,alphap\code{alpha}_1,...,\code{alpha}_p and the penalized estimated entries of the pmf pmf0,pmf1\code{pmf}_0, \code{pmf}_1,... where pmfi\code{pmf}_i represents the probability of an innovation being equal to ii.

Examples

# generate data
dat1 <- spinar_sim(n = 50, p = 1, alpha = 0.5,
                   pmf = c(0.3, 0.25, 0.2, 0.15, 0.1))

# penalized semiparametric estimation
spinar_penal(x = dat1, p = 1, penal1 = 0, penal2 = 0.1)

Validated penalized semiparametric estimation of INAR models

Description

Semiparametric penalized estimation of the autoregressive parameters and the innovation distribution of INAR(p) models, p{1,2}\code{p} \in \{1,2\}. The estimation is conducted by maximizing the penalized conditional likelihood of the model. Included is a possible validation of one or both penalization parameters. If no validation is wanted, the function coincides to the spinar_penal function of this package.

Usage

spinar_penal_val(
  x,
  p,
  validation,
  penal1 = NA,
  penal2 = NA,
  over = NA,
  folds = 10,
  init1 = 1,
  init2 = 1,
  progress = TRUE
)

Arguments

x

[integer]
vector with integer observations.

p

[integer(1)]
order of the INAR model, where p{1,2}\code{p} \in \{1,2\}.

validation

[logical(1)]
indicates whether validation is wanted.

penal1

[numeric(1)]
L1L_1 penalization parameter. It will be ignored if validation = TRUE and over {"both","L1"}\in \{"both", "L_1"\}. It is mandatory if validation = FALSE.

penal2

[numeric(1)]
L2L_2 penalization parameter. It will be ignored if validation = TRUE and over {"both","L2"}\in \{"both", "L_2"\}. It is mandatory if validation = FALSE.

over

[string(1)]
validation over "both" penalization parameters or only over "L_1" or "L_2". It is mandatory if validation = TRUE, otherwise it will be ignored.

folds

[integer(1)]
number of folds for (cross) validation.

init1

[numeric(1)]
initial value for penal1 in validation. Default value is init1 = 1.

init2

[numeric(1)]
initial value for penal2 in validation. Default value is init2 = 1

progress

[logical(1)]
Should a nice progress bar be shown? Turning it off, could lead to significantly faster calculation. Default is TRUE.

Value

If validation = FALSE, the function returns a vector containing the penalized estimated coefficients alpha1,...,alphap\code{alpha}_1,...,\code{alpha}_p and the penalized estimated entries of the pmf pmf0,pmf1\code{pmf}_0, \code{pmf}_1... where pmfi\code{pmf}_i represents the probability of an innovation being equal to ii.

If validation = TRUE, the function returns a named list, where the first entry contains the penalized estimated coefficients alpha1,...,alphap\code{alpha}_1,...,\code{alpha}_p and the penalized estimated entries of the pmf pmf0,pmf1\code{pmf}_0, \code{pmf}_1,... where pmfi\code{pmf}_i represents the probability of an innovation being equal to ii. The second (and if over = both also the third entry) contain(s) the validated penalization parameter(s).

Examples

# generate data
dat1 <- spinar_sim(n = 50, p = 1, alpha = 0.5,
                   pmf = c(0.3, 0.3, 0.2, 0.1, 0.1))


# penalized semiparametric estimation with validation over L1
spinar_penal_val(x = dat1, p = 1, validation = TRUE, penal2 = 0.1,
                 over = "L1")
# penalized semiparametric estimation with validation over both L1 and L2
spinar_penal_val(x = dat1, p = 1, validation = TRUE, over = "both")

Simulation of (semi)parametric integer autoregressive (INAR) models

Description

Generating INAR(p) observations, where p {1,2}\in \{1,2\}. It allows for general pmfs which can be generated parametrically or "manually" (semiparametrically).

Usage

spinar_sim(n, p, alpha, pmf, prerun = 500)

Arguments

n

[integer(1)]
number of observations.

p

[integer(1)]
lag of the INAR(p) model, where p {1,2}\in \{1,2\}.

alpha

[integer(p)]
vector of INAR coefficients alpha1,...,alphap\code{alpha}_1,...,\code{alpha}_p.

pmf

[numeric]
vector of probability mass function pmf0,...,pmfk\code{pmf}_0,..., \code{pmf}_k where pmfi\code{pmf}_i represents the probability of an innovation being equal to ii.

prerun

[integer(1)]
number of observations which are generated additionally and then omitted (to ensure stationarity).

Value

Vector with nn INAR(p) observations.

Examples

# generate (semiparametrically) 100 INAR(1) observations with
# alpha_1 = 0.5 and a manually set pmf
spinar_sim(n = 100, p = 1, alpha = 0.5, pmf = c(0.3, 0.3, 0.2, 0.1, 0.1))

# generate 100 obervations of an INAR(2) model with
# alpha_1 = 0.2, alpha_2 = 0.3 and Poi(1)-innovations
spinar_sim(n = 100, p = 2, alpha = c(0.2, 0.3), pmf = dpois(0:20,1))