Learn R Programming

ACDm (version 1.0.3)

acdFit: ACD (Autoregressive Conditional Duration) Model Fitting

Description

This function estimates various ACD models with various assumed error term distributions, using Maximum Likelihood Estimation. The currently available models (conditional mean specifications) are: Standard ACD, Log-ACD (two alternative specifications), AMACD, ABACD, SNIACD and LSNIACD. The currently available distributions are: Exponential (also used for QML), Weibull, Burr, generalized Gamma, and generalized F.

Usage

acdFit(durations = NULL, model = "ACD", dist = "exponential", 
    order = NULL, startPara = NULL,  dailyRestart = 0, optimFnc = "optim",
    method = "Nelder-Mead", output = TRUE, bootstrapErrors = FALSE, 
    forceErrExpec = TRUE, fixedParamPos = NULL, bp = NULL, control = list())

Arguments

durations
either a data frame including, at least, a column named 'durations' or 'adjDur' (for adjusted durations), or a vector of durations
model
the conditional mean model specification. Must be one of "ACD", "LACD1", "LACD2", "AMACD", "BACD", "ABACD", "SNIACD" or "LSNIACD". See 'Details' for de
dist
the assumed error term distribution. Must be one of "exponential", "weibull", "burr", "gengamma", "genf", "qweibull", "mixqwe", "mixqww", or "mix
order
a vector detailing the order of the particular ACD model. For example an ACD(p, q) specification should have order = c(p, q).
startPara
a vector with parameter values to start the maximization algorithm from. Must be in the correct order according to the model specification (see Details).
dailyRestart
if TRUE the conditional duration will start fresh every new trading day. Can only be used if the durations arguments included the clock time of the durations, or if the time argument was provided.
optimFnc
Specifies which optimization function to use for the estimation. "optim", "nlminb", "solnp", and "optimx" are available.
method
Argument passed to the optimization function if optimFnc = "optim" or optimFnc = "optimx" were chosen. Specifies the optimization algorithm.
output
if FALSE the estimation results won't be printed.
bootstrapErrors
if TRUE the standard errors will be computed by using bootstrap simulations. Currently only works with the standard ACD model.
forceErrExpec
if TRUE error terms distribution will be forced to be 1, otherwise the distribution parameter specifying the mean will be set to 1 to ensure identification.
fixedParamPos
a logical vector of TRUE and FALSE. Can only be used if the argument startPara were provided, and should be of the same length. Each element represents the respective start parameter and if TRUE, this pa
bp
used only for the SNIACD or LSNIACD model. A vector of break points.
control
a list of control values, [object Object],[object Object],[object Object]

Value

  • a list of class "acdFit" with the following slots:
  • durationsthe durations object used to fit the model.
  • muHatsa vector of the estimated conditional mean durations
  • residualsthe residuals from the fitted model, calculated as durations/mu
  • modelthe model for the conditional mean durations
  • orderthe order of the model
  • distributionthe assumed error term distribution
  • distCodethe internal code used to represent the distribution
  • mParaa vector of the estimated conditional mean duration parameters
  • dParaa vector of the estimated error distribution parameters
  • Npartotal number of parameters
  • goodnessOfFita data.frame with the log likelihood, AIC, BIC, and MSE calculated as the mean squared deviation of the durations and the estimated conditional durations.
  • parameterInferencea data.frame with the estimated coefficients and their standard errors and p-values
  • forcedDistParathe value of the unfree distribution parameter. If forceErrExpec = TRUE were used, this parameter is a function of the other distribution parameters, to force the mean of the distribution to be one. Otherwise the parameter was fixed at 1 to ensure identification.
  • comments
  • hessianthe numerical hessian of the log likelihood evaluated at the estimate
  • Nnumber of observations
  • evalsnumber of log-likelihood evaluations needed for the maximization algorithm
  • convergenceif the maximization algorithm converged, this value is zero. (see the help file optim, nlminb or solnp)
  • estimationTimetime required for estimation
  • descriptionwho fitted the model and when
  • robustCorronly available for QML estimation (choosing the exponential distribution) for the standard ACD(p, q) model. The robust correlation matrix of the parameter estimates.

