Package 'CopulaGAMM'

Title: Copula-Based Mixed Regression Models
Description: Estimation of 2-level factor copula-based regression models for clustered data where the response variable can be either discrete or continuous.
Authors: Pavel Krupskii [aut, ctb, cph], Bouchra R. Nasri [aut, ctb, cph], Bruno N Remillard [aut, cre, cph]
Maintainer: Bruno N Remillard <[email protected]>
License: GPL (>= 2)
Version: 0.4.1
Built: 2024-10-26 06:13:31 UTC
Source: CRAN

Help Index


Bernoulli with p = 1/(1+exp(-th)) cdf/pdf and derivatives

Description

This function computes the cdf, pdf, and associated derivatives

Usage

berncpdf(z, th)

Arguments

z

vector of responses

th

linear combination of covariates (can be negative)

Value

out

Matrix of conditional cdf and pdf with derivative with respect to parameters

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = berncpdf(0,2.5)

Copula cdf/pdf and ders

Description

Derivatives C(u|v), C'_dl(u|v), c(u,v), c'_dl(u,v), c'_u(u,v) for the linking copula

Usage

coplik(u, v, family, rot = 0, cpar, dfC = NULL, du = FALSE)

Arguments

u

vector of values in (0,1)

v

conditioning variable in (0,1)

family

copula family: "gaussian", "t", "clayton", "frank", "fgm", "gumbel", "joe", "plackett".

rot

rotation: 0 (default), 90, 180 (survival), or 270

cpar

copula parameter

dfC

degrees of freedom for the Student copula (default is NULL)

du

logical value (default = FALSE) for the derivative of the copula density with respect to u

Value

out

Matrix of conditional cdf, pdf, and derivatives with respect to parameters

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = coplik(0.3,0.5,"clayton",cpar=2,du=TRUE)

Normal density

Description

Density at (x1,x2)

Usage

dbvn(x1, x2, rh)

Arguments

x1

vector of values

x2

vector of values

rh

correlation parameter, -1< rh <1

Value

out

Vector of densities

Author(s)

Pavel Krupskii

Examples

out = dbvn(0.3,0.5,-0.6)

Normal density (version 2)

Description

Density at (x1,x2)

Usage

dbvn2(x1, x2, rh)

Arguments

x1

vector of values

x2

vector of values

rh

correlation parameter, -1< rh <1

Value

out

Vector of densities

Author(s)

Pavel Krupskii

Examples

out = dbvn2(0.3,0.5,-0.4)

Normal copula density

Description

Density at (u,v)

Usage

dbvncop(u, v, cpar)

Arguments

u

vector of values in (0,1)

v

vector of values in (0,1)

cpar

copula parameter, -1< cpar<1

Value

out

Vector of densities

Author(s)

Pavel Krupskii

Examples

out = dbvncop(0.3,0.5,-0.5)

Student copula density

Description

Density at (u,v)

Usage

dbvtcop(u, v, cpar, dfC)

Arguments

u

vector of values in (0,1)

v

vector of values in (0,1)

cpar

copula parameter, -1< cpar<1

dfC

degrees of freedom

Value

out

Vector of densities

Author(s)

Pavel Krupskii

Examples

out = dbvtcop(0.3,0.5,-0.7,25)

Copula pdf

Description

Evaluates the copula density at given points (u,v)#'

Usage

dcop(u, v, family, rot = 0, cpar, dfC = NULL)

Arguments

u

vector of values in (0,1)

v

conditioning variable in (0,1)

family

