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

From |
"Scott Merryman" <scott.merryman@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Function el() fails |

Date |
Fri, 15 Aug 2008 21:56:15 -0500 |

You could use the pseudofunction -matrix()- to force the term p to be interpreted as a matrix (see [P] page 262, "Name conflicts in expressions (namespaces)" and G Kolev's "Stata tip 31: Scalar or variable? The problem of ambiguous names", SJ 6,2). dis el(matrix(p),1,1) Scott On Fri, Aug 15, 2008 at 4:54 PM, Sergiy Radyakin <serjradyakin@gmail.com> wrote: > Dear All, > > after investigating why my program sometimes breaks, I have found a > problem (observed in Stata 9 and Stata 10 for Windows) with the > function el(matrixname, row, col ), which could be reproduces with the > following sequence of commands: > > > // ----- BEGIN ------- > sysuse auto > > matrix p=1 > matrix a=p > > matrix dir > > matrix list a > di a[1,1] > di el(a,1,1) > > matrix list p > di p[1,1] > di el(p,1,1) > // ----- END ------- > > According to the help file for Stata 9: > > el(A,i,j) the i,j element of A (same as A[i,j]) > > Note that the program above works for matrix name "a" and not "p". > This made it difficult to identify the problem. Because the problem is > observed for some datasets and not for others. > > It seems that the namespace of variables and matrix names in Stata is > overlapping. > I've met the messages earlier regarding what namespaces are shared, > but I can't find them at the moment. The manual explicitly defines the > term "namespace" in the [P] matrix, (page 235 in 10th edition). It > also mentions that there is a single namespace for scalars and > matrices, however it does mention variables in a rather confusing > statement: > > "Scalars and matrices share the same namespace; i.e., scalars and > matrices may have the same names as variables in the dataset, etc., > but they cannot have the same names as each other." > > Confusion here is that indeed Stata allows me to have a matrix with > the same name as a variable, but I'd really like the built-in commands > and functions to be able to WORK with that matrix. (Function el() as > all functions in Stata is built-in). > > I wonder if anyone could elaborate on which namespaces are shared in > Stata, in particular: > > variables > locals > globals > scalars > matrices > programs > classes > all sort of mata objects > all sort of graphics related styles, patterns, etc > .... > [not sure how long the list is, but the above list is definitely not complete] > > I am not sure that the problem above is an intended behavior. In any > case it makes the case that el(a,1,1) is NOT equivalent to A[1,1] > against what the help file says. > If this is not an intended behaviour, can this be fixed? > > Thank you, > Sergiy Radyakin > > CC: Stata Technical Support * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: Function el() fails***From:*"Sergiy Radyakin" <serjradyakin@gmail.com>

**References**:**st: Function el() fails***From:*"Sergiy Radyakin" <serjradyakin@gmail.com>

- Prev by Date:
**st: Function el() fails** - Next by Date:
**st: box plot with 2nd variable** - Previous by thread:
**st: Function el() fails** - Next by thread:
**Re: st: Function el() fails** - Index(es):

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