Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: names in -svmat- or -xsvmat-


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: names in -svmat- or -xsvmat-
Date   Tue, 21 Feb 2012 15:17:59 +0000

Or, as Kit points out, assign the names you want to the columns of the
matrix and then use -names(col)-.

Nick

On Tue, Feb 21, 2012 at 3:13 PM, Nick Cox <njcoxstata@gmail.com> wrote:
> -xsvmat- is from SSC. Please remember...
>
> What you are trying is to specify your own names, but the help for
> -xsvmat- implies that at most you can specify a stub.
>
>  names(string) names the variables string1, string2, ..., stringn, where
>        string is a user-specified string and n is the number of columns of the
>        matrix.
>
> The blame here, if there is any, goes all the way back to Stata's
> -svmat-. Its -names()- option specifies rules for new names; fancy
> thinking that one could just give the names!
>
> However, -svmat2- from
>
> STB-56  dm79  . . . . . . . . . . . . . . . . . . Yet more new matrix commands
>        (help matcorr, matewmf, matvsort, svmat2 if installed)  . .  N. J. Cox
>        7/00    pp.4--8; STB Reprints Vol 10, pp.17--23
>        commands to produce a correlation matrix, elementwise monadic
>        function of another matrix, selected subsets of matrix rows
>        and columns, vec or vech of a matrix, elements sorted within
>        a vector, matrix from a vector, and commands to save matrices
>        see mata matrix language incorporated into Stata 9.0
>
> allows a namelist. I have not looked at or used it in an age, so can't
> vouch for how it works with modern Statas.
>
> Nick
>
> On Tue, Feb 21, 2012 at 3:00 PM, Feiveson, Alan H. (JSC-SK311)
> <alan.h.feiveson@nasa.gov> wrote:
>> OK - I give up. Can someone please given an example of correct usage for the -names- option in -svmat- or -xsvmat- ? Thanks.
>>
>> Al Feiveson
>>
>>
>> . matrix list A
>>
>> A[10,5]
>>             c1          c2          c3          c4          c5
>>  r1   .00821462  -.73199648  -.80059997  -1.3444995  -.73588118
>>  r2   .38707652  -1.1705186   .27901232   .33415055  -.62922745
>>  r3   1.5611447   .82326399  -.58581245    .6017733   .05173269
>>  r4  -1.6878907  -1.4067196   1.0890974  -1.3119514    .0030182
>>  r5  -1.1670293  -1.6118597   1.0981531   1.1144127   .47038956
>>  r6  -1.2363605  -.10125067   .06286368  -1.0167974   .07966359
>>  r7    .6152531  -1.0821879  -.30905276  -.02234645   -.0612078
>>  r8  -.30916348   -.6575941  -1.3403386   .80353234   1.7169523
>>  r9   .61394245   -.0329281  -.14108694  -2.0729119  -.83697348
>> r10   .65664138  -1.4944258   3.2871298  -1.3584897   .36629252
>>
>>
>>
>> . xsvmat A,saving(bull,replace) names(y  x1  x2  x3  x4)
>> new variables cannot be uniquely named or already defined
>> r(110);
>>
>> . xsvmat A,saving(bull,replace) names(" y x1 x2 x3 x4")
>> new variables cannot be uniquely named or already defined
>>
>> . xsvmat A,saving(bull,replace) names(y, x1, x2, x3, x4)
>> invalid syntax
>> r(198);
>>
>> . xsvmat A,saving(bull,replace) names("y, x1, x2, x3, x4")
>> invalid syntax
>> r(198);
>>
>> . xsvmat A,saving(bull,replace) names("y", "x1", "x2", "x3", "x4")
>> invalid syntax
>> r(198);
>>

*
*   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/


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