Density, distribution function and random generation for the vine copula distribution.
Usage
dvinecop(
u,
vinecop,
cores = 1,
keep_all = FALSE,
parameters = NULL,
log = FALSE
)
scores(u, vinecop, ...)
# S3 method for class 'vinecop_dist'
scores(u, vinecop, step_wise = TRUE, cores = 1, parameters = NULL, ...)
hessian(u, vinecop, ...)
# S3 method for class 'vinecop_dist'
hessian(u, vinecop, step_wise = TRUE, cores = 1, parameters = NULL, ...)
pvinecop(u, vinecop, n_mc = 10^4, cores = 1)
rvinecop(
n,
vinecop,
qrng = FALSE,
cores = 1,
u_cond = NULL,
conditioning_set = NULL
)Arguments
- u
matrix of evaluation points; must contain at least d columns, where d is the number of variables in the vine. More columns are required for discrete models, see Details.
- vinecop
an object of class
"vinecop_dist".- cores
number of cores to use; if larger than one, computations are done in parallel on
coresbatches .- keep_all
if
TRUE,dvinecop()returns additional intermediate quantities computed during density evaluation.- parameters
optional observation-specific parameters for
dvinecop(),scores(), andhessian(). For a model with one parameter, this may be a vector with one entry per observation. Otherwise, it must be a matrix with one row per observation and one column per model parameter. For vine copulas, columns follow the(tree, edge, parameter)order ofscores(). Parameters are not recycled. Only continuous parametric models are supported.- log
if
TRUE,dvinecop()returns the log-density instead of the density. A vine density is a product of one factor per edge, so it underflows to0in high dimensions or under strong dependence while its logarithm is still an ordinary double;log = TRUEaccumulates in log space and is the accurate way to obtain it. Ignored whenkeep_all = TRUE, which reports both.- ...
unused.
- step_wise
if
FALSE, the score/Hessian is computed for the full likelihood; ifTRUE, gradients are computed per pair-copula as in step-wise estimation.- n_mc
number of samples used for quasi Monte Carlo integration.
- n
number of observations.
- qrng
if
TRUE, generates quasi-random numbers using the multivariate Generalized Halton sequence up to dimension 300 and the Generalized Sobol sequence in higher dimensions (defaultqrng = FALSE).- u_cond
optional conditioning values for
rvinecop(). A vector or one-row matrix is repeatedntimes; alternatively, supply ann-row matrix for observation-specific conditioning values. The first block holds the copula-scale values \(F(x)\). The expanded layout appends one left-limit column \(F(x^-)\) per conditioning variable in the same order; columns for continuous variables equal their value columns. In the compact layout, the redundant columns for continuous variables are omitted. IfNULL,rvinecop()performs unconditional simulation.- conditioning_set
variable indices or names corresponding to the first block of
u_cond. WhenNULL, the columns ofu_condcorrespond to the last variables of the current vine order. When supplied, the model is transiently reoriented and is not modified.
Value
dvinecop() gives the density, pvinecop() gives the distribution function,
rvinecop() generates unconditional or conditional random deviates,
scores() gives the observation-wise score matrix, and hessian() gives the
average Hessian matrix.
If keep_all = TRUE, dvinecop() returns a list with entries pdf,
logpdf, pdf_edges, hfunc1, hfunc2, hfunc1_sub, and hfunc2_sub.
The _sub
entries contain h-functions evaluated at left-sided limits when the model
contains discrete variables; they are empty for fully continuous models.
The length of the result is determined by n for rvinecop(), and
the number of rows in u for the other functions.
The vinecop object is recycled to the length of the
result.
Details
See vinecop() for the estimation and construction of vine copula
models.
The copula density is defined as joint density divided by marginal densities, irrespective of variable types.
Discrete variables
When at least one variable is discrete, two types of
"observations" are required in u: the first \(n \; x \; d\) block
contains realizations of \(F_{X_j}(X_j)\). The second \(n \; x \; d\)
block contains realizations of \(F_{X_j}(X_j^-)\). The minus indicates a
left-sided limit of the cdf. For, e.g., an integer-valued variable, it holds
\(F_{X_j}(X_j^-) = F_{X_j}(X_j - 1)\). For continuous variables the left
limit and the cdf itself coincide. Respective columns can be omitted in the
second block.
Examples
## simulate dummy data
x <- rnorm(30) * matrix(1, 30, 5) + 0.5 * matrix(rnorm(30 * 5), 30, 5)
u <- pseudo_obs(x)
## fit a model
vc <- vinecop(u, family_set = "clayton")
# simulate from the model
u <- rvinecop(100, vc)
pairs(u)
# evaluate the density and cdf
dvinecop(u[1, ], vc)
#> [1] 4115.68
pvinecop(u[1, ], vc)
#> [1] 0.0664
# evaluate derivatives of the log-likelihood
scores(u, vc)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.260346067 0.1759036931 0.154398563 0.129105254 0.184412469
#> [2,] -0.169966127 0.1427862033 0.077558463 0.164293905 -0.215380477
#> [3,] 0.161242106 0.1176481225 0.118840133 0.090517411 -1.091123675
#> [4,] 0.008956368 -0.2378654607 -0.020568648 0.106993409 -0.189024658
#> [5,] -0.084913679 0.0725536035 0.135725902 0.201783368 -0.002224342
#> [6,] -0.170427543 -0.0702656252 0.284876442 0.270813786 0.648272777
#> [7,] 0.092260039 0.0007298912 0.112823843 0.003887122 -0.336573220
#> [8,] 0.104815720 -0.0653057589 -0.502663738 0.133068303 0.309765933
#> [9,] -0.276026335 0.1583688252 -0.519026874 0.227889833 -0.305498445
#> [10,] -0.018290840 -0.0419218150 -0.906938821 0.119032318 -0.739128736
#> [11,] 0.099834076 0.0311785050 0.124282453 0.122714229 -0.296796475
#> [12,] 0.138110865 0.1361351782 0.202804436 0.168568124 -0.074133285
#> [13,] 0.100618816 0.0859641463 0.026789793 0.112159967 0.265866079
#> [14,] -0.071971628 0.0784028389 0.116066886 0.092320485 -0.320418388
#> [15,] 0.212299777 0.2038491796 0.271970395 -0.204611103 0.101216598
#> [16,] 0.113078367 0.0986887899 0.124248034 0.041445531 0.126181431
#> [17,] 0.220837492 0.2044568726 0.126617315 -0.029060282 0.195866385
#> [18,] 0.129422256 0.1068495286 -0.007217833 0.118952021 0.487225053
#> [19,] -0.243794875 -0.0315657647 0.316128953 0.270999629 0.402564419
#> [20,] 0.005745796 0.1958884818 -0.622076336 0.114269329 -0.226934296
#> [21,] 0.126939098 0.1306231711 -0.367504680 0.182597039 0.255814547
#> [22,] -0.155228761 0.1520373590 -0.442197212 0.102328789 0.215110744
#> [23,] 0.169707724 0.1136651263 -0.215753134 0.017038598 0.040372949
#> [24,] 0.058976383 0.0795956102 0.197022671 0.252069222 0.413282403
#> [25,] 0.176327948 0.1099270390 0.268526160 0.253423262 -0.123977482
#> [26,] -0.122178031 0.0518946423 0.171504914 0.160098374 0.295403092
#> [27,] -0.122080642 -0.2626775403 0.094876457 0.094583712 0.431006724
#> [28,] 0.171369578 0.0696976743 0.222310368 0.033997995 0.268482818
#> [29,] 0.226630515 0.1929878589 0.019302176 -0.374716336 0.064492416
#> [30,] -0.253589318 -0.2297456525 -0.608229570 -0.699365397 -1.648797939
#> [31,] 0.131818894 0.1696095436 -0.020043301 0.056050839 0.040976971
#> [32,] 0.263174038 0.2072158302 0.306480212 -0.152244475 0.183555091
#> [33,] -0.248543971 -0.2580301193 0.126025764 0.062777825 1.039232214
#> [34,] -0.037718408 -0.0118564845 0.130380135 -0.277105853 0.038682441
#> [35,] 0.059395563 0.1877449503 0.303604966 -0.053306703 0.166964958
#> [36,] 0.169434872 0.1987538766 -0.555733446 -0.177383458 0.162872313
#> [37,] -0.013645308 0.1394836727 0.267804553 0.188363443 0.278521524
#> [38,] -0.079367563 -0.0815931331 0.131825868 0.031663639 0.268578010
#> [39,] 0.125396432 -0.1211223380 0.300486716 -0.577960468 -0.465726986
#> [40,] 0.134562009 0.0997061090 0.182632002 0.156654688 0.977129963
#> [41,] -0.252986171 -0.0508652563 0.068029447 -0.460230225 0.325679516
#> [42,] 0.116799509 0.0934812765 0.151896277 0.136670492 0.365245326
#> [43,] 0.158962081 -0.2913041628 0.115537293 -0.146143870 -1.116784122
#> [44,] -0.160092955 0.1194847580 0.120140493 0.185730917 -0.144527223
#> [45,] -0.044069230 -0.0952979131 0.069966512 0.120384836 0.615888419
#> [46,] 0.138566623 0.0779627331 0.156072572 -0.036672003 0.357226704
#> [47,] 0.102567910 0.0714065204 0.087929203 -0.186735472 0.035845719
#> [48,] 0.079852209 0.0691890627 0.076559494 0.011606656 0.183045197
#> [49,] 0.158848829 0.0947321027 0.048778378 0.101490329 0.236400497
#> [50,] 0.081787613 0.1092167128 0.080278576 -0.539322404 0.121999668
#> [51,] -0.060439552 0.0776762592 0.103857666 0.035626915 0.215522864
#> [52,] 0.075930439 0.1262364894 -0.106435019 -0.365332231 0.005722856
#> [53,] 0.265296573 0.1081669812 0.298037512 -0.288557402 0.070610813
#> [54,] 0.153853908 0.0547152288 0.110865076 0.189807948 0.245664074
#> [55,] -0.559270531 0.2082709375 0.111206232 0.069009575 -1.485021432
#> [56,] 0.265997567 0.1944755738 0.186368469 0.102701770 0.174617593
#> [57,] 0.147069830 0.1430912715 0.013147992 0.061905649 0.059140643
#> [58,] -0.330944082 -0.1020979967 0.030251170 -0.042367874 0.418604912
#> [59,] 0.172673533 -0.1162846033 0.281444301 -1.247468225 0.270862025
#> [60,] 0.198416762 0.0097561465 0.266002837 -0.525809788 0.203555979
#> [61,] -0.463781094 -0.0405609353 0.048418150 -0.112508529 0.385609137
#> [62,] -0.094089194 0.1791752925 0.037909685 0.133577053 -0.253433583
#> [63,] -0.018536319 0.0587946294 -0.001642709 0.168857485 0.169572740
#> [64,] 0.162777286 0.1984019287 0.151748670 -0.353656708 0.093971213
#> [65,] -0.074797602 0.1142767026 0.101264816 0.080625148 -0.338949593
#> [66,] 0.069983111 0.0343494589 0.053578431 -0.216943671 0.398280462
#> [67,] 0.178145853 0.1340214117 -0.056612517 -0.267103067 0.104349480
#> [68,] 0.082016348 -0.6628978534 0.243626597 0.029855914 -1.568663107
#> [69,] -0.772884141 -0.1463134998 -1.516352964 0.237551896 0.415190310
#> [70,] -0.145824547 0.0870850983 -0.089749057 0.161592079 0.284205124
#> [71,] -0.386132613 -0.4292576252 0.081085663 0.062392588 1.002587292
#> [72,] 0.153505214 0.1087290321 -0.036209241 0.225260969 0.229781639
#> [73,] 0.173355366 0.1645503931 0.132016631 -0.095795142 0.156071554
#> [74,] 0.250331603 0.0697130867 0.252183223 -0.171047697 -0.011234210
#> [75,] 0.196360073 0.1079199214 0.169060898 -0.057696182 0.182009691
#> [76,] 0.040736129 -0.2099373898 -0.233307186 0.100630180 0.244109787
#> [77,] -0.279152955 0.1249954037 0.007714174 -0.789651361 0.294033765
#> [78,] 0.260699336 -0.0714744173 0.264589682 0.217517874 -0.446402062
#> [79,] -0.293996036 -0.1796550081 0.085019555 -0.054850050 0.803428128
#> [80,] 0.058454792 0.0565952271 -0.083705118 -0.504243904 -0.535693933
#> [81,] -0.619659356 0.0300223816 -0.861044902 0.071771885 -0.784054895
#> [82,] -0.108323716 0.1164757954 0.116735745 0.094000721 -0.076316193
#> [83,] -0.524206876 0.0743958322 -0.112789893 -0.287896067 -0.536632081
#> [84,] -0.022969464 0.0292675684 0.216009009 0.272439520 -0.721355072
#> [85,] 0.078739836 0.0594472988 0.061385552 -0.069129501 0.180020043
#> [86,] -0.600882808 -0.2086738690 0.303377331 -0.444489584 0.610986318
#> [87,] 0.035206434 0.1178604231 0.242650377 -0.889747667 -0.464307696
#> [88,] -0.856877011 0.1239478424 0.296629718 0.228066799 -2.948839856
#> [89,] -0.187992898 0.1396627399 0.159755163 0.264763890 0.067622984
#> [90,] -0.129827833 0.1519334487 0.143676514 -0.461334848 0.225049070
#> [91,] -0.065422204 0.0188416300 0.021386743 0.096242148 0.502111497
#> [92,] -0.049093669 -0.0453025962 -0.180131753 -0.046482858 -0.873430319
#> [93,] 0.113443789 -0.0195646149 0.172476843 0.241564077 -0.234325218
#> [94,] 0.100258779 0.0703086569 -0.200385357 0.015303832 0.125329744
#> [95,] 0.090937309 -0.4748624056 0.044267021 -0.032630899 0.188090918
#> [96,] -0.520693435 0.1855778089 0.061158711 -0.426222048 -0.226248696
#> [97,] 0.033977064 0.1639344871 -0.120505217 0.166222562 0.189638775
#> [98,] 0.247042363 0.1552563562 0.261829885 -0.136620756 0.202088472
#> [99,] 0.197817197 0.1999116512 0.266110596 0.246798951 0.165040312
#> [100,] -0.368374960 -0.2121016077 -0.008917636 -0.059662354 0.841989436
#> [,6] [,7] [,8] [,9] [,10]
#> [1,] 0.062384377 0.27218784 -0.04154252 0.034225691 0.09919803
#> [2,] 0.405964379 -0.24807463 -0.69090970 -0.362694358 0.45783403
#> [3,] 0.082730527 0.15616897 0.22574017 -0.093695955 0.11722755
#> [4,] 0.513311001 0.29990992 0.23868034 0.380260110 0.18554041
#> [5,] 4.371769226 0.34936307 -0.65783972 -0.435158458 0.84016499
#> [6,] 0.174291568 0.14861095 0.18392638 0.123644899 0.19311684
#> [7,] 0.161913386 -0.41739242 0.28769673 -0.357342704 -0.55975321
#> [8,] 0.967374730 -0.92479548 -0.35564949 -0.222314547 0.24672775
#> [9,] 0.552400749 0.22294122 2.17741466 0.184129327 -0.17280055
#> [10,] 0.554446355 0.40532830 -3.85957861 0.315838929 -0.22319263
#> [11,] -0.228386584 0.34292178 -0.37045004 0.512291855 0.66582434
#> [12,] 0.840467657 0.64441603 -0.13411197 -0.493736894 0.38005098
#> [13,] 0.039800446 0.26766114 -0.14683252 0.001508467 0.05237001
#> [14,] 0.016560169 0.32287587 -0.69902398 0.323673947 0.91109567
#> [15,] 0.111978512 0.29164848 0.18754884 -0.557248531 0.29547677
#> [16,] 0.090247251 0.07369171 0.20269805 0.029554678 -0.21832073
#> [17,] -0.045410752 -0.67993401 0.24955553 0.425231339 -0.25950315
#> [18,] -0.220281278 0.07191361 -0.04981022 -0.039950441 0.20402795
#> [19,] -0.234329011 0.15088710 -0.11637971 -0.026878020 -1.01062477
#> [20,] -0.779218166 -1.43246456 0.59726312 0.303164545 -0.30459724
#> [21,] 0.102748857 -0.94145211 -0.42855737 0.060723815 0.28665562
#> [22,] -0.358529676 -1.15551287 -1.40577760 0.211738768 0.05052755
#> [23,] 0.117683970 -1.32850668 0.34188495 0.082083042 -0.92490928
#> [24,] -0.024497795 -0.05113934 0.25873123 0.313879873 0.11061914
#> [25,] 0.039925416 0.09505829 0.13240180 -0.043372752 0.13521471
#> [26,] 0.033622354 0.08871117 -0.23201766 -0.101532972 -0.26989209
#> [27,] 0.138944207 0.40303237 0.14863037 0.567868480 0.17656232
#> [28,] 0.385745073 0.15435981 0.10296593 0.521745009 0.03956806
#> [29,] -0.197403956 1.34065890 -0.22503462 -1.150815279 -0.71112419
#> [30,] 0.811399832 0.72429179 2.75550105 0.899026329 1.34979438
#> [31,] -0.025320507 0.51318883 0.35663991 -0.081413977 0.26656570
#> [32,] 0.206838309 -0.04445215 0.14533585 0.368432763 -0.10024423
#> [33,] -0.528688652 0.09964064 0.38393880 0.075900723 0.20946270
#> [34,] -0.067781989 -1.30501569 0.38704092 -1.323608314 0.61381225
#> [35,] 0.201388202 -0.12932036 0.11111936 0.463172241 -0.55283226
#> [36,] -1.136332509 1.45005573 0.37826344 -0.226687032 0.22240525
#> [37,] 0.358045273 0.02589022 -0.10428269 -0.351774731 0.36048224
#> [38,] -0.614560469 0.22537065 0.21610194 -1.066751943 0.33846116
#> [39,] -0.243162899 -0.28400543 0.01572931 -0.943245410 -1.99033432
#> [40,] 0.167250990 0.67377393 0.37092991 0.008226949 -0.94758485
#> [41,] 0.307631838 -0.26919061 -0.68206410 2.061160442 -1.71540580
#> [42,] -0.120744503 0.29707512 0.35238911 0.099543496 0.05130241
#> [43,] -1.185359658 -0.31778284 -0.86967717 -0.938264420 -1.29237120
#> [44,] 0.377021841 0.16081586 -0.40115815 0.154135117 0.09442770
#> [45,] 0.411375919 0.22916847 0.02529999 0.323880289 0.11543515
#> [46,] 0.549835573 0.32489193 -0.26560303 0.571255098 -0.25009473
#> [47,] -0.062407342 -0.95994239 -0.06208574 0.494606172 0.45614531
#> [48,] -0.097401265 0.36087207 0.08644554 -0.213904586 -0.03705841
#> [49,] -0.873323632 0.30561398 -0.17072924 -0.844159521 -0.02599550
#> [50,] 0.144251891 -2.11740304 -0.17825829 -0.715870991 0.45964223
#> [51,] 0.117900129 -0.08472818 -0.28775708 -0.082765618 0.64589587
#> [52,] 0.120286409 -2.02021793 -0.97771583 -0.414388503 0.53662547
#> [53,] 0.198917885 -0.25038356 0.11797402 0.673519031 0.08394986
#> [54,] 0.463814580 0.16065458 0.04583839 0.183714854 0.17036755
#> [55,] -0.032641642 0.76727964 0.41838942 -0.298541421 0.48407445
#> [56,] 0.006344596 -0.39286402 0.11484352 0.403959582 0.20387796
#> [57,] -0.520491403 0.56464330 0.18391431 -0.857301890 0.18611827
#> [58,] -0.774559983 0.38685834 1.07964719 -0.757655466 0.49754179
#> [59,] -0.242295966 -3.11951238 0.15844205 6.166444782 -0.31854842
#> [60,] 0.129187141 -0.21585849 0.14225865 -2.488641589 -0.12308833
#> [61,] 0.283852973 -0.61876541 -1.52364560 -0.573974156 1.87853617
#> [62,] -0.084943194 0.19327281 0.42635321 0.049403044 0.20031951
#> [63,] 0.358695641 -0.17569013 -0.40399948 -0.022516345 0.62557092
#> [64,] 0.053191216 0.47972883 0.26374394 -0.785589238 0.31977736
#> [65,] -0.334438082 0.02774328 -0.05647115 -0.008769684 -0.47381894
#> [66,] 0.389844182 0.48000776 -0.02278672 0.672978972 -2.07180626
#> [67,] -0.503505316 0.64847126 -0.12140100 -0.858537611 -0.41152631
#> [68,] 0.455770920 -0.16971720 0.10658325 -1.111252233 -1.07022506
#> [69,] -1.640322653 0.19521851 1.79772330 -0.446441095 0.12088576
#> [70,] 0.586977741 -0.46691345 -1.16975596 -0.598122214 0.46700614
#> [71,] -0.714602399 0.13085821 0.31531675 0.119900476 0.18744157
#> [72,] -0.140827396 -0.22572873 0.06156953 0.090502655 0.09680239
#> [73,] 0.170408260 0.31351666 -0.14399084 0.179195759 -0.31713650
#> [74,] 0.250022392 -0.08953377 0.12116976 0.669933710 0.28893455
#> [75,] 0.133042185 0.08265740 0.14257072 -0.813944461 -0.05936317
#> [76,] 1.445601151 -0.87387598 -0.04408185 -0.769032983 0.31372590
#> [77,] 0.156951497 -1.30907163 -1.35149556 -0.022135949 1.90730554
#> [78,] 0.472528976 0.15321871 0.27459315 0.334841206 0.06960240
#> [79,] -0.315472388 0.05430822 0.40387487 -0.662096102 0.39545291
#> [80,] 0.303072800 0.34682179 0.61838847 0.014116648 0.56970799
#> [81,] 0.685157675 0.46617162 3.46847710 0.461259070 0.03051158
#> [82,] 0.029920161 0.16007492 0.30361940 -0.089411911 0.31017647
#> [83,] 0.318701913 0.62810507 0.38592397 0.403398422 1.72145974
#> [84,] 0.089277229 0.10666648 0.23413085 -0.090798588 0.12581936
#> [85,] 0.221029898 0.16648316 0.12017330 0.123142944 -0.03376883
#> [86,] 0.241792817 -0.38612592 0.11627899 -2.561047407 0.58208374
#> [87,] 0.081544574 -0.90725137 0.20977994 0.520922036 0.57382608
#> [88,] 0.041209184 0.01614934 0.04470288 -0.053455836 -0.14330521
#> [89,] 0.477489888 0.05656066 -0.65134982 -0.023714542 0.26634175
#> [90,] 0.029536481 0.35840528 0.66265715 0.009360588 0.90238952
#> [91,] -0.358218498 -0.22495467 0.36954966 0.511415009 -0.10993375
#> [92,] 0.603076487 -1.30077804 0.53168032 -0.432085397 -1.33164557
#> [93,] -0.405730911 0.09066970 -0.44287179 -0.020930189 0.23463333
#> [94,] 0.153334628 -0.92966638 -0.02754347 -0.230210289 0.10436031
#> [95,] -2.067183490 -0.88813295 -0.31781175 4.268735674 0.21346410
#> [96,] -0.168977466 -1.08813425 -2.54511040 0.594353915 0.86949799
#> [97,] 0.093155073 0.29805850 0.67407105 0.047137410 0.19601496
#> [98,] 0.011523701 0.21344321 0.13741183 -0.026151562 -0.02363473
#> [99,] 0.211144790 0.13295668 0.04751989 0.019725826 0.20759863
#> [100,] -0.481513584 -0.78646935 0.41262837 0.834687478 -1.01577226
hessian(u, vc)
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,] -0.06212618 0.00000000 0.00000000 0.00000000 -0.04765887 0.000000000
#> [2,] 0.00000000 -0.04042889 0.00000000 0.00000000 -0.01622551 -0.006129733
#> [3,] 0.00000000 0.00000000 -0.07293467 0.00000000 0.00000000 -0.021502487
#> [4,] 0.00000000 0.00000000 0.00000000 -0.06347838 0.00000000 0.000000000
#> [5,] 0.00000000 0.00000000 0.00000000 0.00000000 -0.30664832 0.000000000
#> [6,] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 -0.809269417
#> [7,] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.000000000
#> [8,] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.000000000
#> [9,] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.000000000
#> [10,] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.000000000
#> [,7] [,8] [,9] [,10]
#> [1,] 0.00000000 -0.017433724 0.000000000 -0.0179897831
#> [2,] 0.00000000 -0.001839439 0.027137639 -0.0072151259
#> [3,] -0.03170547 -0.032823107 0.005679447 0.0016162896
#> [4,] -0.07104446 0.000000000 -0.008553580 -0.0173925179
#> [5,] 0.00000000 -0.033865449 0.000000000 -0.0163640011
#> [6,] 0.00000000 0.011513934 0.212713370 0.0086718341
#> [7,] -0.62889327 0.000000000 0.062095509 -0.0002251028
#> [8,] 0.00000000 -0.624597079 0.000000000 -0.0128320717
#> [9,] 0.00000000 0.000000000 -1.504735187 0.0350299775
#> [10,] 0.00000000 0.000000000 0.000000000 -0.4187516774
# derivatives can also be computed for the full likelihood
scores(u, vc, step_wise = FALSE)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.248769293 0.1642623830 0.154488880 0.111030314 0.10656470
#> [2,] -0.294299089 0.2150876366 0.010757125 0.160263988 -0.22128306
#> [3,] 0.249062634 -0.0574708586 0.071077314 0.108628053 -1.08971057
#> [4,] 0.161844210 -0.3347756375 0.004437159 0.107036857 -0.13749163
#> [5,] -0.036171601 0.0744644266 0.106904531 0.175604600 0.02808728
#> [6,] -0.020112143 0.0648868264 0.292264674 0.258857349 0.63670486
#> [7,] 0.009506394 -0.0288268718 0.108010003 -0.066773017 -0.39862339
#> [8,] 0.081868943 0.0174600889 -0.526345881 0.143581189 0.42651057
#> [9,] -0.140772563 0.0994154675 -0.243482615 0.303048209 -0.21510108
#> [10,] -0.027776844 0.0459666389 -1.259839695 0.062090100 -0.75533595
#> [11,] 0.055270755 0.0100277627 0.127862391 0.096946294 -0.26788466
#> [12,] -0.006626407 0.1464133821 0.183172601 0.161523804 0.13356619
#> [13,] 0.113543497 0.0658068705 -0.016663590 0.111632355 0.25575682
#> [14,] -0.118807223 0.0918133411 0.129126940 0.058995772 -0.33120324
#> [15,] 0.211734284 0.2029240319 0.293918698 -0.202691246 0.17206095
#> [16,] 0.134461996 0.0852569306 0.105460989 0.036345851 0.07977206
#> [17,] 0.170229572 0.2167047674 0.086159603 -0.145518264 0.16640041
#> [18,] 0.076269633 0.0999162598 -0.051254409 0.114877362 0.49164321
#> [19,] -0.435681852 0.0026260756 0.265402985 0.288231600 0.57302326
#> [20,] -0.143760258 0.2085110158 -0.833995316 0.163935624 -0.23371418
#> [21,] 0.098136265 0.1740807910 -0.436153653 0.178512359 0.33326580
#> [22,] -0.326123490 0.1995398236 -0.490573456 0.061043123 0.30306724
#> [23,] 0.134776239 0.1145405153 -0.339407015 0.013678492 -0.08617301
#> [24,] 0.127043408 0.1267549284 0.181994034 0.219322038 0.40888657
#> [25,] 0.090000206 0.0868721093 0.292590124 0.232212770 -0.11681229
#> [26,] -0.233077398 0.0904055302 0.158925482 0.167297715 0.40022584
#> [27,] 0.085082775 -0.2965801940 0.102263610 0.093198711 0.48083101
#> [28,] 0.188300142 0.0854000193 0.231297942 0.004742651 0.31712696
#> [29,] 0.192640223 0.1300403544 0.071443454 -0.326173305 0.02079759
#> [30,] 0.092619841 -0.3246294044 -0.486721580 -0.531818038 -0.44784885
#> [31,] 0.119482908 0.1695539472 0.001429897 0.098789103 0.11030080
#> [32,] 0.234868160 0.2092754454 0.327033460 -0.232014407 0.14576648
#> [33,] -0.071200807 -0.1588135201 0.133075925 0.067978568 0.96292614
#> [34,] -0.049704528 0.0450328850 0.133455680 -0.363732237 0.05626038
#> [35,] -0.051838114 0.2372126300 0.328580546 -0.195649332 0.13031963
#> [36,] 0.195837538 0.2030426292 -0.526087629 0.001474029 0.22921086
#> [37,] -0.028423901 0.2073756308 0.258293539 0.190367303 0.28486074
#> [38,] 0.009584655 -0.0711172706 0.123922062 0.038659282 0.21198699
#> [39,] -0.122202523 -0.1766840140 0.352506448 -0.924197233 -0.61991845
#> [40,] 0.096785760 0.0374768117 0.166243058 0.201486332 1.11112225
#> [41,] -0.568697404 0.0222883990 0.143348468 -0.520971780 0.56263208
#> [42,] 0.087377932 0.0406687450 0.140379666 0.155279552 0.36067606
#> [43,] 0.294219311 -0.7182394241 0.165039780 -0.234777462 -2.40790848
#> [44,] -0.265648824 0.2009890761 0.089803316 0.175042616 -0.15702255
#> [45,] 0.034843441 -0.0462540969 0.055279990 0.120080895 0.64014246
#> [46,] 0.116983400 0.1465471079 0.155819334 -0.124859609 0.41714014
#> [47,] 0.121805770 0.0409878015 0.056240414 -0.249844340 0.06850850
#> [48,] 0.133148567 0.0627965479 0.053408247 0.001349139 0.13987819
#> [49,] 0.195539891 0.0174205102 -0.028063798 0.109230769 0.22401117
#> [50,] 0.083249292 0.0997147666 0.031936635 -0.678429366 0.14518520
#> [51,] -0.046393663 0.1054270547 0.086385895 0.041205811 0.21403113
#> [52,] 0.063420806 0.1097820949 -0.238403320 -0.487707328 -0.01483597
#> [53,] 0.252199501 0.1033989789 0.300477356 -0.353452147 0.18412305
#> [54,] 0.181608029 0.0495397974 0.107054969 0.191126929 0.26238937
#> [55,] -1.125974543 0.2505647914 0.162914792 0.122027011 -1.47309674
#> [56,] 0.264960851 0.1849504314 0.153528257 0.068799813 0.17386732
#> [57,] 0.011192812 0.1710690047 -0.021697254 0.061653794 0.32727067
#> [58,] -0.201669790 -0.1035556077 0.119860052 0.103302708 0.33430464
#> [59,] 0.151610844 -0.1112341936 0.269809040 -1.469229929 0.44879014
#> [60,] 0.378167337 -0.1114846245 0.260264210 -0.569483326 0.02532745
#> [61,] -0.377543214 -0.0006253757 0.008424373 -0.048565440 0.34348225
#> [62,] -0.204845534 0.2003201846 0.033140059 0.161848293 -0.23094952
#> [63,] 0.041680483 0.0809556598 -0.046650132 0.156945959 0.14090387
#> [64,] 0.165813817 0.1997654883 0.218223819 -0.343699983 0.17214583
#> [65,] -0.272121792 0.2333822103 0.123946273 0.019562413 -0.54430405
#> [66,] 0.050500366 0.0872322897 0.017363314 -0.294211401 0.53145664
#> [67,] 0.149416555 0.0914322624 0.022111787 -0.256744282 0.03884240
#> [68,] 0.655574641 -1.5053122469 0.228985394 -0.013571705 -2.64482778
#> [69,] 0.026360584 -0.1638894078 -1.411429162 0.272509603 0.08076962
#> [70,] -0.217224216 0.2157036267 -0.206442619 0.149267624 0.27194739
#> [71,] 0.037404322 -0.3952189917 0.082625527 0.070467634 0.84274348
#> [72,] 0.182986380 0.1014914043 -0.053073754 0.217981731 0.18676028
#> [73,] 0.154311634 0.1578278817 0.122625702 -0.168571356 0.07358832
#> [74,] 0.250302172 0.0408160129 0.251987780 -0.183224998 0.11091981
#> [75,] 0.240553995 0.0581933518 0.179854964 -0.073137528 0.11447051
#> [76,] 0.090861764 -0.1572630993 -0.267569287 0.110119865 0.23635569
#> [77,] -0.027355052 0.1472056377 -0.069392337 -0.573320596 0.16231454
#> [78,] 0.284773821 -0.2766993020 0.272008147 0.256783265 -0.52227444
#> [79,] -0.187746813 0.0018333520 0.106242528 -0.049061228 0.77811294
#> [80,] 0.068065141 0.0205635268 0.063797699 -0.498879082 -0.45922667
#> [81,] -0.362064540 -0.0676223003 -0.342993467 0.251880155 -0.53765962
#> [82,] -0.170112289 0.1691991749 0.118951615 0.114771586 -0.05741961
#> [83,] -0.375118174 0.0776077611 0.070781127 -0.110757021 -0.41914251
#> [84,] -0.293410866 -0.0121490241 0.261211089 0.249525070 -0.71139440
#> [85,] 0.033934692 0.0856170549 0.092384579 -0.080553740 0.28639993
#> [86,] -0.586665199 0.1894086204 0.307458429 -0.486527027 0.61396780
#> [87,] -0.139595726 0.0886062753 0.332255419 -0.981396453 -0.39861105
#> [88,] -1.758892838 0.0620097643 0.336339216 0.161665509 -2.94960367
#> [89,] -0.335947339 0.2615766214 0.122511845 0.260352291 0.05488187
#> [90,] 0.089738969 0.1505317635 0.177786042 -0.375389213 0.10864670
#> [91,] -0.028882215 0.1066199068 -0.026683067 0.104127713 0.50425142
#> [92,] -0.225070391 -0.0609056805 -0.261694388 -0.109219940 -0.93020599
#> [93,] 0.078870974 -0.0691816462 0.143747652 0.237824483 -0.26630631
#> [94,] 0.041931384 0.0911824317 -0.211539500 -0.040234401 0.14387006
#> [95,] 0.152663182 -0.5489056782 -0.032739412 -0.085074737 0.13215320
#> [96,] -0.742493117 0.0994057471 -0.086597652 0.186297585 -0.29170769
#> [97,] 0.116659406 0.1634491719 -0.079047218 0.206112595 0.13443365
#> [98,] 0.253160767 0.1419105263 0.283575899 -0.197735521 0.08241494
#> [99,] 0.182084186 0.2016176874 0.269225907 0.244228967 0.17307083
#> [100,] -0.304325034 0.0881429447 -0.099846884 -0.108926769 0.89474429
#> [,6] [,7] [,8] [,9] [,10]
#> [1,] 0.068000914 0.315906218 -0.09199397 0.040472991 0.09919803
#> [2,] 0.534509215 -0.168694078 -0.67845065 -0.276303156 0.45783403
#> [3,] 0.001096459 0.351666116 0.22569876 -0.219850555 0.11722755
#> [4,] 0.481488666 0.256686044 0.24332586 0.322827701 0.18554041
#> [5,] 4.371997965 0.307177653 -0.05642255 -0.381513110 0.84016499
#> [6,] 0.273065590 0.118061242 0.17909026 0.257254492 0.19311684
#> [7,] 0.098832041 -0.606273795 0.31566670 -0.495136161 -0.55975321
#> [8,] 0.982785242 -0.457149646 -0.37642198 -0.139477289 0.24672775
#> [9,] 0.363065911 0.005045425 2.59087357 -0.003825154 -0.17280055
#> [10,] 0.725547579 0.661471920 -3.86176775 0.515501702 -0.22319263
#> [11,] -0.260739185 0.271404895 -0.14051971 0.400712221 0.66582434
#> [12,] 0.837702056 0.636465949 0.16514814 -0.487630728 0.38005098
#> [13,] 0.040171301 0.382603622 -0.15225597 0.002217938 0.05237001
#> [14,] -0.039884849 0.189968005 -0.49068338 0.184728151 0.91109567
#> [15,] 0.133251938 0.293362925 0.15354869 -0.549095072 0.29547677
#> [16,] 0.094052881 0.083109621 0.24778877 0.037320049 -0.21832073
#> [17,] -0.002499017 -0.859679099 0.35125251 0.526617909 -0.25950315
#> [18,] -0.272664095 0.148170290 -0.03653427 -0.091831924 0.20402795
#> [19,] 0.062314853 0.138806565 -0.31725699 0.270539167 -1.01062477
#> [20,] -0.765956274 -2.171597528 0.63311138 0.432318076 -0.30459724
#> [21,] 0.097792204 -0.454814840 -0.43698185 0.036356539 0.28665562
#> [22,] -0.379919467 -0.065315272 -1.60786906 0.042342271 0.05052755
#> [23,] 0.122590802 -1.726357382 0.56112595 0.105910540 -0.92490928
#> [24,] 0.037885728 -0.129875959 0.26384300 0.423476699 0.11061914
#> [25,] 0.019074683 0.057581448 0.13180476 -0.071822977 0.13521471
#> [26,] 0.109463077 0.121156001 -0.37812216 0.007079701 -0.26989209
#> [27,] 0.168925071 0.428251683 0.18151575 0.604583446 0.17656232
#> [28,] 0.453931093 0.174144636 0.09054997 0.613532126 0.03956806
#> [29,] -0.274095075 1.365281124 -0.56457438 -1.194244092 -0.71112419
#> [30,] 0.709184747 0.591907582 1.51298255 0.734596781 1.34979438
#> [31,] -0.008375408 0.462862581 0.31485988 -0.054396505 0.26656570
#> [32,] 0.247535179 -0.057237346 0.16267523 0.430386624 -0.10024423
#> [33,] -0.473902968 0.157579411 0.36268368 0.193785234 0.20946270
#> [34,] 0.020079328 -1.263618108 0.37967700 -1.283680385 0.61381225
#> [35,] 0.292715223 -0.192583983 0.12113659 0.630064596 -0.55283226
#> [36,] -1.130112026 1.360529503 0.29217184 -0.195639585 0.22240525
#> [37,] 0.460584088 0.056378338 -0.09287723 -0.272123963 0.36048224
#> [38,] -0.577732102 0.208440186 0.22029911 -0.973534772 0.33846116
#> [39,] -0.433127046 -0.398665880 0.01334963 -1.309211800 -1.99033432
#> [40,] 0.167547783 0.888250454 0.50927368 0.010841550 -0.94758485
#> [41,] 0.566498883 -0.290482194 -1.23104286 2.128753126 -1.71540580
#> [42,] -0.119992763 0.357467318 0.41255584 0.121900411 0.05130241
#> [43,] -1.297276474 -0.414928984 -1.46223629 -1.139471752 -1.29237120
#> [44,] 0.507352942 0.264685870 -0.40115464 0.309018066 0.09442770
#> [45,] 0.504921061 0.298638794 0.02405366 0.440454744 0.11543515
#> [46,] 0.674811800 0.414334613 -0.36146338 0.739151503 -0.25009473
#> [47,] -0.100213080 -0.933193691 -0.04989789 0.482356699 0.45614531
#> [48,] -0.127043519 0.426021136 0.05787802 -0.254520340 -0.03705841
#> [49,] -1.216295949 0.462740404 -0.17530396 -1.302029726 -0.02599550
#> [50,] 0.172537398 -2.109438211 -0.14605734 -0.713341865 0.45964223
#> [51,] 0.129052847 -0.046086565 -0.15288044 -0.057576638 0.64589587
#> [52,] 0.147197721 -2.003620858 -0.89680875 -0.411102180 0.53662547
#> [53,] 0.241992879 -0.276242806 0.25045951 0.736534757 0.08394986
#> [54,] 0.508375606 0.184164247 0.06014676 0.224631263 0.17036755
#> [55,] 0.030877763 0.686545652 0.41679097 -0.223493961 0.48407445
#> [56,] 0.020005315 -0.413392940 0.19051303 0.420833326 0.20387796
#> [57,] -0.570645215 0.597183906 0.16565837 -0.906825856 0.18611827
#> [58,] -0.512572500 0.216999451 1.04324160 -0.410721230 0.49754179
#> [59,] -0.142532683 -3.120049973 0.10302875 6.167464557 -0.31854842
#> [60,] 0.091580778 -0.218057259 0.03758841 -2.496801760 -0.12308833
#> [61,] 0.405552059 -0.309440070 -0.90117295 -0.292615059 1.87853617
#> [62,] -0.031436930 0.088003251 0.42222079 0.152921386 0.20031951
#> [63,] 0.358917801 -0.159355416 0.04281828 -0.020671176 0.62557092
#> [64,] 0.076841669 0.479930295 0.20994990 -0.777350506 0.31977736
#> [65,] 0.089279151 -0.165686433 -0.20088250 0.478493502 -0.47381894
#> [66,] 0.526049528 0.642039170 -0.13187146 0.900910524 -2.07180626
#> [67,] -0.541830101 0.659107573 -0.41887081 -0.905467604 -0.41152631
#> [68,] 0.127564188 -0.225649397 -0.02832775 -1.279571378 -1.07022506
#> [69,] -1.542712408 0.141482345 2.23860979 -0.323205129 0.12088576
#> [70,] 0.747928115 -0.388698302 -1.12690240 -0.508554922 0.46700614
#> [71,] -0.681894489 0.144984526 0.28174849 0.194444804 0.18744157
#> [72,] -0.141375452 -0.230234666 0.26021589 0.091955370 0.09680239
#> [73,] 0.206064041 0.396263151 -0.23100137 0.229513992 -0.31713650
#> [74,] 0.270478366 -0.092269008 0.21677736 0.685293372 0.28893455
#> [75,] 0.106224603 0.077628147 0.05523313 -0.835416838 -0.05936317
#> [76,] 1.444999087 -0.843274422 0.11557223 -0.745413955 0.31372590
#> [77,] 0.158962605 -1.003761900 -0.20735950 -0.017041197 1.90730554
#> [78,] 0.335870241 0.109336128 0.27204853 0.150825281 0.06960240
#> [79,] -0.236137136 0.075486852 0.37443776 -0.568437359 0.39545291
#> [80,] 0.302304152 0.349514592 0.58886736 0.013852980 0.56970799
#> [81,] 0.369682362 0.117313824 3.79563472 0.114558585 0.03051158
#> [82,] 0.112685284 0.172127767 0.29813435 0.024069669 0.31017647
#> [83,] 0.156925648 0.289829907 0.46138644 0.185633953 1.72145974
#> [84,] 0.024032937 -0.008728114 0.23369075 -0.191602332 0.12581936
#> [85,] 0.225849332 0.162381053 -0.02034707 0.129834962 -0.03376883
#> [86,] 0.387267401 -0.377410202 0.11155032 -2.532129399 0.58208374
#> [87,] 0.064617831 -0.904607323 0.19792330 0.519951899 0.57382608
#> [88,] 0.017540545 -0.053361465 0.04471163 -0.090478520 -0.14330521
#> [89,] 0.623970809 0.147430309 -0.64260284 0.115649926 0.26634175
#> [90,] 0.028990327 0.313621322 0.49642050 0.008171851 0.90238952
#> [91,] -0.294072439 -0.337422543 0.40851015 0.683871681 -0.10993375
#> [92,] 0.554083725 -1.866120683 0.56164499 -0.611272209 -1.33164557
#> [93,] -0.529594270 0.159999483 -0.42994308 -0.142062891 0.23463333
#> [94,] 0.156124272 -0.928870776 0.16658213 -0.230015999 0.10436031
#> [95,] -2.234735245 -0.877795162 -0.09897499 4.224113708 0.21346410
#> [96,] -0.378353947 -0.140549173 -2.57344458 0.089454723 0.86949799
#> [97,] 0.086187582 0.240231224 0.70636874 0.037334762 0.19601496
#> [98,] 0.008374472 0.242003547 0.04167429 -0.030051893 -0.02363473
#> [99,] 0.248527420 0.146370249 0.05187781 0.058461350 0.20759863
#> [100,] -0.392957456 -1.077132293 0.50716591 1.127028057 -1.01577226
hessian(u, vc, step_wise = FALSE)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] -0.0939600803 0.016259830 0.0088303601 5.156633e-03 -4.444920e-02
#> [2,] 0.0162598295 -0.052638250 0.0022012357 1.375801e-03 -2.716702e-02
#> [3,] 0.0088303601 0.002201236 -0.0838520756 4.693138e-04 6.802772e-03
#> [4,] 0.0051566334 0.001375801 0.0004693138 -7.444200e-02 -5.867532e-05
#> [5,] -0.0444492029 -0.027167018 0.0068027715 -5.867532e-05 -3.413619e-01
#> [6,] 0.0117151276 -0.013110778 -0.0221172705 2.320557e-03 -2.726189e-02
#> [7,] -0.0004645175 -0.001289752 -0.0233219167 -7.350761e-02 -3.390827e-02
#> [8,] -0.0179827505 -0.002414822 -0.0409096319 -8.622626e-03 -3.342974e-02
#> [9,] 0.0144082155 0.018033353 0.0051355023 -5.066107e-03 -2.780520e-02
#> [10,] -0.0179897831 -0.007215126 0.0016162896 -1.739252e-02 -1.636400e-02
#> [,6] [,7] [,8] [,9] [,10]
#> [1,] 0.011715128 -0.0004645175 -0.017982751 0.014408215 -0.0179897831
#> [2,] -0.013110778 -0.0012897521 -0.002414822 0.018033353 -0.0072151259
#> [3,] -0.022117271 -0.0233219167 -0.040909632 0.005135502 0.0016162896
#> [4,] 0.002320557 -0.0735076130 -0.008622626 -0.005066107 -0.0173925179
#> [5,] -0.027261888 -0.0339082703 -0.033429741 -0.027805204 -0.0163640011
#> [6,] -0.845303106 0.0001214310 0.022425519 0.177323745 0.0086718341
#> [7,] 0.000121431 -0.6722688450 0.078532456 0.062582644 -0.0002251028
#> [8,] 0.022425519 0.0785324558 -0.725131119 -0.014823683 -0.0128320717
#> [9,] 0.177323745 0.0625826439 -0.014823683 -1.416634250 0.0350299775
#> [10,] 0.008671834 -0.0002251028 -0.012832072 0.035029978 -0.4187516774
## Discrete models
vc$var_types <- rep("d", 5) # convert model to discrete
# with discrete data we need two types of observations (see Details)
x <- qpois(u, 1) # transform to Poisson margins
u_disc <- cbind(ppois(x, 1), ppois(x - 1, 1))
dvinecop(u_disc[1:5, ], vc)
#> [1] 28.451567 1.257040 60.528810 1.915291 130.508629
pvinecop(u_disc[1:5, ], vc)
#> [1] 0.2263 0.3404 0.8408 0.5900 0.7252
# simulated data always has uniform margins
pairs(rvinecop(200, vc))
## Conditional simulation
vc_cond <- vinecop(
u,
family_set = "gaussian",
conditioning_set = c(2, 4)
)
u_cond <- c(0.25, 0.75)
uc <- rvinecop(
100,
vc_cond,
u_cond = u_cond,
conditioning_set = c(2, 4)
)
stopifnot(
isTRUE(all.equal(uc[, 2], rep(0.25, 100))),
isTRUE(all.equal(uc[, 4], rep(0.75, 100)))
)