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: Converting a vetor into a matrix


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Converting a vetor into a matrix
Date   Mon, 24 Sep 2012 13:28:42 +0100

The error message does tell what you are doing wrong. Your vector is a
view, meaning a view of (some of) the data. You can't reshape it. It
makes no sense, as far as the Stata dataset is concerned, to ask to
change a vector of values in some observations into a matrix. You need
to copy the view to another vector first. Or use -st_data()- not
-st_view()- to define your vector.

Nick

On Mon, Sep 24, 2012 at 1:20 PM, André Gyllenram
<[email protected]> wrote:
> Hello,
>
> I have read that in mata you can use rowshape or colshape to convert a vector into a matrix. But it does not seem to work for me. If I have a 9x1 vector and want to convert it to a 3*3 matrix how do I do that?
>
> If A is the 9x1 vector and I write:
>
> rowshape(A,3) i get this message:
>
>
> "rowshape():  3103  view found where array required
>                  <istmt>:     -  function returned error"
>
>
>
> Sorry if this has been asked before but i could not find it.

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