fit.BN: Fit a Bayesian Network model

Description Usage Arguments Details Value Examples

View source: R/fit.BN.R

Description

Finds copula models for each pair of response and predictor in some order, so that the pair is conditional on previous predictors.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
fit.BN(
  y,
  xdat,
  ymarg = identity,
  xmargs = identity,
  xord = NULL,
  cops = NULL,
  families = c("bvncop", "bvtcop", "mtcj", "gum", "frk", "joe", "bb1", "bb7", "bb8"),
  ...
)

Arguments

y

Vector of response observations.

xdat

Matrix of predictors. Columns are variables, rows are observations (that correspond with entries of y).

ymarg

Vectorized function of the cdf of the response.

xmargs

List of vectorized functions of the cdfs of the univariate predictors, in the order of the columns of xdat. Or, a single function if they're all the same.

xord

If you already know what order you want to pair the response and the predictors, put that order here as a vector of "column numbers".

cops

If you already know some of the copula models that you'd like to use corresponding to the variables in xord, put them here. Entries with NA will have a copula model chosen.

families

A vector of copula family names to try fitting (will also consider their rotations/reflections). Limited to those families available in VineCopula package, listed in BiCopSelect.

...

Other arguments to pass to VineCopula::BiCopSelect.

Details

This function first determines the order to pair up the response and predictors in the order of highest partial correlation (by using lm). Then the bivariate copula models are chosen and fitted individually using VineCopula::BiCopSelect.

By "pairing response and predictors in some order", I mean pairing (Y,X1), (Y,X2)|X1, (Y,X3)|(X1,X2), etc, though not necessarily in that order.

For the familyset argument, the default is almost all of the families available. It just doesn't include the Tawn copula families.

Value

A list with three entries:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Get some simulated data:
set.seed(6277)
p <- 5
A0 <- CopulaModel::Dvinearray(p)
copmat0 <- makeuppertri("frk", p-1, p, "")
cparmat0 <- makeuppertri(3, p-1, p)
dat <- fvinesim(100, A0, copmat0, cparmat0)
y <- dat[, 1]
xdat <- dat[, -1]

## Fit the model:
fit.BN(y, xdat)

vincenzocoia/copsupp documentation built on Aug. 23, 2020, 7:37 a.m.