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: Making a matrix out of three variables


From   Eilya Torshizian <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: Making a matrix out of three variables
Date   Thu, 16 Jan 2014 20:59:08 +0000

Hi Nick,

Thanks for your reply. I did rephrase some parts before reposting this, however your response helps me to correct my bad explanation.

I have 3 variables derived from Arcmap (GIS). A and B include the regions' numbers and C represents their shared area. I need to make a spatial matrix out of these three variables.

To fix ideas, let's assume an area of C2 square meters of region A1 overlaps with region A2. This is what the second row of the following hypothesised data represents, 

A1 | A1 | C1
A1 | A2 | C2
A1 | A4 | C3
A1 | A5 | C4
A2 | A2 | C5
A2 | A1 | C6
A2 | A3 | C7
A3 | A2 | C8
A3 | A3 | C9
...
I need to derive a spatial matrix out of these variables' values. The matrix should include 0 values for the regions that do not overlap. The desired final matrix should look like this,

       A1 A2 A3 A4 A5
 A1 C1 C2  0   C3  0
 A2 C6 C5 C7  0    0
 A3  0  C8 C9  0    0
 A4 ...
 A5 ...

Kind regards,
Eilya.

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: Friday, 17 January 2014 9:15 a.m.
To: [email protected]
Subject: Re: st: Making a matrix out of three variables

You asked this before and no-one answered, I guess because no-one could see the point to  what you were asking.

On the face of it you want to populate a 2 x 5 matrix so that 6 values are derived from elsewhere, placed in a not very obvious pattern and the other 4 values are 0. I wouldn't even imagine using nested loops as the natural way to build it is to type the values interactively.

If this is a misunderstanding of your problem you may need to explain it quite differently.
Nick
[email protected]


On 16 January 2014 20:03, Eilya Torshizian <[email protected]> wrote:
> Dear Statalist members,
>
> I need to convert three variables to a matrix. The values of variable 
> A and B should be used as row and column names of the output matrix.  
> Let's assume three columns of data, where A, B and C are the name of 
> my numeric variables,
>
> A      B      C
> A1 | A1 | C1
> A1 | A2 | C2
> A1 | A4 | C3
> A1 | A5 | C4
> A2 | A2 | C5
> A2 | A1 | C6
> A2 | A3 | C7
>
> I need to convert these to the following matrix,
>
>       A1 A2 A3 A4 A5
> A1 C1 C2  0   C3  0
> A2 C6 C5  C7  0   0
>
> As I have a wide range of observations, I would like to avoid nested loops.
>
> Thanks,
> Eilya.
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index