Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: compiling mata code


From   Oleksandr Shepotylo <shepotil@econ.umd.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: compiling mata code
Date   Fri, 13 Jan 2006 15:23:25 -0500

Actually, after experimenting with the code for a while I found that it stops when loading the saved matrix at this line:

mata matuse L:\FDI\Out\weights2rd

Does it mean that I can not load matrix inside the function?



Oleksandr Shepotylo wrote:


Hi,

I want to write a mata function that will take an existing variable X from the loaded dataset,
multiply it by matrix W that also exist, and create a new stata variable Y=W*X .

I wrote a code included below which works fine when I substitute my arguments by real variable names "X" and "Y" but does not want to be compiled as it is.

mata:
function spatlag(string scalar index, string scalar windex)
{
X=J(0,0,.)
Y=J(0,0,.)
mata matuse L:\FDI\Out\weights2rd
st_addvar("float", windex)
st_view(Y,., windex)
st_view(X,., index)
Y[.,.]=(I(11)#W)*X
}
mata mosave spatlag(), dir(PERSONAL)
end

It stops at line: st_addvar("float", windex).

Any suggestions about what is wrong with my code?

Thanks,

Oleksandr.


*
* 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/
*
*   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–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index