- Z_bin = vec_bin(Z,r)
- Z_vec = Z_bin$vec #vecteur 0 et 1 aux endroits o? Z==r
- Z_indice = Z_bin$indice #renvoit les indices o? Z==r
-
- betaInit1[,,r,repet] = ginv(t(X[Z_indice,])*X[Z_indice,])%*%t(X[Z_indice,])%*%Y[Z_indice,]
+ Z_indice = seq_len(n)[Z == r] #renvoit les indices où Z==r
+ if (length(Z_indice) == 1) {
+ betaInit1[,,r,repet] = ginv(crossprod(t(X[Z_indice,]))) %*%
+ crossprod(t(X[Z_indice,]), Y[Z_indice,])
+ } else {
+ betaInit1[,,r,repet] = ginv(crossprod(X[Z_indice,])) %*%
+ crossprod(X[Z_indice,], Y[Z_indice,])
+ }