Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

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


From   "Feiveson, Alan H. (JSC-SK311)" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: names in -svmat- or -xsvmat-
Date   Tue, 21 Feb 2012 09:38:15 -0600

Aha! I see now that names(string) just wants a stub, not individual names. Thanks ,Nick for pointing this out. And thanks, Roger, Scott and Kit for your suggestions.

Al

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: Tuesday, February 21, 2012 9:18 AM
To: [email protected]
Subject: Re: st: names in -svmat- or -xsvmat-

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 <[email protected]> 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)
> <[email protected]> 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/

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index