Runs Monte Carlo simulation for a selected estimation method. The function can save a file and produce a statistical summary.
1 2 3 4 5 6
Values of the parameter α and β from which we simulate the data. By default, The values of γ and δ are set to 1 and 0 respectively; matrix 2 \times n
Sample sizes to be used to simulate the data. By default, we use
Number of Monte Carlo simulation for each couple of parameter, default=100; integer
The estimation function to be used. User can choose between
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)
Functions used to produce the statistical summary. See details ;
Logical flag: if set to TRUE, a csv file (for each couple of parameter α and β) with the the estimation information is saved in the current directory. See details
Logical flag: if set to TRUE, a statistical summary (using
Logical flag: if set to TRUE, an estimation is
declared failed if the squared error of the estimation is larger
Tolerance on the squared error of the estimation to be declared failed; default 1.5
List to control the seed generation. See details.
Other arguments to be passed to the estimation function.
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.
The function is able to produce a statistical summary of the Monte
Carlo simulation for each parameter (slices of the list). Each slice
is a matrix where the rows represents the true values of the
parameters and the columns the statistical information.
In all cases, the following quantities are computed:
the sample size used to produce the simulated data
the true values of the parameters
the number of times the procedure failed to produce relevant estimation.
The average running time in seconds of the estimation procedure
Besides, the (vector of
the other quantities to be computed by providing the name of the
function object to be applied to the vector of estimated
parameter. The signature of the function should be of the form
p is the vector
length(p)=MCparam) of parameter estimate and
the extra arguments to be passed the function.
By default, the functions of the
StatFcts will be
applied but user can pass his own functions by providing their name (
FctsToApply vector and their definition in the global environment.
Note that if
CheckMat is set to TRUE, the estimation is
considered failed if the squared error (of the first 2 parameters
beta) is larger than
saveOutput to TRUE will have the side effect of
saving a csv file in the working directory. This file will have
length(SampleSizes) lines and its columns will
the true value of the parameters.
the sample size used to generate the simulated data.
the seed value used to generate the simulated data.
the estimate of the 4 parameters.
binary: 0 for success, 1 for failure.
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. Besides, using the
check-pointing mechanism explained below, the simulation can re-start
from where it stopped.
Checkpointing is the act of saving enough program state and results
so far calculated that a computation can be stopped and restarted. The
way we did it here is to save a text file with some useful
information about the state of the estimation. This text file is
updated after each MC iteration and read at the beginning of function
Estim_Simulation to allow the simulation to re-start from where
it stopped. This file is deleted at the end of the simulation procedure.
If user does not want to control the seed generation, he could ignore
this argument (default value
NULL). This argument can be more
useful when one wants to cut the simulation (even for one parameter
value) into pieces. In that case, he can control which part of the
seed vector he wants to use.
total values of MC simulations in the entire process.
starting index in the seed vector. The
vector extracted will be of size
StatSummary is set to TRUE, a
list with 4 slices
(corresponding to the 4 parameters) is returned. Each slice is a
SaveOutput is set to TRUE, only a csv file
is saved and nothing is returned (if
StatSummary is FALSE).
If both are FALSE, the function stops.