Hi everyone,
I am wirting my Master-Thesis and I am relatively new to Stata and especially to Mata.
My problem is the following: I have observations about the population share and the county every person is living at.
Now I need to create a matrix to compute several diversity indices (cultural diversity, linguistic diversity, genetic diversity).
For one county it is not a problem to develop that matrix, I did it in the following way:
mkmat share if county==1, matrix(share1)
But because there are a lot of other counties and a lot of years I am examining, I don't like to write that command every single time for every single county.
I have also tried it with foreach and forvalues but I did not get one matrix for one county but I got one matrix for all counties together. But with that matrix for all counties I cannot compute my diversity indices the right way.
I hope, you understood my problem.
Best,
Hans
I am wirting my Master-Thesis and I am relatively new to Stata and especially to Mata.
My problem is the following: I have observations about the population share and the county every person is living at.
Now I need to create a matrix to compute several diversity indices (cultural diversity, linguistic diversity, genetic diversity).
For one county it is not a problem to develop that matrix, I did it in the following way:
mkmat share if county==1, matrix(share1)
But because there are a lot of other counties and a lot of years I am examining, I don't like to write that command every single time for every single county.
I have also tried it with foreach and forvalues but I did not get one matrix for one county but I got one matrix for all counties together. But with that matrix for all counties I cannot compute my diversity indices the right way.
I hope, you understood my problem.
Best,
Hans
Comment