# 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]
if (length(Z_indice) == 0)
next
#U,S,V = SVD of (t(Xr)Xr)^{-1} * t(Xr) * Yr
- s = svd( ginv(crossprod(matricize(X[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
}
sumLogLLF2 = sumLogLLF2 + log(sumLLF1)
}
-
+
LLF = -1/n * sumLogLLF2
#update distance parameter to check algorithm convergence (delta(phi, Phi))
n = nrow(Y)
m = ncol(Y)
p = ncol(X)
- nIte = 20
+ nIte = 20
Zinit1 = array(0, dim=c(n,nIte))
betaInit1 = array(0, dim=c(p,m,k,nIte))
sigmaInit1 = array(0, dim = c(m,m,k,nIte))