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

st: compiling mata code


From   Oleksandr Shepotylo <[email protected]>
To   [email protected]
Subject   st: compiling mata code
Date   Fri, 13 Jan 2006 14:07:03 -0500

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/




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