I have a matrix A that I want to jumble the rows and take the logs of. Then taking the elements on the diagonal and creating a variable in Stata.
Tried this bit of code.
mata:
for (i=1; i<=3; i++) {
jumble(A)
logA`i' = log(A)
Ad`i' = diagonal(logA`i')
st_matrix("Ad`i'", Ad`i')
}
end
But it merged all of it into i. I know the code is clunky, but I'm not familiar with loops in Mata.
Thanks, Gene
Tried this bit of code.
mata:
for (i=1; i<=3; i++) {
jumble(A)
logA`i' = log(A)
Ad`i' = diagonal(logA`i')
st_matrix("Ad`i'", Ad`i')
}
end
But it merged all of it into i. I know the code is clunky, but I'm not familiar with loops in Mata.
Thanks, Gene
Comment