mata
D = (1,1,1 \ 2,1,1 \ 3,1,2 \ 4,1,2 \ 5,1,3 \ 6,1,3 \ 7,2,1 \ 8,2,1 \ 9,2,2 \ 10,2,2 \ 11,2,3 \ 12,2,3)
// two factor variables,the second column has two levels(1 2), the thrird column has three levels(1 2 3) ,then I will do loop on the two factor variables
for (i=1; i<=2; i++){
for (j=1; j<=3; j++) {
Dij=st_select(D,ij) \\ gen Dij matrix when the second column select i(1 or 2) and the third column select(1 or 2 or 3), then we get six matrixes:D11 D12 D13 D21 D22 D23
colnames = "_i_j" \\ rename the colnames of matrixes Dij
Dij = colnonmissing(Dij)' \\ then perform the same operation on the generated matrix
}
}
end
i don't know how to write the two rows of program in red, can you help? thank you very much
D = (1,1,1 \ 2,1,1 \ 3,1,2 \ 4,1,2 \ 5,1,3 \ 6,1,3 \ 7,2,1 \ 8,2,1 \ 9,2,2 \ 10,2,2 \ 11,2,3 \ 12,2,3)
// two factor variables,the second column has two levels(1 2), the thrird column has three levels(1 2 3) ,then I will do loop on the two factor variables
for (i=1; i<=2; i++){
for (j=1; j<=3; j++) {
Dij=st_select(D,ij) \\ gen Dij matrix when the second column select i(1 or 2) and the third column select(1 or 2 or 3), then we get six matrixes:D11 D12 D13 D21 D22 D23
colnames = "_i_j" \\ rename the colnames of matrixes Dij
Dij = colnonmissing(Dij)' \\ then perform the same operation on the generated matrix
}
}
end
i don't know how to write the two rows of program in red, can you help? thank you very much
Comment