Learn R Programming

copBasic (version 1.7.1)

simCOP: Simulate a Copula by Numerical Derivative Method

Description

Perform a simulation and visualization of a copula by numerical derivatives of the copula (Nelsen, 2006, p. 32). 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 can be controlled by na.rm. Failure of a simulation is purely dependent on the derivative inversion, which should be quite robust for continuous to near continuous copulas and even copulas with singularities should be more or less ok. Lastly, the logical combination na.rm=FALSE and keept=TRUE could be used to isolate those combinations giving derCOPinv problems. The simulation method herein is known as the conditional approach or Rosenblatt transform within this copula literature (Joe, 2015, p. 270).

Usage

simCOP(n=100, cop=NULL, para=NULL, na.rm=TRUE, keept=FALSE,
              graphics=TRUE, ploton=TRUE, points=TRUE, snv=FALSE,
              infsnv.rm=TRUE, trapinfsnv=.Machine$double.eps, ...)

Arguments

n
A sample size, default is $n = 100$;
cop
A copula function;
para
Vector of parameters, if needed, to pass to the copula;
na.rm
A logical to toggle the removal of NA entries on the returned data.frame;
keept
Keep the $t$ uniform random variable for the simulation as the last column in the returned data.frame;
graphics
A logical that will disable graphics by setting ploton and points to FALSE and overriding whatever their settings were;
ploton
A logical to toggle on the plot (see Examples in vuongCOP);
points
A logical to actually draw the simulations by points();
snv
A logical to convert the ${u,v}$ to standard normal scores (variates) both for the optional graphics and the returned data.frame (Curiously, Joe (2015) advocates extensively for use of normal scores, which contrasts to Nelsen (2006) who does
infsnv.rm
A logical that will quitely strip out any occurrences of $u = 0,1$ or $v = 0,1$ from the simulations as these are infinity in magnitude when converted to standard normal variates is to occur. Thus, this logical only impacts logic flow when snv
trapinfsnv
If true and presumably small, the numerical value of this argument is used to replace $u = 0$ and $v = 0$ with this value when conversion to standard normal variates is to occur. The setting of trapinfsnv only is used if snv is <
...
Additional arguments to pass to the points() function.

Value

  • An Rdata.frame of the simulated values is returned.

concept

  • conditional approach
  • Rosenblatt transform

References

Joe, H., 2015, Dependence modeling with copulas: Boca Raton, CRC Press, 462 p.

Nelsen, R.B., 2006, An introduction to copulas: New York, Springer, 269 p.

See Also

derCOPinv

Examples

Run this code
# The simCOP function is oft used in other Examples sections through this package.
simCOP(n=10, cop=W)            # Frechet lower bound copula
simCOP(n=10, cop=P)            # Independence copula
simCOP(n=10, cop=M, col=2)     # Frechet upper bound copula
simCOP(n=10, cop=PSP)          # The PSP copula
# Now simulate the PSP copula, add the level curves of the copula, and demonstrate
# the uniform distribution of marginals on the correct axes (U [top] and V [left]).
D <- simCOP(n=400, cop=PSP) # store simulated values in D
level.curvesCOP(cop=PSP, ploton=FALSE)
rug(D$U, side=3, col=2); rug(D$V, side=4, col=2)

# Now let us get more complicated and mix two Plackett copulas together using the
# composite2COP as a "compositor." The parameter argument becomes more complex, but
# is passed as shown into composite2COP.
para <- list(cop1=PLACKETTcop,cop2=PLACKETTcop, alpha=0.3,beta=0.5, para1=0.1,para2=50)
D <- simCOP(n=950, cop=composite2COP, para=para, col=rgb(0,0,0,0.2), pch=16, snv=TRUE)

Run the code above in your browser using DataLab