Statalist The Stata Listserver


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

Re: st: Mata st_matrix question


From   [email protected] (William Gould, Stata)
To   [email protected]
Subject   Re: st: Mata st_matrix question
Date   Fri, 16 Mar 2007 08:42:39 -0500

Carl Nelson <[email protected]> reports, 

> 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 


I suspect that the error message Carl got was not "b not found" but "+b not
found".  If I'm right, that happened because global macro A_NOT was 
note defined and thus the last line appeared to Stata as 

> gen ap =  + 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 

Am I right?

-- Bill
[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