Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: mata st_view


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: mata st_view
Date   Wed, 29 Nov 2006 22:23:21 -0500

Carl said

After I run this the matrix a in mata is correct, but the variables
in the stata data set haven't been
changed.

I would appreciate any help correcting my error. Thanks.


Carl has been bitten by the feature that any command that creates a new matrix in Mata will not populate a view of the same name. He also misunderstood _equilr, which returns r rather than taking it as input.

. webuse grunfeld


. mata
------------------------------------------------- mata (type end to exit) ---------
: st_view(a=.,.,("invest","mvalue","kstock"))

: b=a

: r=J(0,0,.)

: _equilr(b,r)

: a[.,.]=b

: end
------------------------------------------------------------------------ -----------

. l invest mvalue kstock

+--------------------------------+
| invest mvalue kstock |
|--------------------------------|
1. | .1031671 1 .0009095 |
2. | .0840466 1 .0112834 |
3. | .0762191 1 .0291251 |
4. | .0922928 1 .074923 |
5. | .0766948 1 .0471576 |
|--------------------------------|
6. | .0993131 1 .0446177 |
7. | .1124978 1 .0560731 |
8. | .1380969 1 .0936161 |
9. | .1232454 1 .0651504 |
10. | .12502 1 .0460348 |
...

Note that you cannot place a in the _equilr statement, as that creates a new matrix a rather than addressing the view and modifying the underlying variables.



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/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index