cramer_vonmises {cylcop} | R Documentation |
Cramér-von-Mises criterion
Description
Calculate the Cramér-von-Mises criterion with a p-value (via parametric bootstrapping) to assess the goodness of fit of a parametric copula compared to the empirical copula of the data.
Usage
cramer_vonmises(
copula,
theta,
x,
n_bootstrap = 1000,
parameters = NULL,
optim.method = "L-BFGS-B",
optim.control = list(maxit = 100)
)
Arguments
copula |
R object of class ' |
theta |
numeric vector of angles (measurements of a circular variable) or "circular" component of pseudo-observations. |
x |
numeric vector of step lengths (measurements of a linear variable) or "linear" component of pseudo-observations. |
n_bootstrap |
integer number of bootstrap replicates. If
|
parameters |
vector of character strings
holding the names of the parameters to be optimized when using the bootstrap
procedure.
These can be any parameters in |
optim.method |
character string, optimizer used in
|
optim.control |
Details
The Cramér-von Misses criterion is calculated as the sum of the squared
differences between the empirical copula and the parametric copula, copula
,
evaluated at the pseudo-observations obtained from theta
and x
.
If the bootstrap procedure is used, a random sample is drawn from copula
and converted to pseudo-observations. A new (set of) copula parameter(s) is then
fit to those pseudo-observations using maximum likelihood (function
cylcop::fit_cylcop_ml()
).
Value
A list of length 2 containing the Cramér-von Mises criterion and the p-value.
References
Genest C, Rémillard B (2008). “Validity of the parametric bootstrap for goodness-of-fit testing in semiparametric models.” Annales de l'Institut Henri Poincaré, Probabilités et Statistiques, 44(6), 1096 – 1127. doi:10.1214/07-AIHP148.
Examples
set.seed(1234)
sample <- rcylcop(100,cyl_cubsec(0.1, 0.1))
opt_cop <- fit_cylcop_ml(copula = cyl_quadsec(),
theta = sample[,1],
x = sample[,2],
parameters = "a",
start = 0
)$copula
cramer_vonmises(opt_cop,
theta = sample[,1],
x = sample[,2],
n_bootstrap=5)