tscount (version 1.4.2)

interv_detect.tsglm: Detecting an Intervention in Count Time Series Following Generalised Linear Models

Description

Detection procedure for an intervention of given type occuring at unknown time as proposed by Fokianos and Fried (2010, 2012).

Usage

# S3 method for tsglm
interv_detect(fit, taus=2:length(fit$ts), delta, external=FALSE, 
              B=NULL, info=c("score"), start.control_bootstrap, 
              final.control_bootstrap, inter.control_bootstrap, 
              parallel=FALSE, est_interv=TRUE, ...)

Arguments

fit

an object of class "tsglm". Usually the result of a call to tsglm.

taus

integer vector of time points which are considered for the possible intervention to occur. Default is to consider all possible time points.

delta

numeric value that determines the type of intervention (see Details).

external

logical value specifying wether the intervention's effect is external or not (see Details).

B

positive integer value giving the number of bootstrap samples for estimation of the p-value. For B=NULL (the default) no p-value is returned.

info

character value that determines how to calculate the information matrix, see tsglm. Currently "score" is the only possible choice.

start.control_bootstrap

named list that determines how to make initial estimation in the bootstrap, see argument start.control in tsglm. If missing, the same settings as for the regular estimation are used.

final.control_bootstrap

named list that determines how to make final maximum likelihood estimation in the bootstrap, see argument final.control in tsglm. If missing, the same settings as for the regular estimation are used. If final.control_bootstrap=NULL, then the model is not re-fitted for each bootstrap sample. Instead the parameters of the original fit which have been used for simulating the bootstrap samples are used. This approach saves computation time at the cost of a more conservative procedure, see Fokianos and Fried (2012).

inter.control_bootstrap

named list determining how to maximise the log-likelihood function in an intermediate step, see argument inter.control in tsglm. If missing, the same settings as for the regular estimation are used.

parallel

logical value. If parallel=TRUE, the bootstrap is distributed to multiple cores parallely. Requires a computing cluster to be initialised and registered as the default cluster by makeCluster and setDefaultCluster from package parallel.

est_interv

logical value. If est_interv=TRUE a fit for the model with the intervention effect with the largest test statistic is computed and additionally returned.

...

additional arguments passed to the fitting function tsglm.

Value

An object of class "interv_detect", which is a list with at least the following components:

test_statistic

maximum value of the score test statistics for all considered times in taus.

test_statistic_tau

numeric vector of all score test statistics at the considered times in taus.

tau_max

time at which the score test statistic has its maximum.

fit_H0

object of class "tsglm" with the fitted model under the null hypothesis of no intervention, see tsglm.

model_interv

model specification of the model with the specified intervention at time tau_max.

If argument est_interv=TRUE (the default), the following component is additionally returned:

fit_interv

object of class "tsglm" with the fitted model with the specified intervention at time tau_max, see tsglm.

Details

For each time in taus the score test statistic for an intervention effect occuring at that time is computed, see interv_test. The time with the maximum test statistic is considered as a candidate for a possible intervention effect at that time. The type of the intervention effect is specified by delta as described in interv_covariate. The intervention is included as an additional covariate according to the definition in tsglm. It can have an internal (the default) or external (external=TRUE) effect (see Liboschik et al., 2014).

If argument B is not NULL, the null hypothesis that there is no intervention effect at any time is tested. Test statistic for this test is the maximum test statistic of the score test (see above). The p-value is computed by a parametric bootstrap with B bootstrap samples. It is recommended to use at least several hundred bootstrap samples. Note that this bootstrap procedure is very time-consuming.

References

Fokianos, K. and Fried, R. (2010) Interventions in INGARCH processes. Journal of Time Series Analysis 31(3), 210--225, http://dx.doi.org/10.1111/j.1467-9892.2010.00657.x.

Fokianos, K., and Fried, R. (2012) Interventions in log-linear Poisson autoregression. Statistical Modelling 12(4), 299--322. http://dx.doi.org/10.1177/1471082X1201200401.

Liboschik, T. (2016) Modelling count time series following generalized linear models. PhD Thesis TU Dortmund University, http://dx.doi.org/10.17877/DE290R-17191.

Liboschik, T., Kerschke, P., Fokianos, K. and Fried, R. (2016) Modelling interventions in INGARCH processes. International Journal of Computer Mathematics 93(4), 640--657, http://dx.doi.org/10.1080/00207160.2014.949250.

See Also

S3 methods print and plot.

tsglm for fitting a GLM for time series of counts. interv_test for testing on intervention effects and interv_multiple for iterative detection of multiple interventions of unknown types. interv_covariate for generation of deterministic covariates describing intervention effects.

Examples

Run this code
# NOT RUN {
###Campylobacter infections in Canada (see help("campy"))
#Searching for a potential intervention effect:
campyfit <- tsglm(ts=campy, model=list(past_obs=1, past_mean=c(7,13)))
campyfit_intervdetect <- interv_detect(fit=campyfit, taus=80:120, delta=1)
campyfit_intervdetect
plot(campyfit_intervdetect)
#Additionally computing a p-value with the bootstrap procedure based on 500
#replications would take about 20 minutes in this example on a single
#processing unit, of course depending on its speed.

# }
# NOT RUN {
#Parallel computation for shorter run time on a cluster:
library(parallel)
ntasks <- 3
clust <- makeCluster(ntasks)
setDefaultCluster(cl=clust)
interv_detect(fit=campyfit, taus=80:120, delta=1, B=500, parallel=TRUE)
# }

Run the code above in your browser using DataCamp Workspace