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: RE: submatrix


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: RE: submatrix
Date   Tue, 15 Nov 2011 12:14:32 +0000

Use Mata: e.g. 

: y = (1::81)

: y2 = rowshape(y,9)

: y2
        1    2    3    4    5    6    7    8    9
    +----------------------------------------------+
  1 |   1    2    3    4    5    6    7    8    9  |
  2 |  10   11   12   13   14   15   16   17   18  |
  3 |  19   20   21   22   23   24   25   26   27  |
  4 |  28   29   30   31   32   33   34   35   36  |
  5 |  37   38   39   40   41   42   43   44   45  |
  6 |  46   47   48   49   50   51   52   53   54  |
  7 |  55   56   57   58   59   60   61   62   63  |
  8 |  64   65   66   67   68   69   70   71   72  |
  9 |  73   74   75   76   77   78   79   80   81  |
    +----------------------------------------------+

Nick 
[email protected] 

behailu ayele

Is there anyway, then, I can actually restructure my initial matrix in
a way that it has the dimensions I want (9 by 9) instead of one single
row?

On 11/15/11, Nick Cox <[email protected]> wrote:
> Yes; Stata can only regard it as an error if you refer to rows and/or
> columns that don't exist.

behailu ayele

> Thanks very much. I now went to matrix extraction and I think know my
> problem, now. My estimation result reads only as row. Whatever I want
> to extract,, it works when I specify as one row and any number of
> columns. What I mean is, it works when I do either of these:
>
> matrix A = b[1, "b1".."b9"]
>
> matrix A = b[1, "a1".."a9"]
>
>
> but it says conformability error whenever I do
>
> matrix A = b[1..2, "a1".."a9"]
>
>
> I am thinking I need to restructure my estimation result such that it
> is a proper matrix to begin with (with 9 by 9 dimension) and not just
> a matrix with one row and several columns.
>
> Thankyou again.
>
> behailu
>
>
> On 11/15/11, Nick Cox <[email protected]> wrote:
>> This is covered by the help on -matrix extraction-
>>
>> matrix new = b[1..9, 7..9]
>>
>> The = operator for assignment should be used (not ==).
>>
>> Nick
>> [email protected]
>>
>> behailu ayele
>>
>> I have problem extracting parts of a matrix I estimated.
>>
>> my matrix e(b) is  9 by 9. Now I want to extract the first line and I did
>> this.
>>
>> matrix b=e(b)
>> and then
>>  matrix new==b[1,1..9]
>>
>> my problem is  when i want to have a 3 by 9 matrix of the last three
>> columns
>>
>> is this not what I am supposed to do?
>>
>> matrix new==b[7/9,1..9]
>

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