TemperedEstim_Simulation {TempStable} | R Documentation |
Monte Carlo Simulation
Description
Runs Monte Carlo simulation for a selected estimation method. The function can save results in a file.
Usage
TemperedEstim_Simulation(
ParameterMatrix,
SampleSizes = c(200, 1600),
MCparam = 100,
TemperedType = c("CTS", "TSS", "NTS", "MTS", "GTS", "KRTS", "RDTS"),
Estimfct = c("ML", "GMM", "Cgmm", "GMC"),
HandleError = TRUE,
saveOutput = FALSE,
SeedOptions = NULL,
eps = 1e-06,
algo = NULL,
regularization = NULL,
WeightingMatrix = NULL,
t_scheme = NULL,
alphaReg = NULL,
t_free = NULL,
nb_t = NULL,
subdivisions = NULL,
IntegrationMethod = NULL,
randomIntegrationLaw = NULL,
s_min = NULL,
s_max = NULL,
ncond = NULL,
IterationControl = NULL,
methodR = "TM",
...
)
Arguments
ParameterMatrix |
The matrix is to be composed of vectors, row by row.
Each vector must fit the pattern of theta of the |
SampleSizes |
Sample sizes to be used to simulate the data. By default, we use 200 (small sample size) and 1600 (large sample size); vector of integer. |
MCparam |
Number of Monte Carlo simulation for each couple of parameter, default=100; integer |
TemperedType |
A String. Either "CTS", "TSS", "NTS", "MTS", "GTS", "KRTS", "RDTS". |
Estimfct |
The estimation function to be used. A String. Either "ML", "GMM", "Cgmm", or "GMC". |
HandleError |
Logical flag: if set to TRUE, the simulation doesn't stop when an error in the estimation function is encountered. A vector of (size 4) NA is saved and the the simulation carries on. See details. |
saveOutput |
Logical flag: if set to TRUE, a csv file (for each couple of parameter) with the the estimation information is saved in the current directory. See details. |
SeedOptions |
List to control the seed generation. See details. |
eps |
Numerical error tolerance. |
algo |
algorithm: For GMM: |
regularization |
regularization scheme to be used for moment methods,
one of |
WeightingMatrix |
type of weighting matrix used to compute the
objective function for the GMM and GMC methods, one of |
t_scheme |
scheme used to select the points for the GMM method where the
moment conditions are evaluated, one of |
alphaReg |
value of the regularisation parameter; numeric. Example Value could be ==0.01. |
t_free |
sequence, if |
nb_t |
integer, if you set |
subdivisions |
Number of subdivisions used to compute the different integrals involved in the computation of the objective function for the Cgmm method (to minimise); numeric. |
IntegrationMethod |
Numerical integration method to be used to approximate the (vectorial) integrals for the Cgmm method. Users can choose between "Uniform" discretization or the "Simpson"'s rule (the 3-point Newton-Cotes quadrature rule). |
randomIntegrationLaw |
Probability measure associated to the Hilbert space spanned by the moment conditions for the Cgmm method. |
s_min , s_max |
Lower and Upper bounds of the interval where the moment conditions are considered for the Cgmm method; numeric. |
ncond |
Integer. Number of moment conditions (until order |
IterationControl |
only used if algo = "IT..." or algo = "Cue..." to control the iterations. See Details. |
methodR |
A string. Method generates random variates of TS distribution. "TM" by default. Switches automatically if the method is not applicable in this way. |
... |
Other arguments to be passed to the estimation function. |
Details
TemperedTyp With the parameter 'TemperedTyp' you can choose the tempered stable distribution you want to use. Here is a list of distribution you can choose from:
- TSS
Tempered stabel subordinator: See
charTSS()
for details.- CTS
Classical tempered stable distribution: See
charCTS()
for details.- GTS
Generalized classical tempered stable distribution: See
charGTS()
for details.- NTS
Normal tempered stable distribution: See
charNTS()
for details.- MTS
Modified tempered stable distribution: See
charMTS()
for details.- RDTS
Rapid decreasing tempered stable distribution: See
charRDTS()
for details.- KRTS
Kim-Rachev tempered stable distribution: See
charKRTS()
for details.
Error Handling It is advisable to set it to TRUE when user is planning to launch long simulations as it will prevent the procedure to stop if an error occurs for one sample data. The estimation function will produce a vector of NA as estimated parameters related to this (error generating) sample data and move on to the next Monte Carlo step.
Output file Setting saveOutput
to TRUE
will have the
side effect of saving a csv file in the working directory. This file will
have MCparam*length(SampleSizes)
lines and its columns will be:
- alphaT, ...:
the true value of the parameters.
- data size:
the sample size used to generate the simulated data.
- seed:
the seed value used to generate the simulated data.
- alphaE, ...:
the estimate of the parameters.
- failure:
binary: 0 for success, 1 for failure.
- time:
estimation running time in seconds.
The file name is informative to let the user identify the value of the true parameters, the MC parameters as well as the options selected for the estimation method. The csv file is updated after each MC estimation which is useful when the simulation stops before it finishes.
SeedOptions If users does not want to control the seed generation, they could ignore this argument (default value NULL). This argument can be more useful when they wants to cut the simulation (even for one parameter value) into pieces. In that case, they can control which part of the seed vector they want to use.
- MCtot:
total values of MC simulations in the entire process.
- seedStart:
starting index in the seed vector. The vector extracted will be of size MCparam.
Estimfct Additional parameters are needed for different estimation
functions. These are listed below for each function. The list of additional
parameters starts after the parameter eps
in the parameter list.
- For ML:
See usage of Maximum likelihood estimation in Kim et al. (2008).No additional parameters are needed.
- For GMM:
Generalized Method of Moments by Feuerverger (1981). The parameters
algo, alphaReg, regularization, WeightingMatrix, and t_scheme
must be specified.Parameter
t_scheme
: One of the most important features of this method is that it allows the user to choose how to place the points where the moment conditions are evaluated. One can choose among 6 different options. Depending on the option, further parameters have to be passed.- "equally":
equally placed points in
min_t,max_t
. When provided, user'smin_t
andmax_t
will be used (whenCoinstrained == FALSE
).- "NonOptAr":
non optimal arithmetic placement.
- "uniformOpt":
uniform optimal placement.
- "ArithOpt":
arithmetic optimal placement.
- "Var Opt":
optimal variance placement as explained above.
- "free":
user needs to pass own set of points in
t_free
.
Parameter
WeightingMatrix
: One can choose among 3 different options:- "OptAsym":
the optimal asymptotic choice.
- "DataVar":
the covariance matrix of the data provided.
- "Id":
the identity matrix.
- For Cgmm:
Continuum Generalized Methods of Moments by Carrasco & Kotchoni (2017). The parameters
algo, alphaReg, subdivisions, IntegrationMethod, randomIntegrationLaw, s_min, and s_max
must be specified.- For GMC:
Generalized Method of Cumulants (GMC) by Massing, T. (2022). The parameters
algo, alphaReg, regularization, WeightingMatrix, and ncond
must be specified.
IterationControl If algo = "IT..."
or algo =
"Cue..."
the user can control each iteration by setting up the list
IterationControl which contains the following elements:
- NbIter
maximum number of iteration. The loop stops when NBIter is reached; default = 10.
- PrintIterlogical
if set to TRUE, the value of the current parameter estimation is printed to the screen at each iteration; default = TRUE.
- RelativeErrMax
the loop stops if the relative error between two consecutive estimation steps is smaller than RelativeErrMax; default = 1e-3.
methodR Random numbers must be generated for each MC study. For
each distribution, different methods are available for this (partly also
depending on alpha). For more information, the documentation of the
respective r...()
distribution can be called up. By default, the fastest
method is selected. Since the deviation error can amplify to the edges of
alpha depending on the method, it is recommended to check the generated
random numbers once for each distribution using the density function before
starting the simulation.
Parallelization Parallelization of the function is possible with
using parallelizeMCsimulation()
. If someone wants to parallelize the
function manually, the parameter MCparam
must be set to 1
and
the parameter SeedOption
must be changed for each iteration.
Since this package is structurally based on the "StableEstim" package by Tarak Kharrat and Georgi N. Boshnakov, more detailed documentation can be found in their documentation.
Value
If saveOutput == FALSE
, the return object is a list of 2.
Results of the simulation are listed in $outputMat
. If
saveOutput == TRUE
, only a csv file is saved and nothing is returned.
References
Massing, T. (2023), 'Parametric Estimation of Tempered Stable Laws'
Kim, Y. s.; Rachev, S. T.; Bianchi, M. L. & Fabozzi, F. J. (2008), 'Financial market models with lévy processes and time-varying volatility' doi:10.1016/j.jbankfin.2007.11.004
Hansen, L. P. (1982), 'Large sample properties of generalized method of moments estimators' doi:10.2307/1912775
Hansen, L. P.; Heaton, J. & Yaron, A. (1996), 'Finite-Sample Properties of Some Alternative GMM Estimators' doi:10.1080/07350015.1996.10524656
Feuerverger, A. & McDunnough, P. (1981), 'On the efficiency of empirical characteristic function procedures' doi:10.1111/j.2517-6161.1981.tb01143.x
Carrasco, M. & Kotchoni, R. (2017), 'Efficient estimation using the characteristic function' doi:10.1017/S0266466616000025;
Kuechler, U. & Tappe, S. (2013), 'Tempered stable distribution and processes' doi:10.1016/j.spa.2013.06.012
See Also
https://github.com/GeoBosh/StableEstim/blob/master/R/Simulation.R
Examples
TemperedEstim_Simulation(ParameterMatrix = rbind(c(1.5,1,1,1,1,0),
c(0.5,1,1,1,1,0)),
SampleSizes = c(4), MCparam = 4,
TemperedType = "CTS", Estimfct = "ML",
saveOutput = FALSE)
TemperedEstim_Simulation(ParameterMatrix = rbind(c(1.5,1,1,1,1,0)),
SampleSizes = c(4), MCparam = 4,
TemperedType = "CTS", Estimfct = "GMM",
saveOutput = FALSE, algo = "2SGMM",
regularization = "cut-off",
WeightingMatrix = "OptAsym", t_scheme = "free",
alphaReg = 0.01,
t_free = seq(0.1,2,length.out=12))
TemperedEstim_Simulation(ParameterMatrix = rbind(c(1.45,0.55,1,1,1,0)),
SampleSizes = c(4), MCparam = 4,
TemperedType = "CTS", Estimfct = "Cgmm",
saveOutput = FALSE, algo = "2SCgmm",
alphaReg = 0.01, subdivisions = 50,
IntegrationMethod = "Uniform",
randomIntegrationLaw = "unif",
s_min = 0, s_max= 1)
TemperedEstim_Simulation(ParameterMatrix = rbind(c(1.45,0.55,1,1,1,0)),
SampleSizes = c(4), MCparam = 4,
TemperedType = "CTS", Estimfct = "GMC",
saveOutput = FALSE, algo = "2SGMC",
alphaReg = 0.01, WeightingMatrix = "OptAsym",
regularization = "cut-off", ncond = 8)