copula family: "gaussian" ("normal), "t", "clayton", "frank", "fgm", "galambos", "gumbel", "joe", "huesler-reiss", "plackett".

rot

rotation: 0 (default), 90, 180 (survival), or 270

cpar

copula parameter

dfC

degrees of freedom for the Student copula (default is NULL)

Value

out

Copula density

out

Vector of pdf values

Author(s)

Pavel Krupskii and Bruno Remillard Mai 1, 2023

Examples

out = dcop(0.3,0.7,"clayton",270,2)

Farlie-Gumbel-Morgenstern copula density, -1<= cpar<=

Description

Density at (u,v)

Usage

dfgm(u, v, cpar)

Arguments

u

vector of values in (0,1)

v

vector of values in (0,1)

cpar

copula parameter > 0

Value

out

Vector of densities

Author(s)

Pavel Krupskii

Examples

out = dfgm(0.3,0.5,0.2)

B3 bivariate Frank copula density

Description

Density at (u,v)

Usage

dfrk(u, v, cpar)

Arguments

u

vector of values in (0,1)

v

vector of values in (0,1)

cpar

copula parameter, cpar>0 or cpar<0

Value

out

Vector of densities

Author(s)

Pavel Krupskii

Examples

out = dfrk(0.3,0.5,2)

B7 Galambos copula density, cpar>0

Description

Density at (u,v)

Usage

dgal(u, v, cpar)

Arguments

u

vector of values in (0,1)

v

vector of values in (0,1)

cpar

copula parameter > 0

Value

out

Vector of densities

Author(s)

Pavel Krupskii

Examples

out = dgal(0.3,0.5,2)

B6 Gumbel copula density, cpar>1

Description

Density at (u,v)

Usage

dgum(u, v, cpar)

Arguments

u

vector of values in (0,1)

v

vector of values in (0,1)

cpar

copula parameter > 0

Value

out

Vector of densities

Author(s)

Pavel Krupskii

Examples

out = dgum(0.3,0.5,2)

B8 Huesler-Reiss copula density, cpar>0

Description

Density at (u,v)

Usage

dhr(u, v, cpar)

Arguments

u

vector of values in (0,1)

v

vector of values in (0,1)

cpar

copula parameter > 0

Value

out

Vector of densities

Author(s)

Pavel Krupskii

Examples

out = dhr(0.3,0.5,2)

B5 Joe copula density

Description

Density at (u,v)

Usage

djoe(u, v, cpar)

Arguments

u

vector of values in (0,1)

v

vector of values in (0,1)

cpar

copula parameter > 1

Value

out

Vector of densities

Author(s)

Pavel Krupskii

Examples

out = djoe(0.3,0.5,2)

B4 MTCJ copula density, cpar>0

Description

Density at (u,v)

Usage

dmtcj(u, v, cpar)

Arguments

u

vector of values in (0,1)

v

vector of values in (0,1)

cpar

copula parameter > 0

Value

out

Vector of densities

Author(s)

Pavel Krupskii

Examples

out = dmtcj(0.3,0.5,2)

B2 Plackett copula density

Description

Density at (u,v)

Usage

dpla(u, v, cpar)

Arguments

u

vector of values in (0,1)

v

vector of values in (0,1)

cpar

copula parameter > 0

Value

out

Vector of densities

Author(s)

Pavel Krupskii

Examples

out = dpla(0.3,0.5,2)

Copula-based estimation of mixed regression models for continuous response

Description

This function computes the estimation of a copula-based 2-level hierarchical model.

Usage

EstContinuous(
  y,
  model,
  family,
  rot = 0,
  clu,
  xc = NULL,
  xm = NULL,
  start,
  LB,
  UB,
  nq = 31,
  dfM = NULL,
  dfC = NULL,
  prediction = TRUE
)

Arguments

y

n x 1 vector of response variable (assumed continuous).

model

function for margins: "gaussian" (normal), "t" (Student with known df=dfM), laplace" , "exponential", "weibull".

family

copula family: "gaussian" , "t" , "clayton" , "frank" , "fgm", "gumbel".

rot

rotation: 0 (default), 90, 180 (survival), or 270

clu

variable of size n defining the clusters; can be a factor

xc

covariates of size n for the estimation of the copula, in addition to the constant; default is NULL.

xm

covariates of size n for the estimation of the mean of the margin, in addition to the constant; default is NULL.

start

starting point for the estimation; could be the ones associated with a Gaussian-copula model defined by lmer.

LB

lower bound for the parameters.

UB

upper bound for the parameters.

nq

number of nodes and weighted for Gaussian quadrature of the product of conditional copulas; default is 25.

dfM

degrees of freedom for a Student margin; default is 0 for non-t distribution,

dfC

degrees of freedom for a Student margin; default is 5.

prediction

logical variable for prediction of latent variables V; default is TRUE.

Value

coefficients

Estimated parameters

sd

Standard deviations of the estimated parameters

tstat

T statistics for the estimated parameters

pval

P-values of the t statistics for the estimated parameters

gradient

Gradient of the log-likelihood

loglik

Log-likelihood

aic

AIC coefficient

bic

BIC coefficient

cov

Covariance matrix of the estimations

grd

Gradients by clusters

clu

Cluster values

Matxc

Matrix of covariates defining the copula parameters, including a constant

Matxm

Matrix of covariates defining the margin parameters, including a constant

V

Estimated value of the latent variable by clusters (if prediction=TRUE)

cluster

Unique values of clusters

family

Copula family

tau

Kendall's tau by observation

thC0

Estimated parameters of the copula by observation

thF

Estimated parameters of the margins by observation

pcond

Conditional copula cdf

fcpdf

Margin functions (cdf and pdf)

dfM

Degrees of freedom for Student margin (default is NULL)

dfC

Degrees of freedom for the Student copula (default is NULL)

Author(s)

Pavel Krupskii, Bouchra R. Nasri and Bruno N. Remillard

References

Krupskii, Nasri & Remillard (2023). On factor copula-based mixed regression models

Examples

data(normal) #simulated data with normal margins
start=c(0,0,0,1); LB=c(rep(-10,3),0.001);UB=c(rep(10,3),10)
y=normal$y; clu=normal$clu;xm=normal$xm
out=EstContinuous(y,model="gaussian",family="clayton",rot=90,clu=clu,xm=xm,start=start,LB=LB,UB=UB)

Copula-based estimation of mixed regression models for discrete response

Description

This function computes the estimation of a copula-based 2-level hierarchical model.

Usage

EstDiscrete(
  y,
  model,
  family,
  rot = 0,
  clu,
  xc = NULL,
  xm = NULL,
  start,
  LB,
  UB,
  nq = 25,
  dfC = NULL,
  offset = NULL,
  prediction = TRUE
)

Arguments

y

n x 1 vector of response variable (assumed continuous).

model

margins: "binomial" or "bernoulli","poisson", "nbinom" (Negative Binomial), "geometric", "multinomial".

family

copula family: "gaussian" , "t" , "clayton" , "frank" , "fgm", gumbel".

rot

rotation: 0 (default), 90, 180 (survival), or 270

clu

variable of size n defining the clusters; can be a factor

xc

covariates of size n for the estimation of the copula, in addition to the constant; default is NULL.

xm

covariates of size n for the estimation of the mean of the margin, in addition to the constant; default is NULL.

start

starting point for the estimation; could be the ones associated with a Gaussian-copula model defined by lmer.

LB

lower bound for the parameters.

UB

upper bound for the parameters.

nq

number of nodes and weighted for Gaussian quadrature of the product of conditional copulas; default is 25.

dfC

degrees of freedom for a Student margin; default is 0.

offset

offset (default is NULL)

prediction

logical variable for prediction of latent variables V (default is TRUE).

Value

coefficients

Estimated parameters

sd

Standard deviations of the estimated parameters

tstat

T statistics for the estimated parameters

pval

P-values of the t statistics for the estimated parameters

gradient

Gradient of the log-likelihood

loglik

Log-likelihood

aic

AIC coefficient

bic

BIC coefficient

cov

Covariance matrix of the estimations

grd

Gradients by clusters

clu

Cluster values

Matxc

Matrix of covariates defining the copula parameters, including a constant

Matxm

Matrix of covariates defining the margin parameters, including a constant

V

Estimated value of the latent variable by clusters (if prediction=TRUE)

cluster

Unique clusters

family

Copula family

thC0

Estimated parameters of the copula by observation

thF

Estimated parameters of the margins by observation

rot

rotation

dfC

Degrees of freedom for the Student copula

model

Name of the margins

disc

Discrete margin number

Author(s)

Pavel Krupskii, Bouchra R. Nasri and Bruno N. Remillard

References

Krupskii, Nasri & Remillard (2023). On factor copula-based mixed regression models

Examples

data(sim.poisson) #simulated data with Poisson margins
start=c(2,8,3,-1); LB =    c(-3,  3,  -7,  -6);UB=c( 7, 13,   13,   4)
y=sim.poisson$y; clu=sim.poisson$clu;
xc=sim.poisson$xc; xm=sim.poisson$xm
model = "poisson"; family="frank"
out.poisson=EstDiscrete(y,model,family,rot=0,clu,xc,xm,start,LB,UB,nq=31,prediction=TRUE)

Conditional expectation

Description

This function computes the conditional expectation for a given copula family and a given margin variables for a clustered data model. The clusters ar3e independent but the observations with clusters are dependent, according to a one-factor copula model.

Usage

expcond(w, family, rot = 0, cpar, margin, dfC = NULL, subs = 1000)

Arguments

w

value of the conditioning random variable

family

copula model: "gaussian" , "t" , "clayton" ,"joe", "frank" , "gumbel", "plackett"

rot

rotation: 0 (default), 90, 180 (survival), or 270

cpar

copula parameter

margin

marginal distribution function

dfC

degrees of freedom for the Student copula (default is NULL)

subs

number of subdivisions for the integrals (default=1000)

Value

mest

Conditional expectations

Author(s)

Pavel Krupskii and Bruno N. Remillard

Examples

margin = function(x){ppois(x,10)}
expcond(0.4,'clayton',cpar=2,margin=margin)

Inverse conditional expectation for a vector of probabilities

Description

This function computes the inverse conditional expecatation for a given copula family and a given margin variables for a clustered data model. The clusters ar3e independent but the observations with clusters are dependent, according to a one-factor copula model.

Usage

expcondinv(u, family, cpar, rot = 0, margin, subs = 1000, eps = 1e-04)

Arguments

u

conditional expectation

family

copula model: "gaussian" , "t" , "clayton" "joe", "frank" , "gumbel", "plackett"

cpar

copula parameter

rot

rotation: 0 (default), 90, 180 (survival), or 270

margin

marginal distribution function of the response

subs

number of subdivisions for the integrals (default=1000)

eps

precision required

Value

minv

Inverse conditional expectation

Author(s)

Pavel Krupskii and Bruno N. Remillard


Inverse conditional expectation for a single value

Description

Inverse conditional expectation for a single value

Usage

expcondinv1(u, family, cpar, rot = 0, margin, subs = 1000, eps = 1e-04)

Arguments

u

conditional expectation

family

copula model: "gaussian" , "t" , "clayton" "joe", "frank" , "gumbel", "plackett"

cpar

copula parameter

rot

rotation: 0 (default), 90, 180 (survival), or 270

margin

marginal distribution function of the response

subs

number of subdivisions for the integrals (default=1000)

eps

precision required

Value

minv

Inverse conditional expectation


Exponential cdf/pdf and ders

Description

This function computes the cdf, pdf, and associated derivatives

Usage

expcpdf(z, th)

Arguments

z

vector of responses

th

th is rate > 0

Value

out

Matrix of conditional cdf, derivative with respect to parameter, pdf,

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = expcpdf(2,3)

Farlie-Gumbel-Morgenstern copula cdf/pdf and ders

Description

Derivatives C(u|v), C'_dl(u|v), c(u,v), c'_dl(u,v), c'_u(u,v) for the linking copula

Usage

ffgmders(u, v, cpar, du = FALSE)

Arguments

u

vector of values in (0,1)

v

conditioning variable in (0,1)

cpar

copula parameter in [-1,1]

du

logical value (default = FALSE) for the derivative of the copula density with respect to u

Value

out

Matrix of conditional cdf, pdf, and derivatives with respect to parameter

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = ffgmders(0.3,0.5,2,TRUE)

Frank copula cdf/pdf and ders

Description

Derivatives C(u|v), C'_dl(u|v), c(u,v), c'_dl(u,v), c'_u(u,v) for the linking copula

Usage

ffrkders(u, v, cpar, du = FALSE)

Arguments

u

vector of values in (0,1)

v

conditioning variable in (0,1)

cpar

copula parameter

du

logical value (default = FALSE) for the derivative of the copula density with respect to u

Value

out

Matrix of conditional cdf, pdf, and derivatives with respect to parameter

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = ffrkders(0.3,0.5,2,TRUE)

Gumbel copula cdf/pdf and ders

Description

Derivatives C(u|v), C'_dl(u|v), c(u,v), c'_dl(u,v), c'_u(u,v) for the linking copula

Usage

fgumders(u, v, cpar, du = FALSE)

Arguments

u

vector of values in (0,1)

v

conditioning variable in (0,1)

cpar

copula parameter > 1

du

logical value (default = FALSE) for the derivative of the copula density with respect to u

Value

out

Matrix of conditional cdf, pdf, and derivatives with respect to parameter

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = fgumders(0.3,0.5,2,TRUE)

Joe copula cdf/pdf and ders

Description

Derivatives C(u|v), C'_dl(u|v), c(u,v), c'_dl(u,v), c'_u(u,v) for the linking copula

Usage

fjoeders(u, v, cpar, du = FALSE)

Arguments

u

vector of values in (0,1)

v

conditioning variable in (0,1)

cpar

copula parameter > 1

du

logical value (default = FALSE) for the derivative of the copula density with respect to u

Value

out

Matrix of conditional cdf, pdf, and derivatives with respect to parameter

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = fjoeders(0.3,0.5,2,TRUE)

Clayton copula cdf/pdf and ders

Description

Derivatives C(u|v), C'_dl(u|v), c(u,v), c'_dl(u,v), c'_u(u,v) for the linking copula

Usage

fmtcjders(u, v, cpar, du = FALSE)

Arguments

u

vector of values in (0,1)

v

conditioning variable in (0,1)

cpar

copula parameter > 0

du

logical value (default = FALSE) for the derivative of the copula density with respect to u

Value

out

Matrix of conditional cdf, pdf, and derivatives with respect to parameter

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = fmtcjders(0.3,0.5,2,TRUE)

Farlie-Gumbel-Morgenstern copula cdf/pdf and ders

Description

Derivatives C(u|v), C'_dl(u|v), c(u,v), c'_dl(u,v), c'_u(u,v) for the linking copula

Usage

fnorders(u, v, cpar, du = FALSE)

Arguments

u

vector of values in (0,1)

v

conditioning variable in (0,1)

cpar

copula parameter in (-1,1)

du

logical value (default = FALSE) for the derivative of the copula density with respect to u

Value

out

Matrix of conditional cdf, pdf, and derivatives with respect to parameter

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = fnorders(0.3,0.5,0.6,TRUE)

Plackett copula cdf/pdf and ders

Description

Derivatives C(u|v), C'_dl(u|v), c(u,v), c'_dl(u,v), c'_u(u,v) for the linking copula

Usage

fpladers(u, v, cpar, du = FALSE)

Arguments

u

vector of values in (0,1)

v

conditioning variable in (0,1)

cpar

copula parameter > 0

du

logical value (default = FALSE) for the derivative of the copula density with respect to u

Value

out

Matrix of conditional cdf, pdf, and derivatives with respect to parameter

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = fpladers(0.3,0.5,2,TRUE)

Student copula cdf/pdf and ders

Description

Derivatives C(u|v), C'_dl(u|v), c(u,v), c'_dl(u,v), c'_u(u,v) for the linking copula

Usage

ftders(u, v, cpar, nu, du = FALSE)

Arguments

u

vector of values in (0,1)

v

conditioning variable in (0,1)

cpar

copula parameter in (-1,1)

nu

degrees of freedom >0

du

logical value (default = FALSE) for the derivative of the copula density with respect to u

Value

out

Matrix of conditional cdf, pdf, and derivatives with respect to parameter

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = ftders(0.3,0.5,2,25)

Student copula cdf/pdf and ders

Description

Derivatives C(u|v), C'_dl(u|v), c(u,v), c'_dl(u,v), c'_u(u,v) for the linking copula

Usage

ftdersP(u, v, cpar, dfC, du = FALSE)

Arguments

u

vector of values in (0,1)

v

conditioning variable in (0,1)

cpar

copula parameter in (-1,1)

dfC

degrees of freedom

du

logical value (default = FALSE) for the derivative of the copula density with respect to u

Value

out

Matrix of conditional cdf, pdf, and derivatives with respect to parameter

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = ftdersP(0.3,0.5,2,25,TRUE)

Geometric with p = 1/(1+exp(-th)) cdf/pdf and ders

Description

This function computes the cdf, pdf, and associated derivatives

Usage

geomcpdf(z, th)

Arguments

z

vector of responses

th

linear combination of covariates (can be negative)

Value

out

Matrix of conditional cdf, derivative with respect to parameter, pdf,

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = geomcpdf(0,-3)

Inverse function

Description

This function is used to get the inverse of a monotonic function on (0,1), depending on parameters, and using the bisection method

Usage

invfunc(q, func, th, lb = 1e-12, ub = 1 - 1e-12, tol = 1e-08, nbreak = 40)

Arguments

q

Function value (can be a vector if func() supports a vector argument)

func

Function of one argument to be inverted

th

Function parameters

lb

Lower bound for the possible values

ub

Upper bound for the possible values

tol

Tolerance for the inversion

nbreak

Maximum number of iterations (default is 40)

Value

out

Inverse values

Author(s)

Pavel Krupskii


Laplace cdf/pdf and ders

Description

This function computes the cdf, pdf, and associated derivatives

Usage

lapcpdf(z, th)

Arguments

z

vector of responses

th

th[,1] is mean, th[,2] is standard deviation > 0

Value

out

Matrix of conditional cdf, derivative with respect to parameter, pdf,

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = lapcpdf(2,c(-3,4))

Link to copula parameter

Description

Computes the copula parameters given a linear combination of covariates.

Usage

linkCop(th, family = "clayton")

Arguments

th

vector of linear combinations

family

copula family: "gaussian" , "t" , "clayton" , "claytonR" , "frank" , "gumbel", "gumbelR".

Value

cpar

Associated copula parameters

hder

Derivative of link function

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2023

References

Krupskii, Nasri & Remillard (2023). On factor copula-based mixed regression models

Examples

out = linkCop(-1,"gaussian")

Estimation of latent variables in the continuous case

Description

This function computes the estimation of a latent variables for each cluster using the conditional a posteriori median.

Usage

MAP.continuous(u, family, rot, thC0k, dfC = NULL, nq = 35)

Arguments

u

vector of values in (0,1)

family

copula family: "gaussian" , "t" , "clayton" , "joe", "frank" , "fgm", gumbel", "plackett", "galambos", "huesler-reiss"

rot

rotation: 0 (default), 90, 180 (survival), or 270.

thC0k

vector of copula parameters

dfC

degrees of freedom for the Student copula (default is NULL)

nq

number of nodes and weighted for Gaussian quadrature of the product of conditional copulas; default is 31.

Value

condmed

Conditional a posteriori median.

Author(s)

Pavel Krupskii, Bouchra R. Nasri and Bruno N. Remillard

References

Krupskii, Nasri & Remillard (2023). On factor copula-based mixed regression models

Examples

u = c(0.5228155, 0.3064417, 0.2789849, 0.5176489, 0.3587144)
thC0k=rep(17.54873,5)
MAP.continuous(u,"clayton",rot=90,thC0k,nq=35)

Estimation of latent variable in the dicrete case

Description

This function computes the estimation of a latent variables foe=r each cluster using the conditional a posteriori median.

Usage

MAP.discrete(vv, uu, family, rot, thC0k, dfC = NULL, nq = 35)

Arguments

vv

vector of values in (0,1)

uu

vector of values in (0,1)

family

copula family "gaussian" , "t" , "clayton" , "joe", "frank" , "fgm", gumbel", "plackett", "galambos", "huesler-reiss"

rot

rotation: 0 (default), 90, 180 (survival), or 270.

thC0k

vector of copula parameters

dfC

degrees of freedom for the Student copula (default is NULL)

nq

number of nodes and weighted for Gaussian quadrature of the product of conditional copulas; default is 31.

Value

condmed

Conditional a posteriori median.

Author(s)

Pavel Krupskii, Bouchra R. Nasri and Bruno N. Remillard

References

Krupskii, Nasri & Remillard (2023). On factor copula-based mixed regression models

Examples

uu = c(0.5228155, 0.3064417, 0.2789849, 0.5176489, 0.3587144)
vv = c(0.7816627, 0.6688788, 0.6351364, 0.7774917, 0.7264787)
thC0k=rep(17.54873,5)
MAP.discrete(vv,uu,"clayton",rot=90,thC0k,nq=35)

Margins cdf/pdf and their derivatives

Description

This function computes the cdf, pdf, and associated derivatives

Usage

margins(z, th, model, x = NULL, dfM = NULL)

Arguments

z

vector of responses

th

linear combination of covariates (can be negative)

model

model for margin: "binomial" (bernoulli), "poisson", "nbinom" (mean is the parameter),"nbinom1" (p is the parameter), "geometric", "multinomial", "exponential", "weibull", "normal","t", "laplace"

x

covariates for the multinomial margin (default is NULL)

dfM

degrees of freedom for the Student margin (default is NULL)

Value

out

Matrix of conditional cdf, derivative with respect to parameter, pdf,

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = margins(0,2.5,"binomial")

Estimation of the parameter of a bivariate copula (Clayton, Frank, Gumbel)

Description

Computes the MLE estimation for a bivariate copula using gradient. The likelihood is likelihood is c(u,v;theta)

Usage

mlecop(u, v, fcopders, start = 2, LB = 1.01, UB = 7)

Arguments

u

vector of values in (0,1)

v

vector of values in (0,1)

fcopders

ffrkders, fgumders or fmtcjders

start

starting value for the parameter (default =2)

LB

lower bound for the parameter (default is 1.01)

UB

upper bound for the parameter (default is 7)

Value

mle

List of outputs from nlm function

Author(s)

Pavel Krupskii

Examples

set.seed(2)
v = runif(250)
w = runif(250)
u = 1/sqrt(1+(w^(-2/3)-1)/v^2) # Clayton copula with parameter 2 (tau=0.5)
out = mlecop(u,v,fmtcjders)

Estimation of the parameter of a bivariate copula (Clayton, Frank, Gumbel) when the first observation is 0 or 1

Description

Computes the MLE estimation for a bivariate copula using gradient. The likelihood is likelihood is C(1-p|v;theta) if y=0 and 1-C(1-p|v;theta) if y=1

Usage

mlecop.disc(y, v, fcopders, start = 2, LB = 1.01, UB = 7)

Arguments

y

vector of binary values 0 or 1

v

vector of values in (0,1)

fcopders

ffrkders, fgumders or fmtcjders

start

starting value for the parameter (default =2)

LB

lower bound for the parameter (default is 1.01)

UB

upper bound for the parameter (default is 7)

Value

mle

List of outputs from nlm function

Author(s)

Pavel Krupskii

Examples

set.seed(2)
v = runif(250)
w = runif(250)
u = 1/sqrt(1+(w^(-2/3)-1)/v^2) #Clayton with parameter 2
y = as.numeric(u>0.6) # if one takes (u<4), one obtains a rotation of the Clayton!
out = mlecop.disc(y,v,fmtcjders)

Multinomial with p = 1/(1+exp(-th)) cdf/pdf and ders

Description

This function computes the cdf, pdf, and associated derivatives

Usage

multinomcpdf(z, th, x)

Arguments

z

vector of responses taking values in 1,...,nL: as.number(z) if z is a factor!

th

th is a n x (L-1) matrix of parameters, i.e., mpar = a=[a_1,1,...a_1,k2,a_2,1,...a_2,k2,... a_L-1,1... a_L-1,k2], and first level is the baseline.

x

matrix of covariates (including the constant)

Value

out

Matrix of conditional cdf, derivative with respect to parameter, pdf,

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

x=matrix(c(1,1,-1,-1,0,2),nrow=2)
z = c(1,3)
th = matrix(c(1,2,3,4,5,6),nrow=2)
out = multinomcpdf(z,th,x = x)

Simulated data

Description

Simulated clustered data from a Clayton copula with parameter 2, and multinomial margins with 3 levels and parameters 1.0,-1 for level 2 and 0.5, 2 for level 3. Clusters and covariates are included.

Usage

data(multinomial)

Format

Data frame of numerical values

Examples

data(multinomial)

Negative binomial cdf/pdf and ders

Description

This function computes the cdf, pdf, and associated derivatives

Usage

nbinom1cpdf(z, th)

Arguments

z

vector of responses

th

th[,1] is size > 0 and th[,2] is mean > 0; size does not have to be integer

Value

out

Matrix of conditional cdf, derivative with respect to parameter, pdf,

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = nbinom1cpdf(0,c(1,0.5))

Negative binomial cdf/pdf and ders

Description

This function computes the cdf, pdf, and associated derivatives

Usage

nbinomcpdf(z, th)

Arguments

z

vector of responses

th

th[,1] is size > 0 and th[,2] is p, with 0<p<1; size does not have to be integer

Value

out

Matrix of conditional cdf, derivative with respect to parameter, pdf,

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = nbinomcpdf(0,c(1,0.5))

Simulated data

Description

Simulated clustered data from a Clayton copula with parameter 2, rotation = 90, and normal margins with 1,-1 for the mean, ans sd = 4. Clusters and covariates are included.

Usage

data(normal)

Format

List of simulated values (y, clu, xm)

Examples

data(normal)

normal cdf/pdf and ders

Description

This function computes the cdf, pdf, and associated derivatives

Usage

normcpdf(z, th)

Arguments

z

vector of responses

th

th[,1] is mean, th[,2] is standard deviation > 0;

Value

out

Matrix of conditional cdf, derivative with respect to parameter, pdf,

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = normcpdf(2,c(-3,4))

EstContinuous object

Description

Output of EstContinuous for the simulated clustered data normal.

Usage

data(out.normal)

Format

Data frame of numerical values

Examples

data(out.normal)

EstDiscrete object

Description

Output of EstDiscrete for the simulated clustered data poisson.

Usage

data(out.poisson)

Format

Data frame of numerical values

Examples

data(out.poisson)

Conditional cdf

Description

This function computes the conditional cdf C(U|V) for a copula C

Usage

pcond(U, V, family, rot = 0, cpar, dfC = NULL)

Arguments

U

values at which the cdf is evaluated

V

value of the conditioning variable in (0,1)

family

"gaussian" , "t" , "clayton" , "joe", "frank" , "fgm", gumbel", "plackett", "galambos", "huesler-reiss"

rot

rotation: 0 (default), 90, 180 (survival), or 270

cpar

copula parameter (vector)

dfC

degrees of freedom of the Student copula (default is NULL)

Value

p

Conditional cdf

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

p = pcond(0.1,0.2,"clayton",rot=270,cpar=0.87)

Conditional Clayton

Description

Conditional Clayton

Usage

pcondcla(u, v, cpar)

Arguments

u

values at which the cdf is evaluated

v

value of the conditioning variable in (0,1)

cpar

copula parameter

Value

ccdf

Conditional cdf

Examples

pcondcla(0.5,0.6,2)

Conditional FGM (B10)

Description

Conditional FGM (B10)

Usage

pcondfgm(u, v, cpar)

Arguments

u

probability

v

value of the conditioning variable in (0,1)

cpar

copula parameter -1<=cpar<=1

Value

ccdf

Conditional cdf

Examples

pcondfgm(0.5,0.6,0.9)

Conditional Frank (B3)

Description

Conditional Frank (B3)

Usage

pcondfrk(u, v, cpar)

Arguments

u

values at which the cdf is evaluated

v

value of the conditioning variable in (0,1)

cpar

copula parameter

Value

ccdf

Conditional cdf

Examples

pcondfrk(0.5,0.6,2)

Conditional Galambos (B7)

Description

Conditional Galambos (B7)

Usage

pcondgal(u, v, cpar)

Arguments

u

values at which the cdf is evaluated

v

value of the conditioning variable in (0,1)

cpar

copula parameter

Value

ccdf

Conditional cdf

Examples

pcondgal(0.5,0.6,2)

Conditional Gumbel (B6)

Description

Conditional Gumbel (B6)

Usage

pcondgum(u, v, cpar)

Arguments

u

values at which the cdf is evaluated

v

value of the conditioning variable in (0,1)

cpar

copula parameter >1

Value

ccdf

Conditional cdf

Examples

pcondgum(0.5,0.6,2)

Conditional Huesler-Reiss (B8)

Description

Conditional Huesler-Reiss (B8)

Usage

pcondhr(u, v, cpar)

Arguments

u

values at which the cdf is evaluated

v

value of the conditioning variable in (0,1)

cpar

copula parameter >0

Value

ccdf

Conditional cdf

Examples

pcondhr(0.5,0.6,2)

Conditional Joe (B5)

Description

Conditional Joe (B5)

Usage

pcondjoe(u, v, cpar)

Arguments

u

values at which the cdf is evaluated

v

value of the conditioning variable in (0,1)

cpar

copula parameter

Value

ccdf

Conditional cdf

Examples

pcondjoe(0.5,0.6,2)

Conditional Gaussian

Description

Conditional Gaussian

Usage

pcondnor(u, v, cpar)

Arguments

u

values at which the cdf is evaluated

v

value of the conditioning variable in (0,1)

cpar

copula parameter

Value

ccdf

Conditional cdf

Examples

pcondnor(0.5,0.6,0.6)

Conditional Plackett (B2)

Description

Conditional Plackett (B2)

Usage

pcondpla(u, v, cpar)

Arguments

u

values at which the cdf is evaluated

v

value of the conditioning variable in (0,1)

cpar

copula parameter >1

Value

ccdf

Conditional cdf

Examples

pcondpla(0.5,0.6,2)

Conditional Student

Description

Conditional Student is Y2|Y1=y1 ~ t(nu+1,location=rho*y1, sigma(y1)), where here sigma^2 = (1-rho^2)(nu+y1^2)/(nu+1)

Usage

pcondt(u, v, cpar, dfC)

Arguments

u

values at which the cdf is evaluated

v

value of the conditioning variable in (0,1)

cpar

copula parameter

dfC

degrees of freedom

Value

ccdf

Conditional cdf

Examples

pcondt(0.5,0.6,0.6,15)

Poisson cdf/pdf and ders

Description

This function computes the cdf, pdf, and associated derivatives

Usage

poiscpdf(z, th)

Arguments

z

vector of responses

th

values of lambda >0

Value

out

Matrix of conditional cdf, derivative with respect to parameter, pdf,

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = poiscpdf(0,2.5)

Conditional expectation for a copula-based estimation of mixed regression models for continuous response

Description

Compute the conditional expectation of a copula-based 2-level hierarchical model for continuous response.

Usage

predictContinuous(object, newdata = NULL, nq = 25)

Arguments

object

Object of class “EstContinuous“ generated by EstContinuous.

newdata

List of variables for be predicted (“clu“ for clusters, “xc“ for the copula covariates, and “xm“ for the margins covariates). The covariates can be NULL.

nq

number of nodes and weighted for Gaussian quadrature of the product of conditional copulas; default is 25.

Value

mest

Conditional expectations

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2023

References

Krupskii, Nasri & Remillard (2023). On factor copula-based mixed regression models

Examples

data(out.normal)
newdata=list(clu=c(1:50),xm=rep(0.4,50))
pred= predictContinuous(out.normal,newdata)

Conditional expectation for a copula-based estimation of mixed regression models for discrete response

Description

Compute the conditional expectation of a copula-based 2-level hierarchical model for disctrete response.

Usage

predictDiscrete(object, newdata, m = 100)

Arguments

object

Object of class “EstDiscrete“ generated by EstDiscrete.

newdata

List of variables for be predicted (“clu“ for clusters, “xc“ for the copula covariates, and “xm“ for the margins covariates). The covariates can be NULL.

m

Number of points for the numerical integration (default is 100).

Value

mest

Conditional expectations (conditional probabilities for the multinomial case

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2023

References

Krupskii, Nasri & Remillard (2023). On factor copula-based mixed regression models

Examples

data(out.poisson)
newdata = list(clu=c(1:50),xc=rep(0.2,50),xm=rep(0.5,50))
pred= predictDiscrete(out.poisson,newdata,m=100)

Estimation cdf, left-continuous cdf, and pseudo-observations

Description

This function estimates the empirical cdf, its left limit, and pseudo-observations for a univatiate vector y

Usage

pseudosC(y)

Arguments

y

univariate data

Value

Fn

Emprirical cdf

Fm

Left-contniuous cdf

U

Pseudo-obsevations

Author(s)

Bruno N. Remillard, January 20, 2022

Examples

y = rpois(100,2)
out=pseudosC(y)

Inverse conditional cdf

Description

This function computes the quantile of conditional cdf C(U|v) for a copula C

Usage

qcond(w, v, family, cpar, rot = 0)

Arguments

w

probability

v

value of the conditioning variable in (0,1)

family

"gaussian" , "t" , "clayton" , "fgm", "frank" , "gumbel", "plackett", "galambos", "huesler-reiss"

cpar

copula parameter (vector)

rot

rotation: 0 (default), 90, 180 (survival), or 270

Value

U

Conditional quantile

U

Conditional quantile

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

U = qcond(0.1,0.2,"gaussian",0.87)

Inverse clayton

Description

Inverse clayton

Usage

qcondcla(w, v, th)

Arguments

w

probability

v

value of the conditioning variable in (0,1)

th

copula parameter

Value

out

Conditional quantile


Inverse FGM (B10)

Description

Inverse FGM (B10)

Usage

qcondfgm(w, v, th)

Arguments

w

probability

v

value of the conditioning variable in (0,1)

th

copula parameter -1<=th<=1

Value

out

Conditional quantile


Inverse Frank

Description

Inverse Frank

Usage

qcondfra(w, v, th)

Arguments

w

probability

v

value of the conditioning variable in (0,1)

th

copula parameter

Value

out

Conditional quantile


Inverse Galambos

Description

Inverse Galambos

Usage

qcondgal(w, v, th)

Arguments

w

probability

v

value of the conditioning variable in (0,1)

th

copula parameter >0

Value

out

Conditional quantile


Inverse Gumbel

Description

Inverse Gumbel

Usage

qcondgum(w, v, th)

Arguments

w

probability

v

value of the conditioning variable in (0,1)

th

copula parameter

Value

out

Conditional quantile


Inverse Huesler-Reiss

Description

Inverse Huesler-Reiss

Usage

qcondhr(w, v, th)

Arguments

w

probability

v

value of the conditioning variable in (0,1)

th

copula parameter >0

Value

out

Conditional quantile


Inverse Joe

Description

Inverse Joe

Usage

qcondjoe(w, v, th)

Arguments

w

probability

v

value of the conditioning variable in (0,1)

th

copula parameter >-1

Value

out

Conditional quantile


Inverse Gaussian

Description

Inverse Gaussian

Usage

qcondnor(w, v, th)

Arguments

w

probability

v

value of the conditioning variable in (0,1)

th

copula parameter (correlation)

Value

out

Conditional quantile


Inverse Plackett

Description

Inverse Plackett

Usage

qcondpla(w, v, th)

Arguments

w

probability

v

value of the conditioning variable in (0,1)

th

copula parameter

Value

out

Conditional quantile


Inverse Student

Description

Inverse Student

Usage

qcondt(w, v, th)

Arguments

w

probability

v

value of the conditioning variable in (0,1)

th

copula parameter

Value

out

Conditional quantile


Simulated data

Description

Simulated clustered data from a Frank copula with parC=c(2,8), and Poisson margins with parM=c(3.0,-0.1). Clusters and covariates (both uniform) are included.

Usage

data(sim.poisson)

Format

List of simulated values (y, clu,xc,xm) together with true parameters

Examples

data(sim.poisson)

Simulation of clustered data

Description

Generate a random sample of observations from a copula-based mixed regression model.

Usage

SimGenCluster(
  parC,
  parM,
  clu,
  xc = NULL,
  xm = NULL,
  family,
  rot = 0,
  dfC = NULL,
  model,
  dfM = NULL,
  offset = NULL
)

Arguments

parC

vector of copula parameters; k1 is the number of covariates + constant for the copula

parM

vector of margin parameters; k2 is the number of covariates + constant for the margins

clu

vector of clusters (can be a factor)

xc

matrix (N x k1) of covariates for the copula, not including the constant (can be NULL)

xm

matrix (N x k2) of covariates for the margins, not including the constant (can be NULL)

family

copula family: "gaussian" , "t" , "clayton" , "joe", "frank" , "gumbel", "plackett"

rot

rotation: 0 (default), 90, 180 (survival), or 270

dfC

degrees of freedom for the Student copula (default is NULL)

model

marginal distribution: "binomial" (bernoulli), "poisson", "nbinom" (mean is the parameter),"nbinom1" (p is the parameter), "geometric", "multinomial", exponential", "weibull", "normal" (gaussian),"t", "laplace"

dfM

degrees of freedom for the Student margins (default is NULL)

offset

offset for the margins (default is NULL)

Value

y

Simulated response

y

Simulated values

Author(s)

Bruno N. Remillard

Examples

K=50 #number of clusters
n=5  #size of each cluster
N=n*K
set.seed(1)
clu=rep(c(1:K),each=n)
parC = 0 # yields tau = 0.5 for Clayton
parM= c(1,-1,4)
xm = runif(N)
y=SimGenCluster(parC,parM,xm,family="clayton",rot=90,clu=clu,model="gaussian")

Simulation of multinomial clustered data

Description

Generate a random sample of multinomial observations from a copula-based mixed regression model.

Usage

SimMultinomial(
  parC,
  parM,
  clu,
  xc = NULL,
  xm = NULL,
  family,
  rot = 0,
  dfC = NULL,
  offset = NULL
)

Arguments

parC

copula parameters

parM

matrix of dimension (L-1)x k2 of margin parameters; L is the number of levels and k2 is the number of covariates+constant for the margins

clu

vector of clusters (can be a factor)

xc

matrix of covariates for the copula, not including the constant (can be NULL)

xm

matrix of covariates for the margins, not including the constant (can be NULL)

family

copula family: "gaussian" , "t" , "clayton" , "joe", "frank" , "gumbel", "plackett"

rot

rotation: 0 (default), 90, 180 (survival), or 270

dfC

degrees of freedom for student copula (default is NULL)

offset

offset for the margins (default is NULL)

Value

y

Simulated factor

Author(s)

Bruno N. Remillard

Examples

K=50 #number of clusters
n=5  #size of each cluster
N=n*K
set.seed(1)
clu=rep(c(1:K),each=n)
parC = 2
parM=matrix(c(1,-1,0.5,2),byrow=TRUE,ncol=2)
xm = runif(N)
y=SimMultinomial(parC,parM,clu,xm=xm,family="clayton",rot=90)

Student cdf/pdf and ders

Description

This function computes the cdf, pdf, and associated derivatives

Usage

tcpdf(z, th, df)

Arguments

z

vector of responses

th

th[,1] is mean, th[,2] is standard deviation > 0

df

degrees of freedom

Value

out

Matrix of conditional cdf, derivative with respect to parameter, pdf,

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = tcpdf(2,c(-3,4),25)

Weibul cdf/pdf and ders

Description

This function computes the cdf, pdf, and associated derivatives

Usage

weibcpdf(z, th)

Arguments

z

vector of responses

th

th[,1] is rate>0, th[,2] is shape > 0;

Value

out

Matrix of conditional cdf, derivative with respect to parameter, pdf,

Author(s)

Pavel Krupskii and Bruno N. Remillard, January 20, 2022

Examples

out = weibcpdf(2,c(2,3))