Last data update: 2014.03.03

R: ACD simulation
sim_ACDR Documentation

ACD simulation

Description

Simulates a sample from a specified ACD model and error term distribution dist. The error terms can also be sampled from residuals. The possibility of including a diurnal seasonal component in the simulated sample is included.

Usage

    
sim_ACD(N = 1000, model = "ACD", dist = "exponential", param = NULL, order = NULL,
    Nburn = 50, startX = c(1), startMu = c(1), errors = NULL, sampleErrors = TRUE, 
    roundToSec = FALSE, rm0 = FALSE, diurnalFactor = FALSE, splineObj = NULL,
    open = NULL, close = NULL)

Arguments

N

sample size

model

the class of conditional mean duration specification. One of "ACD", "LACD1", "LACD2", "AMACD","ABACD", "SNIACD" or "LSNIACD".

dist

the distribution of the error terms (only if errors are left out). Must be one of "exponential", "weibull", "burr", "gengamma" or "genf".

param

a vector of the parameters of the DGP (data generating process).

order

a vector describing the order of the conditional mean duration specification, e.g. order = c(1,1) for an ACD(1,1) model.

Nburn

the number of burned observations. Used to lower the effect of the start values of the simulated series.

startX

a vector of values to start the simulation from.

startMu

a vector of conditional mean values to start the simulation from.

errors

a vector of error terms. If provided and sampleErrors = TRUE the errors will be sampled from this vector (with replacement). If instead sampleErrors = FALSE the error terms will be matched by the errors vector non stochastic (must then be of the same length as N + Nburn)

sampleErrors

logical flag, see errors above. Default is TRUE.

roundToSec

if TRUE the simulated sample will be discretized with 1 second(unit) precision.

rm0

if TRUE zero durations will be removed. Will the result in a smaller sample than N.

diurnalFactor

if TRUE the simulated data will include a diurnal factor. The diurnal factor is from a fitted cubic spline given as argument to splineObj. If the argument splineObj is empty, a default fitted cubic spline from transData using aggregation over weekdays will be used.

splineObj

a cubic spline return by diurnalAdj(). Currently only works with cubic splines fitted with weekday aggregation. Also see diurnalFactor above.

open

only used if diurnalFactor = TRUE and a splineObj were provided. The time the exchange opens trading (as used in the fitted splineObj), for example open = "10:00:00".

close

only used if diurnalFactor = TRUE and a splineObj were provided. The time the exchange close trading (as used in the fitted splineObj), for example close = "18:25:00".

Value

a numerical vector of simulated ACD durations

Author(s)

Markus Belfrage

Examples


x <- sim_ACD() #simulates 1000 observations from an ACD(1,1) with exp. errors as default
acdFit(x)


Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(ACDm)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/ACDm/sim_ACD.Rd_%03d_medium.png", width=480, height=480)
> ### Name: sim_ACD
> ### Title: ACD simulation
> ### Aliases: sim_ACD
> 
> ### ** Examples
> 
> 
> x <- sim_ACD() #simulates 1000 observations from an ACD(1,1) with exp. errors as default
> acdFit(x)

ACD model estimation by (Quasi) Maximum Likelihood 

Call:
  acdFit(durations = x) 

Model:
  ACD(1, 1)

Distribution:
  exponential

N: 1000

Parameter estimate:
        Coef     SE    PV robustSE
omega  0.135 0.0434 0.002   0.0420
alpha1 0.147 0.0271 0.000   0.0262
beta1  0.777 0.0435 0.000   0.0414


The fixed/unfree mean distribution parameter: 
 lambda: 1

QML robust correlations:
        omega alpha1  beta1
omega   1.000  0.464 -0.862
alpha1  0.464  1.000 -0.826
beta1  -0.862 -0.826  1.000


Goodness of fit:
                     value
LogLikelihood -1505.896464
AIC            3017.792929
BIC            3032.516195
MSE               3.401044

Convergence: 0 

Number of log-likelihood function evaluations: 88 

Estimation time: 0.0177 secs 

Description: Estimated at 2016-07-04 14:06:34 by user ddbj

> 
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>