Hi Statalist: I do not have much experience writing code for Stata except for the routines with which I am most familiar. So, I am not certain how to write code to achieve the following:
1714001 1 0 1 1 0 0 0 0 0 0
1714001 0 0 1 0 0 0 0 0 0 0
1714001 1 1 1 1 1 0 0 0 0 1
1714001 0 1 1 0 0 0 1 0 0 0
1714001 1 1 1 1 1 0 0 0 0 1
1714071 1 1 1 1 1 1 1 1 1 1
1714071 1 1 1 1 1 1 1 0 0 0
1714071 0 0 1 0 0 1 1 0 0 0
1714071 1 1 1 1 0 0 1 0 1 1
1714071 1 0 1 1 1 1 1 0 0 1
1714071 1 1 1 1 1 0 1 0 0 1
1714071 1 1 1 1 1 0 0 0 0 0
1714081 0 0 0 1 0 0 1 0 0 0
1714081 1 1 1 1 1 1 1 0 1 0
1714081 0 0 0 0 0 0 0 0 0 0
Given the above, it seems I would first somehow need to use mkmat looping through the values of groupID. Then, I'd need need to loop through A'*A for each stored matrix, A-Z. After this, I could vertically append the saved results for each operation with mat new = A/B/C/..../Z, but ideally without having to write out all 1,136 elements. I'd appreciate any help on how to get started. The leads I've found from previous posts, such as subsets using complicated criterion or the help manual haven't provided quite the help I need.
Thanks - Ebony
- Ultimately, I need to append or 'vertically stack the rows' of a set of saved matrices resulting from a series of matrix operations.
- This requires first having saved the results from the series matrix operations, namely A'*A (i.e. A-transpose by A), for matrices A-Z.
- Before this, however, I need to create matrices A-Z from an existing Stata dataset, which has 8,981 observations nested into 1,136 groups identified by 'groupID' and where groups are of different sizes, n. Below is an example, noting that for this example, I'd want to start by making three matrices of size 5x10, 7x10 and 3x10:
1714001 1 0 1 1 0 0 0 0 0 0
1714001 0 0 1 0 0 0 0 0 0 0
1714001 1 1 1 1 1 0 0 0 0 1
1714001 0 1 1 0 0 0 1 0 0 0
1714001 1 1 1 1 1 0 0 0 0 1
1714071 1 1 1 1 1 1 1 1 1 1
1714071 1 1 1 1 1 1 1 0 0 0
1714071 0 0 1 0 0 1 1 0 0 0
1714071 1 1 1 1 0 0 1 0 1 1
1714071 1 0 1 1 1 1 1 0 0 1
1714071 1 1 1 1 1 0 1 0 0 1
1714071 1 1 1 1 1 0 0 0 0 0
1714081 0 0 0 1 0 0 1 0 0 0
1714081 1 1 1 1 1 1 1 0 1 0
1714081 0 0 0 0 0 0 0 0 0 0
Given the above, it seems I would first somehow need to use mkmat looping through the values of groupID. Then, I'd need need to loop through A'*A for each stored matrix, A-Z. After this, I could vertically append the saved results for each operation with mat new = A/B/C/..../Z, but ideally without having to write out all 1,136 elements. I'd appreciate any help on how to get started. The leads I've found from previous posts, such as subsets using complicated criterion or the help manual haven't provided quite the help I need.
Thanks - Ebony
Comment