[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Austin Nichols <austinnichols@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: subsetting a matrix by rowname and column name |

Date |
Sat, 21 Mar 2009 18:09:50 -0400 |

Jacob Wegelin <jacob.wegelin@gmail.com> : Try: sysuse auto, clear g b=1 qui probit foreign mpg mat b=e(b) scalar b=el(matrix(b),1,colnumb(matrix(b),"mpg")) di scalar(b) di b Note that matrices, scalars, and variables share the same namespace, which often leads to cryptic error messages or huge mistakes for the less careful (you may prefer to use a local instead to avoid this problem). So say matrix(b) instead of b, and scalar(p) instead of p. On Sat, Mar 21, 2009 at 5:43 PM, Jacob Wegelin <jacob.wegelin@gmail.com> wrote: > The results below indicate that > > (1) One can extract a cell from a matrix using the row and column names, but > > (2) the value returned cannot be assigned to a scalar, only to a > one-by-one matrix. (See error below.) > > (3) By contrast, when one extracts a cell from a matrix using row and > column *indices*, the value can be assigned to a scalar. > > Is there some good reason for this? I'd ideally like to extract a > scalar by row and column name, since this would be less error-prone. > > Thanks for any insights * * 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: subsetting a matrix by rowname and column name***From:*Jacob Wegelin <jacob.wegelin@gmail.com>

**References**:**st: subsetting a matrix by rowname and column name***From:*Jacob Wegelin <jacob.wegelin@gmail.com>

- Prev by Date:
**Re: st: dprobit/nocons/mfx question** - Next by Date:
**Re: st: variable selection and bootstrap** - Previous by thread:
**st: subsetting a matrix by rowname and column name** - Next by thread:
**Re: st: subsetting a matrix by rowname and column name** - Index(es):

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