Perform a simulation and visualization of a copula using numerical partial derivatives of the copula (Nelsen, 2006, p. 32). The method is more broadly known as conditional simulation method. Because a focus of copBasic is on copula theory for pedagogic purposes, the coupling between simulation and subsequent visualization is emphasized by this function by it providing for both simulation and plotting operations by default.
The simCOP
function is based on a uniformly simulating nonexceedance probability \(u\) and then conditioning the \(v\) from the inverse of the sectional derivative for \(V\) with respect to \(U\) (see derCOPinv
). The function for speed will only report a warning if at least one of the requested simulations in n
could not be made because of uniroot
'ing problems in derCOPinv
. The returned data.frame
will be shortened automatically, but this can be controlled by na.rm
. Failure of a simulation is purely dependent failure of the derivative inversion. In general, inversion should be quite robust for continuous or near continuous copulas and even copulas with singularities should be more or less okay. Lastly, the logical combination na.rm=FALSE
and keept=TRUE
could be used to isolate those combinations giving derCOPinv
problems. The implemented simulation method in the copBasic package is known as the conditional distribution method (Nelsen, 2006; pp. 40--41), conditional method, or Rosenblatt transform (Joe, 2014, p. 270).
simCOP(n=100, cop=NULL, para=NULL, na.rm=TRUE, seed=NULL, keept=FALSE,
graphics=TRUE, ploton=TRUE, points=TRUE, snv=FALSE,
infsnv.rm=TRUE, trapinfsnv=.Machine$double.eps,
resamv01=FALSE, showresamv01=FALSE, ...)
rCOP(n, cop=NULL, para=NULL, na.rm=TRUE, seed=NULL,
resamv01=FALSE, showresamv01=FALSE, ...)
An R
data.frame
of the simulated values is returned.
A sample size, default is \(n = 100\);
A copula function;
Vector of parameters, if needed, to pass to the copula;
A logical to toggle the removal of NA
entries should they form on the returned data.frame
. A well implemented copula should accommodate and not return NA
but because this package relies on numerical derivation, it was decided to have a mechanism to handle this;
The integer seed to pass immediately to set.seed()
;
Keep the \(t\) uniform random variable for the simulation as the last column in the returned data.frame
;
A logical that will disable graphics by setting ploton
and points
to FALSE
and overriding whatever their settings were;
A logical to toggle on the plot (see Examples in vuongCOP
);
A logical to actually draw the simulations by the points()
function in R;
A logical to convert the \(\{u,v\}\) to standard normal scores (variates) both for the optional graphics and the returned R data.frame
. Curiously, Joe (2014) advocates extensively for use of normal scores, which is in contrast to Nelsen (2006) who does not;
A logical that will quietly strip out any occurrences of \(u = \{0,1\}\) or \(v = \{0,1\}\) from the simulations because these are infinity in magnitude when converted to standard normal variates has been selected. Thus, this logical only impacts logic flow when snv
is TRUE
. The infsnv.rm
is mutually exclusive from trapinfsnv
;
If TRUE
and presumably small, the numerical value of this argument (\(\eta\)) is used to replace \(u = \{0,1\}\) and \(v = \{0,1\}\) with \(u(0) = v(0) = \eta\) or \(u(1) = v(1) = 1 - \eta\) as appropriate when conversion to standard normal variates has been selected. The setting of trapinfsnv
only is used if snv
is TRUE
and infsnv.rm
is FALSE
;
A logical triggering resampling for the elements of \(v=0\) and \(v=1\) (see Examples). This is a relatively late addition to copBasic logic and hence is disabled by default. If this is set to true, then the operations related to infsnv.rm
and trapinfsnv
are never to be involved later down in the functions' logic;
A logical providing a trigger to display a message()
within the resampling loops for \(v <= 0, v >= 1\); and
Additional arguments to pass to the points()
function in R.
W.H. Asquith
Joe, H., 2014, Dependence modeling with copulas: Boca Raton, CRC Press, 462 p.
Nelsen, R.B., 2006, An introduction to copulas: New York, Springer, 269 p.
derCOPinv
, simCOPmicro