From: emilie Date: Wed, 19 Apr 2017 11:46:17 +0000 (+0200) Subject: fix few things X-Git-Url: https://git.auder.net/%7B%7B%20asset%28%27mixstore/css/store/view-usecase.css%27%29%20%7D%7D?a=commitdiff_plain;h=96b591b7a76da9780e766ead693eb065281b6d62;p=valse.git fix few things --- diff --git a/pkg/R/EMGrank.R b/pkg/R/EMGrank.R index db40948..db0b8f2 100644 --- a/pkg/R/EMGrank.R +++ b/pkg/R/EMGrank.R @@ -73,8 +73,8 @@ matricize <- function(X) if (length(Z_indice) == 0) next # U,S,V = SVD of (t(Xr)Xr)^{-1} * t(Xr) * Yr - s <- svd(MASS::ginv(crossprod(matricize(X[Z_indice, ]))) - %*% crossprod(matricize(X[Z_indice, ]), matricize(Y[Z_indice, ]))) + s <- svd(MASS::ginv(crossprod(matricize(X[Z_indice, ]))) %*% + crossprod(matricize(X[Z_indice, ]), matricize(Y[Z_indice, ]))) S <- s$d # Set m-rank(r) singular values to zero, and recompose best rank(r) approximation # of the initial product diff --git a/pkg/R/constructionModelesLassoMLE.R b/pkg/R/constructionModelesLassoMLE.R index 4f23bb0..8f93fb8 100644 --- a/pkg/R/constructionModelesLassoMLE.R +++ b/pkg/R/constructionModelesLassoMLE.R @@ -71,8 +71,8 @@ constructionModelesLassoMLE <- function(phiInit, rhoInit, piInit, gamInit, mini, { delta <- (Y %*% rhoLambda[, , r] - (X[, col.sel] %*% t(phiLambda[col.sel, , r]))) } else delta <- (Y %*% rhoLambda[, , r] - (X[, col.sel] %*% phiLambda[col.sel, , r])) - densite <- densite + piLambda[r] * det(rhoLambda[, , r])/(sqrt(2 * base::pi))^m - * exp(-diag(tcrossprod(delta))/2) + densite <- densite + piLambda[r] * det(rhoLambda[, , r])/(sqrt(2 * base::pi))^m * + exp(-diag(tcrossprod(delta))/2) } llhLambda <- c(sum(log(densite)), (dimension + m + 1) * k - 1) list(phi = phiLambda, rho = rhoLambda, pi = piLambda, llh = llhLambda) diff --git a/pkg/R/initSmallEM.R b/pkg/R/initSmallEM.R index d1ade1c..ba95586 100644 --- a/pkg/R/initSmallEM.R +++ b/pkg/R/initSmallEM.R @@ -54,8 +54,8 @@ initSmallEM <- function(k, X, Y, fast = TRUE) { dotProduct <- tcrossprod(Y[i, ] %*% rhoInit1[, , r, repet] - X[i, ] %*% phiInit1[, , r, repet]) - Gam[i, r] <- piInit1[repet, r] - * det(rhoInit1[, , r, repet]) * exp(-0.5 * dotProduct) + Gam[i, r] <- piInit1[repet, r] * + det(rhoInit1[, , r, repet]) * exp(-0.5 * dotProduct) } sumGamI <- sum(Gam[i, ]) gamInit1[i, , repet] <- Gam[i, ]/sumGamI