Statalist The Stata Listserver


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

st: Mata st_matrix question


From   Carl Nelson <[email protected]>
To   [email protected]
Subject   st: Mata st_matrix question
Date   Fri, 16 Mar 2007 08:13:31 -0500 (CDT)

The following stata syntax produced the error that b was not found at the gen command, even though it was listed by mat l

mata
   fh = fopen("demcoeff.mat", "r")
   X = fgetmatrix(fh)
   fclose(fh)
   st_matrix("b", X)
end
mat l b
egen lnp1m = median(lnp1)
egen lnp2m = median(lnp2)
egen lnp3m = median(lnp3)
egen lnp4m = median(lnp4)
egen lnp5m = median(lnp5)
egen z1m = median(z1)
egen z2m = median(z2)
egen lnexpm = median(lnexp)

gen ap =  $A_NOT + b[1,1]*lnp1m + b[1,2]*lnp2m + b[1,3]*lnp3m + b[1,4]*lnp4m + (1-b[1,1]-b[1,2]-b[1,3]-b[1,4])*lnp5m /*

-----code cut -----

When I add the command gen tbb1 = b[1,1] between the mat l
and egen commands, the b not found error disappears and the do file runs without error.

I'd appreciate an explanation of the error and the fix. Thanks.

Carl Nelson
ACE
UIUC
*
*   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