Learn R Programming

copBasic (version 1.5.1)

EMPIRsim: Simulate an Empirical Copula

Description

Perform a simulation on an empirical copula to simulate the variates $U$ and $V$ and return a data frame of them. This function is an empirical parallel to simCOP for parametric copulas. This behavior differs from that in EMPIRsimv, which a vector of $V$ from a fixed $u$ is generated.

For the situation in which an individual $u$ during the simulation loops is not a value on the grid, then the bounding conditional quantile functions are solved for each of the $n$ simulations and the following interpolation is made. $$v = \frac{v_1/w_1 + v_2/w_2}{1/w_1 + 1/w_2}$$ which states that that the weighted mean is computed. The values $v_1$ and $v_2$ are ordinates of the conditional quantile function at for the grid lines to the left and right of the $u$ value. The value $w_1$ $=$ $u - u^\mathrm{left}_\mathrm{grid}$, and the value $w_2$ $=$ $u^\mathrm{right}_\mathrm{grid} - u$.

Usage

EMPIRsim(n=100, empgrid=NULL, kumaraswamy=FALSE,
         ploton=TRUE, points=TRUE, ...)

Arguments

n
A sample size, default is 100;
empgrid
Gridded empirical copula from EMPIRgrid;
kumaraswamy
A logical to trigger Kumaraswamy smoothing of the conditional quantile function that is passed to EMPIRgridderinv;
ploton
A logical to toggle on the plot;
points
A logical to actually draw the simulations by points(); and
...
Additional arguments to pass to the points() function or to EMPIRgridderinv.

Value

  • A data frame of the simulated values is returned.

See Also

EMPIRgrid, EMPIRgridderinv, EMPIRsimv

Examples

Run this code
pdf("experiment.pdf")
nsim <- 5000
para <- list(alpha=.15, beta=.65,
             cop1=PLACKETTcop, cop2=PLACKETTcop, para1=.005, para2=1000)
set.seed(1)
uv <- simCOP(n=nsim, cop=composite2COP, para=para, pch=16, col=rgb(0,0,0,.2))
# set.seed(1) # try not resetting the seed
uv.grid <- EMPIRgrid(para=uv, deluv=.025)
tmp <- EMPIRsim(n=nsim, empgrid=uv.grid, kumaraswamy=FALSE,
                col=rgb(1,0,0,.1), pch=16)
tmp <- EMPIRsim(n=nsim, empgrid=uv.grid, kumaraswamy=TRUE,
                col=rgb(1,0,0,.1), pch=16)
dev.off()


# See examples under EMPIRsimv

Run the code above in your browser using DataLab