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
{
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)
{
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