R/gamVineStructureSelect.R
gamVineStructureSelect.Rd
This function select the structure and estimates the parameter(s) of a
Generalized Additive model
(GAM) Vine model, where GAMs for individual edges are specified either for
the copula parameter or Kendall's tau.
It solves the maximum penalized likelihood estimation for the copula families
supported in this package by reformulating each Newton-Raphson iteration as
a generalized ridge regression, which is solved using
the mgcv
package.
gamVineStructureSelect(
udata,
lin.covs = NULL,
smooth.covs = NULL,
simplified = TRUE,
type = 0,
familyset = NA,
rotations = TRUE,
familycrit = "AIC",
treecrit = "tau",
level = 0.05,
trunclevel = NA,
tau = TRUE,
method = "FS",
tol.rel = 0.001,
n.iters = 10,
parallel = FALSE,
verbose = FALSE,
select.once = TRUE
)
A matrix or data frame containing the data in [0,1]^d.
A matrix or data frame containing the parametric (i.e.,
linear) covariates (default: lin.covs = NULL
).
A matrix or data frame containing the non-parametric
(i.e., smooth) covariates (default: smooth.covs = NULL
).
If TRUE
(default), then a simplified vine is fitted
(which is possible only if there are exogenous covariates). If FALSE
,
then a non-simplified vine is fitted.
type = 0
(default) for a R-Vine and type = 1
for a
C-Vine.
An integer vector of pair-copula families to select from
(the independence copula MUST NOT be specified in this vector unless one
wants to fit an independence vine!).
Not listed copula families might be included to better handle
limit cases. If familyset = NA
(default), selection among all
possible families is performed. Coding of pair-copula families:
1
Gaussian,
2
Student t,
5
Frank,
301
Double Clayton type I (standard and rotated 90 degrees),
302
Double Clayton type II (standard and rotated 270 degrees),
303
Double Clayton type III (survival and rotated 90 degrees),
304
Double Clayton type IV (survival and rotated 270 degrees),
401
Double Gumbel type I (standard and rotated 90 degrees),
402
Double Gumbel type II (standard and rotated 270 degrees),
403
Double Gumbel type III (survival and rotated 90 degrees),
404
Double Gumbel type IV (survival and rotated 270 degrees).
If TRUE
, all rotations of the families in familyset
are included.
Character indicating the criterion for bivariate copula
selection. Possible choices: familycrit = 'AIC'
(default) or
'BIC'
, as in BiCopSelect
from the
VineCopula
package.
Character indicating how pairs are selected in each tree.
treecrit = "tau"
uses the maximum spanning tree of the Kendall's tau
(i.e., the tree of maximal overall dependence), treecrit = "rho"
uses the Spearman's rho.
Numerical; Passed to gamBiCopSelect
, it is the
significance level of the test for removing individual
predictors (default: level = 0.05
) for each conditional pair-copula.
Integer; level of truncation.
TRUE
(default) for a calibration function specified for
Kendall's tau or FALSE
for a calibration function specified
for the Copula parameter.
'NR'
for Newton-Raphson
and 'FS'
for Fisher-scoring (default).
Relative tolerance for 'FS'
/'NR'
algorithm.
Maximal number of iterations for
'FS'
/'NR'
algorithm.
TRUE
(default) for parallel selection of copula
family at each edge or FALSE
for the sequential version.
for the Copula parameter.
TRUE
if informations should be printed during the
estimation and FALSE
(default) for a silent version.
from mgcv
.
if TRUE
the GAM structure is only selected once,
for the family that appears first in familyset
.
gamVineSeqFit
returns a gamVine-class
object.
require(VineCopula)
set.seed(0)
## An example with a 3-dimensional GAM-Vine
# Sample size
n <- 1e3
# Define a R-vine tree structure matrix
d <- 3
Matrix <- c(2, 3, 1, 0, 3, 1, 0, 0, 1)
Matrix <- matrix(Matrix, d, d)
nnames <- paste("x", 1:d, sep = "")
# Copula families for each edge
fam <- c(301, 401, 1)
# Parameters for the first tree (two unconditional copulas)
par <- c(1, 2)
# Pre-allocate the GAM-Vine model list
count <- 1
model <- vector(mode = "list", length = d * (d - 1) / 2)
# The first tree contains only the two unconditional copulas
for (i in 1:(d - 1)) {
model[[count]] <- list(family = fam[count], par = par[count], par2 = 0)
count <- count + 1
}
# The second tree contains a unique conditional copula
# In this first example, we take a linear calibration function (10*x-5)
# Set-up a dummy dataset
tmp <- data.frame(u1 = runif(1e2), u2 = runif(1e2), x1 = runif(1e2))
# Set-up an arbitrary linear model for the calibration function
model[[count]] <- gamBiCopFit(tmp, ~x1, fam[count])$res
# Update the coefficients of the model
attr(model[[count]], "model")$coefficients <- c(-5, 10)
# Define gamVine object
GVC <- gamVine(Matrix = Matrix, model = model, names = nnames)
GVC
#> GAM-Vine matrix:
#> [,1] [,2] [,3]
#> [1,] 2 0 0
#> [2,] 3 3 0
#> [3,] 1 1 1
#>
#> Where
#> 1 <-> x1
#> 2 <-> x2
#> 3 <-> x3
#>
#> Tree 1:
#> x2,x1: Clayton type 1 (standard and 90 degrees rotated)
#> x3,x1: Gumbel type 1 (standard and 90 degrees rotated)
#>
#> Tree 2:
#> x2,x3|x1 : Gaussian copula with tau(z) = (exp(z)-1)/(exp(z)+1) where
#> z ~ x1
if (FALSE) { # \dontrun{
# Simulate new data
simData <- data.frame(gamVineSimulate(n, GVC))
colnames(simData) <- nnames
# Fit data using sequential estimation assuming true model known
summary(fitGVC <- gamVineSeqFit(simData, GVC))
# Fit data using structure selection and sequential estimation
summary(fitGVC2 <- gamVineStructureSelect(simData, simplified = FALSE))
} # }