| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: How to convert matrix to variables in Mata
. set obs 16
obs was 0, now 16
. g retvar = .
(16 missing values generated)
. mata
------------------------------------------------- mata (type end to
exit) ---------
: st_view(X=.,.,("retvar"))
: d1 = (1,3,2,4,3,5,8,10,1,3)
: d2=invvech(d1')
: d3=vec(d2)
: d3
1
+------+
1 | 1 |
2 | 3 |
3 | 2 |
4 | 4 |
5 | 3 |
6 | 3 |
7 | 5 |
8 | 8 |
9 | 2 |
10 | 5 |
11 | 10 |
12 | 1 |
13 | 4 |
14 | 8 |
15 | 1 |
16 | 3 |
+------+
: X[.,.]=d3
: end
------------------------------------------------------------------------
-----------
. list retvar
+--------+
| retvar |
|--------|
1. | 1 |
2. | 3 |
3. | 2 |
4. | 4 |
5. | 3 |
|--------|
6. | 3 |
7. | 5 |
8. | 8 |
9. | 2 |
10. | 5 |
|--------|
11. | 10 |
12. | 1 |
13. | 4 |
14. | 8 |
15. | 1 |
|--------|
16. | 3 |
+--------+
Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/