- Z_bin = vec_bin(Z,r)
- Z_vec = Z_bin$Z #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,])
+ }