Oleksandr Shepotylo ([email protected]) asked about a problem
he had compiling a function in Mata:
> 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
The compilation error Oleksandr is getting is at the line
mata matuse L:\FDI\Out\weights2rd
This is a command intended only to be used at Mata's colon prompt,
either interactively or in a do-file. It is not a Mata function
which can be compiled as part of another Mata function.
The "Remarks" section in -help mata matsave- shows the proper way using
the Mata functions fopen(), fgetmatrix(), and fclose() to read a matrix
from disk.
Alan
([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/