gcopSub: Extract a subset of variables from a Gaussian Copula...

Description Usage Arguments Value Examples

View source: R/gcopSub.R

Description

Extract a subset of variables from a Gaussian Copula distribution.

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# 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")
# 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]]))
}
# check that subsetted correlation matrix is the same
print(identical(gCop$Rho[isub,isub], gCop.sub$Rho))

mlysy/GaussCop documentation built on Nov. 6, 2019, 6:19 p.m.