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

st: matrix colnames

From   "Edward F. Blackburne" <>
Subject   st: matrix colnames
Date   Tue, 27 Sep 2005 16:26:22 -0500 (CDT)

Hello all,

I have a frustrating problem I know someone can quickly fix.

I am trying to assign colnames to a matrix and I have included a snippet
of code below.

It should be the case (IMHO) that theta_V and theta will have same
colnames, but they don't.

With the code below, theta_V has equation names specified (in this case a
generic c1:) which are NOT in theta matrix.

If I change line 4 in the code below to matrix `theta_V'=J(4,4,1) for
example, the problem disappears and all colnames are as expected.

I have supposed the problem (feature) is that by taking the product of
(tmp'tmp) Stata introduces equation names.

How do I avoid this problem?

***********Code Snippet***************
    local names: colnames `theta'
    matrix `theta_h'=J(1,`n',1/`n')*`theta'
    matrix `tmp'=`theta'-J(`n',1,1)#`theta_h'
    matrix `theta_V'=`tmp''*`tmp'/(`n'*(`n'-1))
    matrix rownames `theta_V'=`names'
    matrix colnames `theta_V'=`names'

Thanks in advance,


Edward F. Blackburne III, PhD
Associate Professor
Economics and International Business
Sam Houston State University
*   For searches and help try:

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