Learn R Programming

copula (version 0.999-7)

fitMvdc: Estimation of Multivariate Models Defined via Copulas

Description

Fitting copula-based multivariate distributions ("mvdc") to multivariate data, estimating both the marginal and the copula parameters.

Usage

loglikMvdc(param, x, mvdc, hideWarnings)
fitMvdc(data, mvdc, start, optim.control = list(), method = "BFGS",
        estimate.variance = TRUE, hideWarnings = TRUE)

## S3 method for class 'fittedMV': coef(object, ...) ## S3 method for class 'fittedMV': logLik(object, ...) ## S3 method for class 'fittedMV': vcov(object, ...)

Arguments

param
a vector of parameter values. When specifying parameters for mvdc objects, the parameters must be ordered with the marginals first and the copula parameters last. When the mvdc object has marginsIdentical = TR
x
a data matrix.
mvdc
a "mvdc" object.
hideWarnings
deprecated and unused for loglikMvdc; logical; if TRUE, warning messages from likelihood maximization (mostly evaluating at invalid parameter values) are suppressed.
data
a data matrix.
start
a vector of starting value for "param". See "param" above for ordering of this vector.
optim.control
a list of controls to be passed to optim.
method
the method for optim.
estimate.variance
logical; if TRUE, the asymptotic variance is estimated.
object
an Robject of class "fitMvdc".
...
potentially further arguments to methods.

Value

  • The return value loglikMvdc() is the log likelihood evaluated for the given value of param.

    The return value of fitMvdc() is an object of class "fitMvdc" (see there), containing slots (among others!):

  • estimatethe estimate of the parameters.
  • var.estlarge-sample (i.e., asymptotic) variance estimate of the parameter estimator (filled with NA if estimate.variance = FALSE).
  • mvdcthe fitted multivariate distribution, see mvdc.
  • The summary() method for "fitMvdc" objects returns a S3 class "summary.fitMvdc", simply a list with components method, loglik, and convergence, all three from corresponding slots of the "fitMvdc" objects, and
  • coefficientsa matrix of estimated coefficients, standard errors, t values and p-values.

See Also

mvdc and mvdc; further, Copula, fitCopula, gofCopula.

For fitting univariate marginals, fitdistr().

Examples

Run this code
gumbel.cop <- gumbelCopula(3, dim=2)
gMvd2 <- mvdc(gumbel.cop, c("exp","exp"),
              list(list(rate=2), list(rate=4)))
set.seed(11)
x <- rMvdc(10000, gMvd2)
## with identical margins:
gMvd.I <- mvdc(gumbel.cop, "exp", param = list(rate=3), marginsIdentical=TRUE)
if(copula:::doExtras()) { ## these are typically not run with CRAN checking:
 ## Takes about 25 sec. [2012-07]:
 fit2 <- fitMvdc(x, gMvd2, start = c(1,1, 2),
                 hideWarnings=FALSE) ## <- show warnings here
 print(fit2)
 ## The (estimated, asymptotic) var-cov matrix:
 print( vcov(fit2) )

 fitI <- fitMvdc(x, gMvd.I, start = c(3, 2),
                 optim.control=list(trace= TRUE, REPORT= 2))
 print(coef(summary(fitI)))
 print(fitI)

  ## a wrong starting value can already be *the* problem:
  f2 <- try(fitMvdc(x, gMvd.I, start = c(1, 1),
	            optim.control=list(trace= TRUE, REPORT= 2)))
  ##--> Error in optim( ... : non-finite finite-difference value [2]

  ##==> "Solution" :  Using a more robust (but slower) optim() method:
  fI.2 <- fitMvdc(x, gMvd.I, start = c(1, 1), method = "Nelder",
		  optim.control=list(trace= TRUE))

 ## The (estimated, asymptotic) var-cov matrix:
 print( vcov(fit2) )
 str(sfI <- summary(fitI))
 stopifnot(is.matrix(coef(sfI)))
stopifnot(all.equal(coef(sfI),
		     coef(summary(fI.2)),    tol = 2e-4),
	   all.equal(coef(fitI), coef(fI.2), tol = 1e-4))}
## Roger Koenker prepared a demo illustrating MLE for a Clayton AR(1)
## copula model with identical, user-defined Student marginals
if(FALSE) ## not yet ok %% FIXME !
demo("QARClayton")

Run the code above in your browser using DataLab