Marginal and simultaneous cumulative distribution, log probability density, and log-likelihood functions of the Gaussian mixture model (GMM) and Gaussian mixture copula model (GMCM) and the relevant inverse marginal quantile functions.

dgmcm.loglik(theta, u, marginal.loglik = FALSE, ...)

dgmm.loglik(theta, z, marginal.loglik = FALSE)

dgmm.loglik.marginal(theta, x, marginal.loglik = TRUE)

pgmm.marginal(z, theta)

qgmm.marginal(u, theta, res = 1000, spread = 5, rule = 2)

Arguments

theta

A list parameters as described in rtheta.

u

A matrix of (estimates of) realizations from the GMCM where each row corresponds to an observation.

marginal.loglik

Logical. If TRUE, the marginal log-likelihood functions for each multivariate observation (i.e. the log densities) are returned. In other words, if TRUE the sum of the marginal likelihoods is not computed.

...

Arguments passed to qgmm.marginal.

z

A matrix of realizations from the latent process where each row corresponds to an observation.

x

A matrix where each row corresponds to an observation.

res

The resolution at which the inversion of qgmm.marginal is done. Default is 1000.

spread

The number of marginal standard deviations from the marginal means the pgmm.marginal is to be evaluated on.

rule

The extrapolation rule used in approxfun.

Value

The returned value depends on the value of marginal.loglik. If TRUE, the non-summed marginal likelihood values are returned. If FALSE, the scalar sum log-likelihood is returned.

dgmcm.loglik: As above, with the GMCM density.

dgmm.loglik: As above, with the GMM density.

dgmm.loglik.marginal: As above, where the j'th element is evaluated in the j'th marginal GMM density.

pgmm.marginal: A matrix where the (i,j)'th entry is the (i,j)'th entry of z evaluated in the jth marginal GMM density.

qgmm.marginal: A matrix where the (i,j)'th entry is the (i,j)'th entry of u evaluated in the inverse jth marginal GMM density.

Details

qgmm.marginal distributes approximately res points around the cluster centers according to the mixture proportions in theta$pie and evaluates pgmm.marginal on these points. An approximate inverse of pgmm.marginal function is constructed by linear interpolation of the flipped evaluated coordinates.

Author

Anders Ellern Bilgrau <anders.ellern.bilgrau@gmail.com>

Examples

set.seed(1) data <- SimulateGMCMData(n = 10) u <- data$u z <- data$z print(theta <- data$theta)
#> theta object with d = 2 dimensions and m = 3 components: #> #> $pie #> pie1 pie2 pie3 #> 0.2193406 0.3074170 0.4732425 #> #> $mu #> $mu$comp1 #> [1] 13.29799 12.72429 #> #> $mu$comp2 #> [1] 4.146414 -15.399500 #> #> $mu$comp3 #> [1] -9.285670 -2.947204 #> #> #> $sigma #> $sigma$comp1 #> [,1] [,2] #> [1,] 13.348429 8.850678 #> [2,] 8.850678 5.934935 #> #> $sigma$comp2 #> [,1] [,2] #> [1,] 3.0665824 -0.3895294 #> [2,] -0.3895294 2.6192252 #> #> $sigma$comp3 #> [,1] [,2] #> [1,] 1.9840226 0.4433423 #> [2,] 0.4433423 2.8292856 #> #>
GMCM:::dgmcm.loglik(theta, u, marginal.loglik = FALSE)
#> [1] 13.59121
GMCM:::dgmcm.loglik(theta, u, marginal.loglik = TRUE)
#> [,1] #> [1,] 3.7357739 #> [2,] 0.8021746 #> [3,] 0.2719414 #> [4,] 0.8672774 #> [5,] 0.6881781 #> [6,] 0.8119559 #> [7,] 1.1731392 #> [8,] 0.9476444 #> [9,] 0.7314841 #> [10,] 3.5616420
GMCM:::dgmm.loglik(theta, z, marginal.loglik = FALSE)
#> [,1] #> [1,] -43.74253
GMCM:::dgmm.loglik(theta, z, marginal.loglik = TRUE)
#> [,1] #> [1,] -3.653635 #> [2,] -4.037537 #> [3,] -6.198597 #> [4,] -4.256785 #> [5,] -3.879436 #> [6,] -3.802766 #> [7,] -4.805304 #> [8,] -5.308502 #> [9,] -4.146636 #> [10,] -3.653327
GMCM:::dgmm.loglik.marginal(theta, z, marginal.loglik = FALSE)
#> [,1] [,2] #> [1,] -28.94221 -28.39174
GMCM:::dgmm.loglik.marginal(theta, z, marginal.loglik = TRUE)
#> [,1] [,2] #> [1,] -3.878353 -3.511683 #> [2,] -2.048666 -2.791043 #> [3,] -3.554761 -2.915783 #> [4,] -2.166867 -2.957184 #> [5,] -2.112156 -2.455467 #> [6,] -2.355797 -2.258921 #> [7,] -3.228134 -2.750316 #> [8,] -3.082020 -3.174180 #> [9,] -2.690093 -2.188029 #> [10,] -3.825364 -3.389137
GMCM:::pgmm.marginal(z, theta)
#> [,1] [,2] #> [1,] 0.84505432 0.84019072 #> [2,] 0.18455949 0.37171423 #> [3,] 0.45460398 0.36120747 #> [4,] 0.33718720 0.72988747 #> [5,] 0.15397511 0.67091502 #> [6,] 0.09592262 0.47416290 #> [7,] 0.74791295 0.08598483 #> [8,] 0.73595788 0.26505301 #> [9,] 0.05758476 0.55218465 #> [10,] 0.85356669 0.85999327
GMCM:::qgmm.marginal(u, theta)
#> [,1] [,2] #> [1,] 11.314478 11.2413720 #> [2,] -9.679158 -4.7958888 #> [3,] -6.809556 -4.9778080 #> [4,] -8.495785 -0.8596063 #> [5,] -9.923474 -1.7148287 #> [6,] -10.457700 -3.5847277 #> [7,] 6.163773 -16.3443181 #> [8,] 5.884038 -13.6349242 #> [9,] -10.928869 -2.8746333 #> [10,] 11.714836 11.8618236