rgcopCond: Conditional simulation from a Gaussian Copula distribution.

Description Usage Arguments Value Examples

View source: R/rgcopCond.R

Description

Conditional simulation from a Gaussian Copula distribution.

Usage

1
rgcopCond(n, gCop, XCond, iCond)

Arguments

n

Integer number of random draws.

gCop

An object of class gaussCop describing the joint Gaussian Copula distribution on all variables.

XCond

Vector or matrix; values of the variables on which to condition.

iCond

Vector of logicals, or characters specifying which are the random variables on which to condition.

Value

An n x (nrv-nCond) matrix containing the draws from the conditional distribution.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
require(GaussCop)
#conditionally simulate data and plot it
n = 1e4
dat1 = rnorm(n, mean = 1, sd = 3)
dat = cbind(dat1,
            rnorm(n, mean = dat1, sd = 2),
            rnorm(n, mean=dat1, sd = 10))

plot(dat[, c(2, 3)]) # plot a subset of the data

# fit Gaussian Copula using gc4 method
temp.cop = gcopFit(X = dat, fitXD = "gc4")

# simulate data from Copula model and add it to plot, should blend in
new.data = rgcopCond(n, gCop = temp.cop, XCond = as.matrix(dat1), iCond = !c(FALSE, TRUE, TRUE))
points(new.data, cex = 0.5, col="red") # plot points from subsetted copula

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