Learn R Programming

PCBN (version 0.1.1)

default_envir: Fits the copula joining w and v given cond_set abiding by the conditional independencies of the graph

Description

Fits the copula joining w and v given cond_set abiding by the conditional independencies of the graph

Usage

default_envir()

BiCopCondFit( data, DAG, v, w, cond_set, familyset, order_hash, e, verbose = 1, method )

ComputeCondMargin( data, DAG, v, cond_set, familyset, order_hash, e, verbose = 1, method = method )

Value

default_envir returns an environment to be passed to BiCopCondFit or to ComputeCondMargin. BiCopCondFit

returns the fitted copula object of v, w given cond_set. ComputeCondMargin returns the fitted conditional margins of v

given cond_set.

Both functions store all intermediary results in e to save computation time.

Arguments

data

data frame

DAG

Directed Acylic Graph

v, w

nodes of the graph

cond_set

vector of nodes of DAG. They should all be parents of v. They should be ordered from the smallest to the biggest.

familyset

vector of copula families

order_hash

hashmap of parental orders

e

environment containing all the hashmaps

verbose

if 0, don't print anything. If verbose >= 1, print information about the fitting procedure.

method

indicates the estimation method ("mle" for maximum likelihood estimation or "itau" of inversion of Kendall's tau)

Examples

Run this code

DAG = create_empty_DAG(3)
DAG = bnlearn::set.arc(DAG, 'U1', 'U3')
DAG = bnlearn::set.arc(DAG, 'U2', 'U3')

order_hash = r2r::hashmap()
order_hash[['U3']] = c("U1", "U2")

fam = matrix(c(0, 0, 1,
               0, 0, 1,
               0, 0, 0), byrow = TRUE, ncol = 3)

tau = 0.2 * fam

my_PCBN = new_PCBN(
  DAG, order_hash,
  copula_mat = list(tau = tau, fam = fam))

mydata = PCBN_sim(my_PCBN, N = 5)
e = default_envir()
ls(e)
C_13 = BiCopCondFit(data = mydata, DAG = DAG, v = "U1", w = "U3",
                    cond_set = c(), familyset = 1, order_hash = order_hash,
                    e = e, method = "mle")

C_23_1 = BiCopCondFit(data = mydata, DAG = DAG, v = "U2", w = "U3",
                      cond_set = "U1", familyset = 1, order_hash = order_hash,
                      e = e, method = "itau")

U_2_13 = ComputeCondMargin(data = mydata, DAG = DAG,
                           v = "U2", cond_set = c("U1", "U3"),
                           familyset = 1, order_hash = order_hash, e = e,
                           method = "mle")

Run the code above in your browser using DataLab