From: Benjamin Auder Date: Thu, 24 Aug 2017 17:03:08 +0000 (+0200) Subject: started to look at EMGLLF.c X-Git-Url: https://git.auder.net/%7B%7B%20asset%28%27mixstore/css/static/img/doc/common.css?a=commitdiff_plain;h=17b9fa5f6004bb55e915d8916f1c9a1f128a65ce;p=valse.git started to look at EMGLLF.c --- diff --git a/pkg/R/EMGLLF.R b/pkg/R/EMGLLF.R index bf4476b..2aeea53 100644 --- a/pkg/R/EMGLLF.R +++ b/pkg/R/EMGLLF.R @@ -19,7 +19,8 @@ #' rho : parametre de variance renormalisé, calculé par l'EM #' pi : parametre des proportions renormalisé, calculé par l'EM #' LLF : log vraisemblance associée à cet échantillon, pour les valeurs estimées des paramètres -#' S : ... affec : ... +#' S : ... +#' affec : ... #' #' @export EMGLLF <- function(phiInit, rhoInit, piInit, gamInit, mini, maxi, gamma, lambda, @@ -41,6 +42,7 @@ EMGLLF <- function(phiInit, rhoInit, piInit, gamInit, mini, maxi, gamma, lambda, X, Y, eps, phi = double(p * m * k), rho = double(m * m * k), pi = double(k), LLF = double(maxi), S = double(p * m * k), affec = integer(n), n, p, m, k, PACKAGE = "valse") + list(phi = phi, rho = rho, pi = pi, llh = llh, S = S, affec=affec) } # R version - slow but easy to read @@ -190,5 +192,6 @@ EMGLLF <- function(phiInit, rhoInit, piInit, gamInit, mini, maxi, gamma, lambda, break } - list(phi = phi, rho = rho, pi = pi, llh = llh, S = S) + affec = apply(gam, 1, which.max) + list(phi = phi, rho = rho, pi = pi, llh = llh, S = S, affec=affec) } diff --git a/pkg/data/script_data.R b/pkg/data/script_data.R deleted file mode 100644 index 7479674..0000000 --- a/pkg/data/script_data.R +++ /dev/null @@ -1,15 +0,0 @@ -m=6 -p=6 - -covY = array(0,dim = c(m,m,2)) -covY[,,1] = diag(m) -covY[,,2] = diag(m) - -Beta = array(0, dim = c(p, m, 2)) -Beta[1:4,1:4,1] = 3*diag(4) -Beta[1:4,1:4,2] = -2*diag(4) - -#Data = generateXY(200, c(0.5,0.5), rep(0,p), Beta, diag(p), covY) -# -#Res = valse(Data$X,Data$Y, fast=FALSE, plot=FALSE, verbose = TRUE, kmax=3, size_coll_mod = 50, selecMod = "DDSE", mini = 50, maxi=100) -#plot(Res$tableau[,3], -Res$tableau[,4]) diff --git a/test/script_data.R b/test/script_data.R new file mode 100644 index 0000000..102961c --- /dev/null +++ b/test/script_data.R @@ -0,0 +1,15 @@ +m=6 +p=6 + +covY = array(0,dim = c(m,m,2)) +covY[,,1] = diag(m) +covY[,,2] = diag(m) + +Beta = array(0, dim = c(p, m, 2)) +Beta[1:4,1:4,1] = 3*diag(4) +Beta[1:4,1:4,2] = -2*diag(4) + +Data = generateXY(200, c(0.5,0.5), rep(0,p), Beta, diag(p), covY) +# +Res = valse(Data$X,Data$Y, fast=FALSE, plot=FALSE, verbose = TRUE, kmax=3, size_coll_mod = 50, selecMod = "DDSE", mini = 50, maxi=100) +plot(Res$tableau[,3], -Res$tableau[,4])