Statalist


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

Re: st: st_subview() in Mata


From   [email protected] (William Gould, StataCorp LP)
To   [email protected]
Subject   Re: st: st_subview() in Mata
Date   Mon, 13 Aug 2007 08:22:01 -0500

Nguyen Cong Minh <[email protected]> writes, 

>   I used some Mata functions, and used st_view() to get the matrix from
>   data, then use st_subview() to get a submatrix from that matrix.
>
>   ------ Mata code -------
>
>    real matrix V, Yall, Xall
>    neq = st_local("neqn")
>    st_view(V,., tokens(varname))
>    st_subview(Yall,V,.,(1\neq))
>    st_subview(Xall,V,.,(neq+1\cols(V)))
>    
>    It reported the error:
>                 mysub():  3250  type mismatch
>                 <istmt>:     -  function returned error

I wonder if the error is where Nguyen thinks it is because I see nothing 
incorrect in the part of the program quoted.  Right now, all we know for sure 
is that in Nguyen's subroutine -mysub()- there is a "type mismatch" error, 
meaning probably that a string variable appeared where a real was expected, 
or vice versa.  (Type mismatch could also be complex in place of a real, 
string in place of a complex, etc.)

I suggest the following:

        . mata

        : mata set matalnum on

        : <repeat problem> 

        : mata set matalnum off

With -matalnum- set on, Mata will report the line number in mysub() 
where the error occurs and then Ngyuen will be know exactly where to 
look.

Don't forget to -mata set matalnum off- afterwards.  With -matalnum on-, 
optimization cannot be performed, and so programs compiled that way 
execute more slowly than those compiled with -matalnum off-.

-- Bill
[email protected]
*
*   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