X-Git-Url: https://git.auder.net/?p=valse.git;a=blobdiff_plain;f=pkg%2FR%2FEMGrank.R;h=7c0d91f653a226a7b5bdf61f755eb2fee70af95c;hp=0e68cb4ecdf4dd9f9270557823d76a3875a7f72e;hb=43d76c49d2f98490abc782c7e8a8b94baee40247;hpb=5965d116de1595372c8d34281551183fd3799038 diff --git a/pkg/R/EMGrank.R b/pkg/R/EMGrank.R index 0e68cb4..7c0d91f 100644 --- a/pkg/R/EMGrank.R +++ b/pkg/R/EMGrank.R @@ -2,7 +2,6 @@ #' #' Description de EMGrank #' -#' @param phiInit ... #' @param Pi Parametre de proportion #' @param Rho Parametre initial de variance renormalisé #' @param mini Nombre minimal d'itérations dans l'algorithme EM @@ -49,6 +48,7 @@ matricize <- function(X) # R version - slow but easy to read .EMGrank_R = function(Pi, Rho, mini, maxi, X, Y, tau, rank) { + require(MASS) #matrix dimensions n = dim(X)[1] p = dim(X)[2] @@ -70,10 +70,10 @@ matricize <- function(X) ite = 1 while (ite<=mini || (ite<=maxi && sumDeltaPhi>tau)) { - #M step: Mise à jour de Beta (et donc phi) + #M step: update for Beta ( and then phi) for(r in 1:k) { - Z_indice = seq_len(n)[Z==r] #indices où Z == r + Z_indice = seq_len(n)[Z==r] #indices where Z == r if (length(Z_indice) == 0) next #U,S,V = SVD of (t(Xr)Xr)^{-1} * t(Xr) * Yr @@ -87,7 +87,7 @@ matricize <- function(X) phi[,,r] = s$u %*% diag(S) %*% t(s$v) %*% Rho[,,r] } - #Etape E et calcul de LLF + #Step E and computation of the loglikelihood sumLogLLF2 = 0 for(i in seq_len(n)) {