Extract a subset of variables from a Gaussian Copula distribution.

gcopSub(gCop, subset)

Arguments

gCop

A gaussCop object (see gcopFit).

subset

Integer or logical vector specifying which subset of variables to keep. Default is to keep all variables.

Value

A gaussCop object representing the marginal Gaussian Copula distribution on the subset of variables.

Examples

# simulate data n <- 5e4 X <- cbind(rnorm(n, mean = 1, sd = 3), rnorm(n, mean=4, sd = 0.5), rt(n, df = 10), rchisq(n, df = 5), rnorm(n, mean=10, sd = 10)) # fit Gaussian Copula using Kernel method gCop <- gcopFit(X, fitXD = "kernel")
#> Warning: Endpoint matching failed. mean/sd set to empirical estimates.
# subset gCop isub <- sample(5, 3) # subset gCop.sub <- gcopSub(gCop, subset = isub) # check that subsetted xDensity representations are the same for(ii in 1:3) { print(identical(gCop$XDens[[isub[ii]]], gCop.sub$XDens[[ii]])) }
#> [1] TRUE #> [1] TRUE #> [1] TRUE
# check that subsetted correlation matrix is the same print(identical(gCop$Rho[isub,isub], gCop.sub$Rho))
#> [1] TRUE