Learn R Programming

dsfa (version 2.0.2)

cop: cop

Description

The cop implements multiple copula distributions in which the parameter \(\delta\) can depend on additive predictors. Useable with mgcv::gam, the additive predictors are specified via a formula.

Usage

cop(link = list("glogit"), W, distr = "normal", rot = 0)

Value

An object inheriting from class general.family of the mgcv package, which can be used in the 'mgcv' and 'dsfa' package.

Arguments

link

formula, specifying the link for \(\delta\) parameter. See details.

W

numeric matrix of pseudo observations. Must have two columns.

distr

string, defines the copula family:
`independent` = Independence copula
`normal` = Gaussian copula
`clayton` = Clayton copula
`gumbel` = Gumbel copula
`frank` = Frank copula
`joe` = Joe copula
`amh` = Ali-Mikhail-Haq copula

rot

integer determining the rotation for Archimedian copulas. Can be 90, 180 or 270.

Details

Mostly internal function. Used with gam to fit copula model, which in turn is used for starting values. The function gam is from the mgcv package and is called with a formula. The formula specifies a dummy on the left hand side and the structure of the additive predictor for the \(\delta\) parameter on the right hand side. Link function is "generalized logit", where for each distr argument there are specific min and max arguments, which are the boundaries of the parameter space. Although the parameter space is larger in theory for some copulas, numeric under- and overflow limits the parameter space. The intervals for the parameter delta are provided by [delta_bounds()]. WARNING: Only the estimates of the coefficients are useful. The rest of the 'mgcv' object has no meaningful values, as gam() was more or less abused here.

References

  • schmidt2023multivariatedsfa

  • wood2017generalizeddsfa

  • aigner1977formulationdsfa

  • kumbhakar2015practitionerdsfa

  • azzalini2013skewdsfa

  • schmidt2020analyticdsfa

See Also

Other copula: dcop(), delta_bounds()

Examples

Run this code
# \donttest{
#Set seed, sample size and type of copula
set.seed(1337)
N=500 #Sample size
cop="gumbel" #copula
rot=180 #rotation

#Generate covariates
x1<-runif(N,-1,1); x2<-runif(N,-1,1)

#Set parameters of the copula
eta<-matrix(1+2.5*x1+1.75*sin(pi*x2),nrow=N)
delta<-transform(x=eta, type="glogitinv", par=as.numeric(delta_bounds(cop)), deriv_order = 0)

#Simulate pseudo observations W and create dataset
dat<-as.data.frame(rcop(n=N, delta=delta, distr=cop, rot=rot))
dat$y<-1 #Add dummy response variable

#Write formulae for parameters
delta_formula<-y~x1+s(x2,bs="ps")

#Fit model
model<-mgcv::gam(delta_formula, data=dat,
                 family=cop(W=dat[,1:2],
                            distr=cop, rot=rot),
                 optimizer="efs")

#Smooth effects
#Effect of x2 on the predictor of delta
plot(model, select=1) #Estimated function
lines(x2[order(x2)], 1.75*sin(pi*x2[order(x2)])-
        mean(1.75*sin(pi*x2)), col=2) #True effect
# }

Run the code above in your browser using DataLab