Learn R Programming

ACDm (version 1.0.3)

sim_ACD: 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

Examples

Run this code

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


Run the code above in your browser using DataLab