| Title: | Structures and functions for partition of unity copulas |
|---|---|
| Description: | Structures for creating some types of partition of unity copula. Based on joint work with Dietmar Pfeifer and Olena Ragulina. |
| Authors: | Andreas Maendle <[email protected]> |
| Maintainer: | Andreas Maendle <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 0.1.1 |
| Built: | 2026-05-19 05:47:41 UTC |
| Source: | https://github.com/amaendle/PUcopula |
This is the 19-dimensional data set presented in Neumann et al. (2019), Tab. 2 and Tab. 3.
The data contains insurance losses from a non-life portfolio of natural perils in 19 areas in central Europe over a time period of 20 years. The monetary unit is 1 million €.
Neumann, A., Bodnar, T., Pfeifer, D., & Dickhaus, T. (2019). Multivariate multiple test procedures based on nonparametric copula estimation. Biometrical Journal, 61(1), 40-61.
Constructs an object of class PUCopula. This is the main
user-facing function for creating partition of unity copulas.
PUCopula( dim = 0, family = c("binom", "nbinom", "poisson", "sample", "gamma", "beta", "power"), pars.a = c(10, 10), patch = c("rook", "uFrechet", "lFrechet", "varwc", "Bernstein", "Gauss", "sample"), patchpar = list(NULL), data, numericCDF = FALSE )PUCopula( dim = 0, family = c("binom", "nbinom", "poisson", "sample", "gamma", "beta", "power"), pars.a = c(10, 10), patch = c("rook", "uFrechet", "lFrechet", "varwc", "Bernstein", "Gauss", "sample"), patchpar = list(NULL), data, numericCDF = FALSE )
dim |
Integer. Dimension of the copula. If 0, it is inferred from |
family |
Character vector specifying the copula family.
Possible values include |
pars.a |
Numeric vector of parameters controlling the family. |
patch |
Character. Patchwork type, e.g.
|
patchpar |
List. Parameters for the patchwork (e.g., correlation for Gaussian copula). |
data |
Matrix. Input data used to construct the copula. |
numericCDF |
Logical. Whether to use numerical CDF approximations. |
An object of class PUCopula.
data(stormflood) x <- PUCopula( family = "gamma", pars.a = c(40, 43), patch = "lFrechet", data = stormflood ) plot(x@ranks)data(stormflood) x <- PUCopula( family = "gamma", pars.a = c(40, 43), patch = "lFrechet", data = stormflood ) plot(x@ranks)
The PUCopula class implements partition-of-unity copulas as
developed in Pfeifer et al. (2016, 2017, 2019). It provides a
framework for constructing copulas using general partitions of unity,
including both discrete and continuous cases.
An object of class PUCopula.
dimNumeric scalar. Dimension of the copula.
familyCharacter vector. Specifies the family of the PU copula. (and therefore the densities fdenss)
par.factorNumeric vector. Scaling parameter for ranks.
pars.aNumeric vector. Parameters controlling the distribution of ....
patchparList. Parameters for the copula driver, e.g. rho in case of Gauss copula driver, K,m in case of Bernstein,...
pMatrix. Internal parameter representation.
phiFunction. Base density .... (obsolete due to phis)
psyFunction. Secondary density function.... (obsolete due to phis)
phisList of functions. Collection of component densities.... for . Either continuous case: A list of functions which represent Lebesgue densities of distributions over R with a parameter u in (0,1), i.e.
Or (discrete case): A list of functions which represent discrete probabilities over Z+ with a parameter u in (0,1).
continuousLogical vector. Indicates whether components are continuous....
alphFunction. Integral of ....
betaFunction. Integral of ....
alphsList of functions. Marginal densities.... Integral over the elements of phis w.r.t. u, i.e.
alphsCDFList of functions. CDFs corresponding to densities alphs, i.e.
opstartList. Starting values for optimization....
cdflimList. Limits for numerically stable CDF evaluation....
cdfdomList. Effective domain of the CDFs....
alphsquantfList. Fast quantile approximations....
cdfappxList. Approximate CDF functions....
alphsobjectiveList. Objective functions for quantiles....
alphsquantList. Quantile functions....
fdensFunction. Density function.... (obsolete due to fdenss)
gdensFunction. Secondary density.... (obsolete due to fdenss)
fdenssList of functions. Contains densities obtained from normalizing the functions (from slot phis) w.r.t. , i.e.
cpatchFunction. Copula driver density....
PUdensFunction. Density of the (continuous) PU copula defined by
where denotes the density of an arbitrary -dimensional random vector over with marginal densities for .
fqFunction. Auxiliary function.
gqFunction. Auxiliary function.
patchCharacter. Patchwork type.
dPWorkFunction. Patchwork density....
dataMatrix. Input data.
ranksMatrix. Rank-transformed data.
relRanksMatrix. Relative ranks.
rpatchFunction. Patchwork sampler - generates random samples from the specified patchwork.
randFunction. Random number generator to simulate from PU copula.
Pfeifer, D., Tsatedem, H. A., Mändle, A., and Girschig, C. (2016). New copulas based on general partitions-of-unity and their applications to risk management. Dependence Modeling, 4(1). doi:10.1515/demo-2016-0006
Pfeifer, D., Mändle, A., and Ragulina, O. (2017). New copulas based on general partitions-of-unity and their applications to risk management (part II). Dependence Modeling, 5(1), 246–255. doi:10.1515/demo-2017-0014
Pfeifer, D., Mändle, A., Ragulina, O., and Girschig, C. (2019). New copulas based on general partitions-of-unity (part III) — the continuous case. Dependence Modeling, 7(1), 181–201. doi:10.1515/demo-2019-0009
# Use dataset stormflood data(stormflood) # example: choose Gamma copula model x <- PUCopula(family="gamma", pars.a=c(40, 43), patch="lFrechet",data=stormflood) # The following plots show the common ranks and several copula drivers; # these plots do not depend on the above chosen family of the PUcopula. # 2*3 plots in one par(mfrow=c(2,3)) # plot the empirical rank vectors plot(x@ranks, sub="emp. rank vectors", xlab="", ylab="") # plot the lower Fréchet driver, i.e. phi=-1 plot(x@rpatch(2000,"lFrechet"), sub="lower Fréchet driver, phi=-1", xlab="", ylab="") # plot for phi=-0.8 plot( x@rpatch(2000,"Bernstein",list(m=20,K=20)), sub="Bernstein copula, m=20, K=20", xlab="", ylab="" ) # plot for phi=0 (rook copula) plot(x@rpatch(2000,"rook"), sub="rook copula, phi=0", xlab="", ylab="") # plot for phi=0.9 plot(x@rpatch(2000,"Gauss",0.9), sub="phi=0.9", xlab="", ylab="") # plot for phi=1 (upper Fréchet driver) plot(x@rpatch(2000,"uFrechet"), sub="upper Fréchet driver, phi=1", xlab="", ylab="") # single plot window par(mfrow=c(1,1)) # plot the densities given by phis (=densities of Gamma distributions) # plot for s=1,3,5,7,...,999 (s must be in (0,inf)) palette(rainbow(10)) xs=c(seq(0,0.01,length.out=200),seq(0.02,1,length.out=200)) # function phi for a fixed s foo <- function(u) x@phi(u,1) ys=foo(xs) # plot for s=1 plot( x=xs,y=ys, col=1, ylim=c(0,0.4), xlim=c(0,1), type = "l" ) #plot(foo, col=1, ylim=c(0,0.94), xlim=c(0,1)) # ylim=c(0,1e-88) # repeat for s=3,5,7,...,999 for (i in 2:500) { foo <- function(u) x@phi(u,i*2-1) ys=foo(xs) lines(x=xs,y=ys, col=i+1) #plot(foo, add=TRUE, col=i+1) } # for a Gamma PUC the alphs are densities of inverse Pareto distributions... plot(x@alphs[[1]], xlim=c(0,500)) # the fdenss are basically a normalization of the phis using alphs # for a fixes s they are densities of exponentially transformed # Gamma distributions # heatplot: us <- seq(0,1,length.out=100) ss <- seq(1,500,length.out=100) zs <- matrix(nrow=length(us),ncol=length(ss)) for (s in 1:length(ss)) zs[,s] <- x@fdenss[[1]](us, s) image(x=us, y=ss, z=zs, col=terrain.colors(15)) #For the simulation from the Gamma copula, the slots alphsCDF # and Qk/corresponnding quantile are used internally # plot the CDF corresponding to density alphs[1] ## Not run: x <- PUCopula(family="gamma", pars.a=c(40, 43), patch="lFrechet",data=stormflood, numericCDF=TRUE) warnings() # Warning messages: # 1: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 2: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 3: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 4: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 5: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 6: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 7: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 8: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 9: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 10: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 11: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 12: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 13: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 14: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 15: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 16: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 17: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 18: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 19: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 20: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 21: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 22: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 23: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 24: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 25: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 26: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 27: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 28: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 29: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 30: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 31: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 32: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 33: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 34: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 35: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 36: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 37: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 38: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 39: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 40: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 41: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 42: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 43: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 44: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 45: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 46: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 47: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 48: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 49: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 50: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 plot(x@alphsCDF[[1]],xlim=c(0,100)) x@alphsobjective[[1]](5,0.8) x@alphsquant[[1]](0.8) x@rand(1) ## End(Not run) # Create a beta copula x <- PUCopula(family="beta", pars.a=c(40, 43), patch="lFrechet",data=stormflood) x@phi(0.5,0.5) #[1] 2.210851e-11 x@alph(0.6) #[1] 1.458522e-11 #x@fdens(0.5,0.6) #[1] 0.0002381545 #x@gdens(0.5,0.6) #[1] 0.0001616076 x@fdenss[[1]](0.5,0.6) #[1] 0.0002381545 x@fdenss[[2]](0.5,0.6) #[1] 0.0001616076 x@rand(5) #does not work # example 2: gamma copula x <- PUCopula(family="gamma", pars.a=c(40, 43), patch="lFrechet",data=stormflood) #plot alpha(s) plot(x@alphs[[1]]) #the numerically computed alpha is quite close: s<-10 [email protected][1]*s^([email protected][1]-1)/((1+s)^([email protected][1]+1)) #[1] 0.008034519 x@alph(s) #[1] 0.008034519 # but of course shows some inaccuracies: s<-2.5 x@alph(s) #[1] 6.530307e-06 [email protected][1]*s^([email protected][1]-1)/((1+s)^([email protected][1]+1)) #[1] 6.530261e-06# Use dataset stormflood data(stormflood) # example: choose Gamma copula model x <- PUCopula(family="gamma", pars.a=c(40, 43), patch="lFrechet",data=stormflood) # The following plots show the common ranks and several copula drivers; # these plots do not depend on the above chosen family of the PUcopula. # 2*3 plots in one par(mfrow=c(2,3)) # plot the empirical rank vectors plot(x@ranks, sub="emp. rank vectors", xlab="", ylab="") # plot the lower Fréchet driver, i.e. phi=-1 plot(x@rpatch(2000,"lFrechet"), sub="lower Fréchet driver, phi=-1", xlab="", ylab="") # plot for phi=-0.8 plot( x@rpatch(2000,"Bernstein",list(m=20,K=20)), sub="Bernstein copula, m=20, K=20", xlab="", ylab="" ) # plot for phi=0 (rook copula) plot(x@rpatch(2000,"rook"), sub="rook copula, phi=0", xlab="", ylab="") # plot for phi=0.9 plot(x@rpatch(2000,"Gauss",0.9), sub="phi=0.9", xlab="", ylab="") # plot for phi=1 (upper Fréchet driver) plot(x@rpatch(2000,"uFrechet"), sub="upper Fréchet driver, phi=1", xlab="", ylab="") # single plot window par(mfrow=c(1,1)) # plot the densities given by phis (=densities of Gamma distributions) # plot for s=1,3,5,7,...,999 (s must be in (0,inf)) palette(rainbow(10)) xs=c(seq(0,0.01,length.out=200),seq(0.02,1,length.out=200)) # function phi for a fixed s foo <- function(u) x@phi(u,1) ys=foo(xs) # plot for s=1 plot( x=xs,y=ys, col=1, ylim=c(0,0.4), xlim=c(0,1), type = "l" ) #plot(foo, col=1, ylim=c(0,0.94), xlim=c(0,1)) # ylim=c(0,1e-88) # repeat for s=3,5,7,...,999 for (i in 2:500) { foo <- function(u) x@phi(u,i*2-1) ys=foo(xs) lines(x=xs,y=ys, col=i+1) #plot(foo, add=TRUE, col=i+1) } # for a Gamma PUC the alphs are densities of inverse Pareto distributions... plot(x@alphs[[1]], xlim=c(0,500)) # the fdenss are basically a normalization of the phis using alphs # for a fixes s they are densities of exponentially transformed # Gamma distributions # heatplot: us <- seq(0,1,length.out=100) ss <- seq(1,500,length.out=100) zs <- matrix(nrow=length(us),ncol=length(ss)) for (s in 1:length(ss)) zs[,s] <- x@fdenss[[1]](us, s) image(x=us, y=ss, z=zs, col=terrain.colors(15)) #For the simulation from the Gamma copula, the slots alphsCDF # and Qk/corresponnding quantile are used internally # plot the CDF corresponding to density alphs[1] ## Not run: x <- PUCopula(family="gamma", pars.a=c(40, 43), patch="lFrechet",data=stormflood, numericCDF=TRUE) warnings() # Warning messages: # 1: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 2: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 3: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 4: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 5: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 6: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 7: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 8: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 9: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 10: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 11: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 12: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 13: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 14: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 15: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 16: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 17: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 18: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 19: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 20: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 21: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 22: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 23: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 24: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 25: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 26: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 27: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 28: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 29: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 30: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 31: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 32: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 33: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 34: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 35: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 36: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 37: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 38: In phis[[i]](u, s) : outside range (0,inf) for s = -752.818778594017 # 39: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 40: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 41: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 42: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 43: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 44: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 45: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 46: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 47: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 48: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 49: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 # 50: In phis[[i]](u, s) : outside range (0,inf) for s = -91.7078148698631 plot(x@alphsCDF[[1]],xlim=c(0,100)) x@alphsobjective[[1]](5,0.8) x@alphsquant[[1]](0.8) x@rand(1) ## End(Not run) # Create a beta copula x <- PUCopula(family="beta", pars.a=c(40, 43), patch="lFrechet",data=stormflood) x@phi(0.5,0.5) #[1] 2.210851e-11 x@alph(0.6) #[1] 1.458522e-11 #x@fdens(0.5,0.6) #[1] 0.0002381545 #x@gdens(0.5,0.6) #[1] 0.0001616076 x@fdenss[[1]](0.5,0.6) #[1] 0.0002381545 x@fdenss[[2]](0.5,0.6) #[1] 0.0001616076 x@rand(5) #does not work # example 2: gamma copula x <- PUCopula(family="gamma", pars.a=c(40, 43), patch="lFrechet",data=stormflood) #plot alpha(s) plot(x@alphs[[1]]) #the numerically computed alpha is quite close: s<-10 x@pars.a[1]*s^(x@pars.a[1]-1)/((1+s)^(x@pars.a[1]+1)) #[1] 0.008034519 x@alph(s) #[1] 0.008034519 # but of course shows some inaccuracies: s<-2.5 x@alph(s) #[1] 6.530307e-06 x@pars.a[1]*s^(x@pars.a[1]-1)/((1+s)^(x@pars.a[1]+1)) #[1] 6.530261e-06
This is the data set used in Cottin, Pfeifer (2014). The table contains some original data from an insurance portfolio of storm and flooding losses, observed over a period of 20 years.
Cottin, Claudia, and Dietmar Pfeifer. "From Bernstein polynomials to Bernstein copulas." J. Appl. Funct. Anal 9.3-4 (2014): 277-288.