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

Re: st: compiling mata code


From   [email protected] (Alan Riley)
To   [email protected]
Subject   Re: st: compiling mata code
Date   Sat, 14 Jan 2006 18:25:53 -0600

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/



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