X-Git-Url: https://git.auder.net/?p=valse.git;a=blobdiff_plain;f=pkg%2FR%2FEMGLLF.R;h=4c31bb504a8c6fc6a7f02de280a7ac4234566c4b;hp=e393ec8633ddfb711f382c8188d39f46df467ee2;hb=6af1d4897dbab92a7be05068e0e15823378965d9;hpb=e9db79707709c10947e89756eb5655c0747a2a1d diff --git a/pkg/R/EMGLLF.R b/pkg/R/EMGLLF.R index e393ec8..4c31bb5 100644 --- a/pkg/R/EMGLLF.R +++ b/pkg/R/EMGLLF.R @@ -1,6 +1,6 @@ #' EMGLLF #' -#' Run a generalized EM algorithm developped for mixture of Gaussian regression +#' Run a generalized EM algorithm developped for mixture of Gaussian regression #' models with variable selection by an extension of the Lasso estimator (regularization parameter lambda). #' Reparametrization is done to ensure invariance by homothetic transformation. #' It returns a collection of models, varying the number of clusters and the sparsity in the regression mean. @@ -16,13 +16,14 @@ #' @param X matrix of covariates (of size n*p) #' @param Y matrix of responses (of size n*m) #' @param eps real, threshold to say the EM algorithm converges, by default = 1e-4 +#' @param fast boolean to enable or not the C function call #' -#' @return A list (corresponding to the model collection) defined by (phi,rho,pi,LLF,S,affec): -#' phi : regression mean for each cluster -#' rho : variance (homothetic) for each cluster -#' pi : proportion for each cluster -#' LLF : log likelihood with respect to the training set -#' S : selected variables indexes +#' @return A list (corresponding to the model collection) defined by (phi,rho,pi,llh,S,affec): +#' phi : regression mean for each cluster, an array of size p*m*k +#' rho : variance (homothetic) for each cluster, an array of size m*m*k +#' pi : proportion for each cluster, a vector of size k +#' llh : log likelihood with respect to the training set +#' S : selected variables indexes, an array of size p*m*k #' affec : cluster affectation for each observation (of the training set) #' #' @export @@ -37,14 +38,8 @@ EMGLLF <- function(phiInit, rhoInit, piInit, gamInit, mini, maxi, gamma, lambda, } # Function in C - n <- nrow(X) #nombre d'echantillons - p <- ncol(X) #nombre de covariables - m <- ncol(Y) #taille de Y (multivarié) - k <- length(piInit) #nombre de composantes dans le mélange .Call("EMGLLF", phiInit, rhoInit, piInit, gamInit, mini, maxi, gamma, lambda, - X, Y, eps, phi = double(p * m * k), rho = double(m * m * k), pi = double(k), - llh = double(1), S = double(p * m * k), affec = integer(n), n, p, m, k, - PACKAGE = "valse") + X, Y, eps, PACKAGE = "valse") } # R version - slow but easy to read