Details

The startPara argument is a vector of the parameter values to start from. The length of the vector naturally depends on the model and distribution. The first elements represent the model parameters, and the last elements the distribution parameters. For example for an ACD(1,1) with Weibull errors the first 3 elements are $\omega, \alpha_1, \beta_1$ for the model, and the last is $\gamma$ for the Weibull distribution. The family of ACD models are $$x_i = \mu_i \epsilon_i,$$ where different specifications of the conditional mean duration $\mu_i$ and the error term $\epsilon_i$ give rise to different models as shown below. Conditional mean duration $\mu_i$ specifications according to the model argument: ACD(p, q) specification: (Engle and Russell, 1998) $$\mu_i = \omega + \sum_{j=1}^{p} \alpha_j x_{i-j} + \sum_{j=1}^{q} \beta_j \mu_{i-j}$$ The element order of the startPara vector is $(\omega, \alpha_j...,\beta_j...)$. LACD1(p, q): (Bauwens and Giot, 2000) $$\ln\mu_i = \omega + \sum_{j=1}^{p} \alpha_j \ln \epsilon_{i-j} + \sum_{j=1}^{q} \beta_j \ln \mu_{i-j}$$ The element order of the startPara vector is $(\omega, \alpha_j...,\beta_j...)$. LACD2(p, q): (Lunde, 1999) $$\ln\mu_i = \omega + \sum_{j=1}^{p} \alpha_j \epsilon_{i-j} + \sum_{j=1}^{q} \beta_j \ln \mu_{i-j}$$ The element order of the startPara vector is $(\omega, \alpha_j...,\beta_j...)$. AMACD(p, r, q) (Additive and Multiplicative ACD): (Hautsch , 2012) $$\mu_i = \omega + \sum_{j=1}^{p} \alpha_j x_{i-j} + \sum_{j=1}^{r} \nu_j \epsilon_{i-j} + \sum_{j=1}^{q} \beta_j \mu_{i-j}$$ The element order of the startPara vector is $(\omega, \alpha_j...,\nu_j...,\beta_j...)$. ABACD(p, q) (Augmented Box-Cox ACD): (Hautsch, 2012) $$\mu_i^{\delta_1} = \omega + \sum_{j=1}^{p} \alpha_j \left( |\epsilon_{i-j}-\nu|+c_j|\epsilon_{i-j}-b| \right)^{\delta_2} + \sum_{j=1}^{q} \beta_j \mu_{i-j}^{\delta_1}$$ The element order of the startPara vector is $(\omega, \alpha_j..., c_j..., \beta_j..., \nu, \delta_1, \delta_2)$. BACD(p, q) (Box-Cox ACD): (Hautsch, 2003) $$\mu_i^{\delta_1} = \omega + \sum_{j=1}^{p} \alpha_j \epsilon_{i-j}^{\delta_2} + \sum_{j=1}^{q} \beta_j \mu_{i-j}^{\delta_1}$$ The element order of the startPara vector is $(\omega, \alpha_j..., \beta_j...)$. SNIACD(p, q, M) (Spline News Impact ACD): (Hautsch, 2012, with a slight difference) $$\mu_i = \omega + \sum_{j=1}^{p} (\alpha_{j-1}+c_0) \epsilon_{i-j} + \sum_{j=1}^{p} \sum_{k=M}^{r} (\alpha_{j-1}+c_k)1_{(\epsilon_{i-j} \le \bar{\epsilon_k})}+\sum_{j=1}^{q} \beta_j \mu_{i-j},$$ where $1_{()}$ is an indicator function and $\alpha_0=0$. The element order of the startPara vector is $(\omega, c_k..., \alpha_j..., \beta_j...)$ (The number of $\alpha$-parameters are $p-1]$). The distribution of the error term $\epsilon_i$ specifications according to the dist argument: Exponential distribution, dist = "exponential": $$f(\epsilon)=\exp(-\epsilon)$$ Weibull distribution, dist = "weibull": $$f(\epsilon)=\theta \gamma \epsilon^{\gamma-1}e^{-\theta \epsilon^{\gamma}} ,$$ where $\theta=[\Gamma(\gamma^{-1}+1)]^{\gamma}$ if forceErrExpec = TRUE. Burr distribution, dist = "burr": $$f(\epsilon)= \frac{\theta \kappa \epsilon^{\kappa-1}}{(1+\sigma^2 \theta \epsilon^{\kappa})^{\frac{1}{\sigma^2}+1}},$$ where, $$\theta= \sigma^{2 \left(1+\frac{1}{\kappa}\right)} \frac{\Gamma \left(\frac{1}{\sigma^2}+1\right)}{\Gamma \left(\frac{1}{\kappa}+1\right) \Gamma \left(\frac{1}{\sigma^2}-\frac{1}{\kappa}\right)},$$ if forceErrExpec = TRUE. The element order of the startPara vector is $(model parameters, \kappa, \sigma^2)$. Generalized Gamma distribution, dist = "gengamma": $$f(\epsilon)=\frac{\gamma \epsilon^{\kappa \gamma - 1}}{\lambda^{\kappa \gamma}\Gamma (\kappa)}\exp \left{{-\left(\frac{\epsilon}{\lambda}\right)^{\gamma}}\right}$$ where $\lambda=\frac{\Gamma(\kappa)}{\Gamma(\kappa+\frac{1}{\gamma})}$ if forceErrExpec = TRUE. The element order of the startPara vector is $(model parameters, \kappa, \gamma)$. Generalized F distribution, dist = "genf": $$f(\epsilon)= \frac{\gamma \epsilon^{\kappa \gamma -1}[\eta+(\epsilon/\lambda)^{\gamma}]^{-\eta-\kappa}\eta^{\eta}}{\lambda^{\kappa \gamma}B(\kappa,\eta)},$$ where $B(\kappa,\eta)=\frac{\Gamma(\kappa)\Gamma(\eta)}{\Gamma(\kappa+\eta)}$, and if forceErrExpec = TRUE, $$\lambda=\frac{\Gamma(\kappa)\Gamma(\eta)}{\eta^{1/\gamma}\Gamma(\kappa+1/\gamma)\Gamma(\eta-1/\gamma)}.$$ The element order of the startPara vector is $(model parameters, \kappa, \eta, \gamma)$. q-Weibull distribution, dist = "qweibull": $$f(\epsilon) = (2-q)\frac{a}{b^a} \epsilon^{a-1} \left[1-(1-q)\left(\frac{\epsilon}{b}\right)^a\right]^{\frac{1}{1-q}}$$ where if forceErrExpec = TRUE, $$b = \frac{(q-1)^{\frac{1+a}{a}}}{2-q}\frac{a\Gamma(\frac{1}{q-1})}{\Gamma(\frac{1}{a}) \Gamma(\frac{1}{q-1}-\frac{1}{a}-1)}.$$ The element order of the startPara vector is $(model parameters, a, q)$.

References

Bauwens, L., and P. Giot (2000) The logarithmic ACD model: an application to the bid-ask quote process of three NYSE stocks. Annales d'Economie et de Statistique, 60, 117-149. Engle R.F, Russell J.R. (1998) Autoregressive Conditional Duration: A New Model for Irregularly Spaced Transaction Data, Econometrica, 66(5): 1127-1162. Grammig, J., and Maurer, K.-O. (2000) Non-monotonic hazard functions and the autoregressive conditional duration model. Econometrics Journal 3: 16-38. Hautsch, N. (2003) Assessing the Risk of Liquidity Suppliers on the Basis of Excess Demand Intensities. Journal of Financial Econometrics (2003) 1 (2): 189-215 Hautsch, N. (2012) Econometrics of Financial High-Frequency Data. Berlin, Heidelberg: Springer. Lunde, A. (1999): A generalized gamma autoregressive conditional duration model, Working paper, Aalborg University.

Examples

Run this code
fitModel <- acdFit(durations = adjDurData, model = "ACD", 
            dist = "exponential", order = c(1,1), dailyRestart = 1)

Run the code above in your browser using DataLab