Hi, I have a dataset with the following structure. ColumnA ColumnB ColumnC ClassA OtherStud WorkWith AA DD 1 AA EE 0 AA BB 1 BB FF 1 BB GG 1 BB KK 0 CC AA 1 CC BB 1 ColumnA refers to students in ClassroomA, and Column B refers to "Other Students" in the school who could act as work and/or playmates. Note, ColumnB could also include some of the same students in ColumnA(ClassA) who work with each other (For example, Students: AA and BB). If a Student in Classroom A works with a student in ClassroomB, ColumnC takes the value of 1, and 0(zero) if otherwise So, looking at ColumnA, we find that there are three students: AA, BB and CC. Student_AA for instance interacts with three students <DD, EE, BB> but only works with DD and BB. Similarly, Student_CC interacts with two students <AA, and BB> and works and plays with each of them. Now, I am interested in constructing a matrix indicating which students in ClassroomA work with each other. This means that student_AA for instance works with student_BB, who is in his/her classroom, hence the cell in their matrix will have a "1". Again, Student_CC in ClassroomA works with 2 other members of his/her own class<ie, AA and BB>. So CC would have two "1s" in the matrix. The resulting matrix for the "Works With" relation (ColumnC) among the 3 students in ClassroomA would look like this. AA BB CC AA 0 1 0 BB 0 0 0 CC 1 1 0 This matrix is the output I am interested in, and need to produce for the relationship specified in Column C. I would certainly appreciate some ideas to help me produce this. Thanks in advance for your assistance. Sincerely, Cy |
|
Open a new instance of SPSS. Copy the syntax below into the syntax window. Run it. See if this is what you want. data list list/rowkid (a2) colkid(a2) link(f1). begin data AA DD 1 AA EE 0 AA BB 1 BB FF 1 BB GG 1 BB KK 0 CC AA 1 CC BB 1 end data. autorecode variables = rowkid colkid /into nrowkid ncolkid /group. select if link eq 1. * Custom Tables. CTABLES /VLABELS VARIABLES=nrowkid ncolkid DISPLAY=BOTH /TABLE nrowkid BY ncolkid [COUNT F40.0] /CATEGORIES VARIABLES=nrowkid ncolkid ORDER=A KEY=VALUE EMPTY=INCLUDE. Art Kendall Social Research Consultants On 10/22/2010 1:29 AM, Chao Yawo wrote: ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARDHi, I have a dataset with the following structure. ColumnA ColumnB ColumnC ClassA OtherStud WorkWith AA DD 1 AA EE 0 AA BB 1 BB FF 1 BB GG 1 BB KK 0 CC AA 1 CC BB 1 ColumnA refers to students in ClassroomA, and Column B refers to "Other Students" in the school who could act as work and/or playmates.Note, ColumnB could also include some of the same students in ColumnA(ClassA) who work with each other (For example, Students: AA and BB). If a Student in Classroom A works with a student in ClassroomB, ColumnC takes the value of 1, and 0(zero) if otherwise So, looking at ColumnA, we find that there are three students: AA, BB and CC. Student_AA for instance interacts with three students <DD, EE, BB> but only works with DD and BB. Similarly, Student_CC interacts with two students <AA, and BB> and works and plays with each of them. Now, I am interested in constructing a matrix indicating which students in ClassroomA work with each other. This means that student_AA for instance works with student_BB, who is in his/her classroom, hence the cell in their matrix will have a "1".Again, Student_CC in ClassroomA works with 2 other members of his/her own class<ie, AA and BB>. So CC would have two "1s" in the matrix. The resulting matrix for the "Works With" relation (ColumnC) among the 3 students in ClassroomA would look like this. AA BB CC AA 0 1 0 BB 0 0 0 CC 1 1 0 This matrix is the output I am interested in, and need to produce for the relationship specified in Column C.I would certainly appreciate some ideas to help me produce this. Thanks in advance for your assistance. Sincerely, Cy
Art Kendall
Social Research Consultants |
|
Art, thanks very much -- it worked, mostly, but it produced the warning below:
>Warning # 1116 >Under LIST input, insufficient data were contained on one record to fulfill
>the variable list. Remaining numeric variables have been set to the >system-missing value and string variables have been set to blanks Here is the matrix I got: ncolkid AA BB CC DD EE FF GG KK
Count Count Count Count Count Count Count Count Count
nrowkid 0 0 0 0 0 0 0 0 0
AA 0 0 1 0 1 0 0 0 0
BB 0 0 0 0 0 0 1 1 0
CC 0 1 1 0 0 0 0 0 0
DD 0 0 0 0 0 0 0 0 0
EE 0 0 0 0 0 0 0 0 0
FF 0 0 0 0 0 0 0 0 0
GG 0 0 0 0 0 0 0 0 0
KK 0 0 0 0 0 0 0 0 0
I will now appy it to some real data: will report back soon. rgds, CY On Fri, Oct 22, 2010 at 7:57 AM, Art Kendall <[hidden email]> wrote: data list list/rowkid (a2) colkid(a2) link(f1). |
|
Did the paste cause some blank lines? Art On 10/22/2010 8:43 AM, Chao Yawo wrote: Art, thanks very much -- it worked, mostly, but it produced the warning below:===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Art Kendall
Social Research Consultants |
|
Art On 10/22/2010 9:23 AM, Chao Yawo wrote: Art, thanks very much for your continuing assistance. I checked, but there were no break lines. I am attaching the syntax file for your perusal, if that would help. warmest regards, Cy===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Art Kendall
Social Research Consultants |
|
Ok. I will check again and delete the line and re-run it. Will let you know how it goes. rgds, Cy
On Fri, Oct 22, 2010 at 10:44 AM, Art Kendall <[hidden email]> wrote:
|
|
In reply to this post by Chao Yawo
Cy
Art has already supplied a solution, but you don't
say how many students there are in total, but one thing you could try (if there
are not too many) would be to feed the data in as two string variables
columna and columnb and then do:
crosstabs columna by columnb .
Thiswould at least show you the
combinations.
|
|
Administrator
|
In reply to this post by Chao Yawo
Shouldn't such a matrix be symmetrical?
ie AA->BB IFF BB->AA??? Please clarify why this is not the case. On Fri, 22 Oct 2010 21:12:24 +0200, John F Hall <[hidden email]> wrote: >Cy > >Art has already supplied a solution, but you don't say how many students there are in total, but one thing you could try (if there are not too many) would be to feed the data in as two string variables columna and columnb and then do: > >crosstabs columna by columnb . > >Thiswould at least show you the combinations. > >John Hall >[hidden email] >http://surveyresearch.weebly.com > > ----- Original Message ----- > From: Chao Yawo > To: [hidden email] > Sent: Friday, October 22, 2010 7:29 AM > Subject: Help with Square Matrix > > >Hi, > >I have a dataset with the following structure. > > >ColumnA ColumnB ColumnC >ClassA OtherStud WorkWith > >AA DD 1 >AA EE 0 >AA BB 1 >BB FF 1 >BB GG 1 >BB KK 0 >CC AA 1 >CC BB 1 > > >ColumnA refers to students in ClassroomA, and Column B refers to "Other >Students" in the school who could act as work and/or playmates. Note, work with each other (For example, Students: AA and BB). > >If a Student in Classroom A works with a student in ClassroomB, ColumnC >takes the value of 1, and 0(zero) if otherwise > >So, looking at ColumnA, we find that there are three students: AA, BB and >CC. Student_AA for instance interacts with three students <DD, EE, BB> but only >works with DD and BB. Similarly, Student_CC interacts with two students ><AA, and BB> and works and plays with each of them. > >Now, I am interested in constructing a matrix indicating which >students in ClassroomA work with each other. This means >that student_AA for instance works with student_BB, who is in his/her >classroom, hence the cell in their matrix will have a "1". Again, >his/her own class<ie, AA and BB>. So CC would have two "1s" in the matrix. > >The resulting matrix for the "Works With" relation (ColumnC) among the 3 >students in ClassroomA would look like this. > > AA BB CC >AA 0 1 0 >BB 0 0 0 >CC 1 1 0 > >This matrix is the output I am interested in, and need to produce for the to help me produce this. > > >Thanks in advance for your assistance. > >Sincerely, Cy > > ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
|
In reply to this post by Chao Yawo
I used Art's syntax and tried this to see what the
result looked like: does it help as an intermediate step?
data list list/rowkid (a2) colkid(a2)
link(f1).
begin data AA DD 1 AA EE 0 AA BB 1 BB FF 1 BB GG 1 BB KK 0 CC AA 1 CC BB 1 end data. cros rowkid by colkid by link.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
In reply to this post by David Marso
in this case not necessarily since we are interested in student's perceptions of who their playmates are. A can perceive and name B as a playmate, but not necessarily the converse. cheers, CY
On Fri, Oct 22, 2010 at 11:58 PM, David Marso <[hidden email]> wrote: Shouldn't such a matrix be symmetrical? |
|
In reply to this post by David Marso
The OP was ambiguous. The example output was not entirely consistent
with the explanation. I guessed that the example was what was wanted. If we think of rows as chooser and the columns as chosen, AA can choose BB without BB choosing AA. Many people can choose a "leader" to work with without the leader choosing them. ( The example in the OP has this asymmetry.) If we think of the relation as "seen working together", then it should be symmetric (or only read into other analyses as an upper triangular matrix which would assume symmetry). Art Kendall Social Research Consultants On 10/22/2010 11:58 PM, David Marso wrote: > Shouldn't such a matrix be symmetrical? > ie AA->BB IFF BB->AA??? > Please clarify why this is not the case. > > On Fri, 22 Oct 2010 21:12:24 +0200, John F Hall<[hidden email]> wrote: > >> Cy >> >> Art has already supplied a solution, but you don't say how many students > there are in total, but one thing you could try (if there are not too many) > would be to feed the data in as two string variables columna and columnb and > then do: >> crosstabs columna by columnb . >> >> Thiswould at least show you the combinations. >> >> John Hall >> [hidden email] >> http://surveyresearch.weebly.com >> >> ----- Original Message ----- >> From: Chao Yawo >> To: [hidden email] >> Sent: Friday, October 22, 2010 7:29 AM >> Subject: Help with Square Matrix >> >> >> Hi, >> >> I have a dataset with the following structure. >> >> >> ColumnA ColumnB ColumnC >> ClassA OtherStud WorkWith >> >> AA DD 1 >> AA EE 0 >> AA BB 1 >> BB FF 1 >> BB GG 1 >> BB KK 0 >> CC AA 1 >> CC BB 1 >> >> >> ColumnA refers to students in ClassroomA, and Column B refers to "Other >> Students" in the school who could act as work and/or playmates. Note, > ColumnB could also include some of the same students in ColumnA(ClassA) who > work with each other (For example, Students: AA and BB). >> If a Student in Classroom A works with a student in ClassroomB, ColumnC >> takes the value of 1, and 0(zero) if otherwise >> >> So, looking at ColumnA, we find that there are three students: AA, BB and >> CC. Student_AA for instance interacts with three students<DD, EE, BB> but only >> works with DD and BB. Similarly, Student_CC interacts with two students >> <AA, and BB> and works and plays with each of them. >> >> Now, I am interested in constructing a matrix indicating which >> students in ClassroomA work with each other. This means >> that student_AA for instance works with student_BB, who is in his/her >> classroom, hence the cell in their matrix will have a "1". Again, > Student_CC in ClassroomA works with 2 other members of >> his/her own class<ie, AA and BB>. So CC would have two "1s" in the matrix. >> >> The resulting matrix for the "Works With" relation (ColumnC) among the 3 >> students in ClassroomA would look like this. >> >> AA BB CC >> AA 0 1 0 >> BB 0 0 0 >> CC 1 1 0 >> >> This matrix is the output I am interested in, and need to produce for the > relationship specified in Column C.I would certainly appreciate some ideas > to help me produce this. >> >> Thanks in advance for your assistance. >> >> Sincerely, Cy >> >> > ===================== > To manage your subscription to SPSSX-L, send a message to > [hidden email] (not to SPSSX-L), with no body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send the command > INFO REFCARD > ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Art Kendall
Social Research Consultants |
|
Administrator
|
In reply to this post by Chao Yawo
If you want the matrix as a dataset then use Art's setup:
"autorecode variables = rowkid colkid /into nrowkid ncolkid /group." Followed by: *Replace 10 with the total number of kids in the following. NUMERIC Play01 TO Play10. VECTOR Play=Play01 TO Play10. COMPUTE Play(ncolkid)=link. AGGREGATE OUTFILE * / BREAK rowkid nrowkid / Play01 to Play10=MAX(Play01 TO Play10). HTH, David On Fri, 22 Oct 2010 10:48:25 -0400, Chao Yawo <[hidden email]> wrote: >Ok. I will check again and delete the line and re-run it. Will let you know >how it goes. rgds, Cy > >On Fri, Oct 22, 2010 at 10:44 AM, Art Kendall <[hidden email]> wrote: > >> when i read it into SPSS there is a blank line after "begin data". >> >> Art >> >> >> On 10/22/2010 9:23 AM, Chao Yawo wrote: >> >> Art, thanks very much for your continuing assistance. I checked, but there >> were no break lines. I am attaching the syntax file for your perusal, if >> that would help. warmest regards, Cy >> >> On Fri, Oct 22, 2010 at 9:10 AM, Art Kendall <[hidden email]> wrote: >> >>> take a look at the data view. >>> Did the paste cause some blank lines? >>> >>> Art >>> >>> >>> On 10/22/2010 8:43 AM, Chao Yawo wrote: >>> >>> Art, thanks very much -- it worked, mostly, but it produced the warning >>> below: >>> >>> >Warning # 1116 >>> >Under LIST input, insufficient data were contained on one record to >>> fulfill >>> >the variable list. Remaining numeric variables have been set to the >>> >system-missing value and string variables have been set to blanks >>> >>> Here is the matrix I got: >>> >>> >>> ncolkid >>> AA BB CC DD EE FF GG KK >>> Count Count Count Count Count Count Count Count Count >>> nrowkid 0 0 0 0 0 0 0 0 0 >>> AA 0 0 1 0 1 0 0 0 0 >>> BB 0 0 0 0 0 0 1 1 0 >>> CC 0 1 1 0 0 0 0 0 0 >>> DD 0 0 0 0 0 0 0 0 0 >>> EE 0 0 0 0 0 0 0 0 0 >>> FF 0 0 0 0 0 0 0 0 0 >>> GG 0 0 0 0 0 0 0 0 0 >>> KK 0 0 0 0 0 0 0 0 0 >>> >>> I will now appy it to some real data: will report back soon. rgds, CY >>> >>> >>> On Fri, Oct 22, 2010 at 7:57 AM, Art Kendall <[hidden email]> wrote: >>> >>>> data list list/rowkid (a2) colkid(a2) link(f1). >>>> begin data >>>> >>>> AA DD 1 >>>> AA EE 0 >>>> AA BB 1 >>>> BB FF 1 >>>> BB GG 1 >>>> BB KK 0 >>>> CC AA 1 >>>> CC BB 1 >>>> end data. >>>> autorecode variables = rowkid colkid /into nrowkid ncolkid /group. >>>> select if link eq 1. >>>> >>>> * Custom Tables. >>>> CTABLES >>>> /VLABELS VARIABLES=nrowkid ncolkid DISPLAY=BOTH >>>> /TABLE nrowkid BY ncolkid [COUNT F40.0] >>>> /CATEGORIES VARIABLES=nrowkid ncolkid ORDER=A KEY=VALUE EMPTY=INCLUDE. >>>> >>> >>> ===================== To manage your subscription to SPSSX-L, send a >>> message to [hidden email] (not to SPSSX-L), with no body text >>> except the command. To leave the list, send the command SIGNOFF SPSSX-L For >>> a list of commands to manage subscriptions, send the command INFO REFCARD >>> >> >> ===================== To manage your subscription to SPSSX-L, send a >> message to [hidden email] (not to SPSSX-L), with no body text >> except the command. To leave the list, send the command SIGNOFF SPSSX-L For >> a list of commands to manage subscriptions, send the command INFO REFCARD >> > ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
|
David and Art,
Thanks very much for your contributions. I am sorry I was not too clear. But Art is right about the asymmetric nature of the data. His commands really helped generate the matrix. It worked with the example data. But when I tried it on my real data, the matrix was based on all the students in both rows and columns. Ideally, what I would really like is the matrix to be based on only the students in the rows. So in the end, we have a square matrix.
My other post - "Comparing Columns" which Art answered yesterday helped me solved part of the problem by ensuring that the names in column A (row) are the only one that appear in column B (column). A bit of manual processing involved, though.
Thanks again for all your support. Rgds, CY On Sat, Oct 23, 2010 at 9:52 AM, David Marso <[hidden email]> wrote: If you want the matrix as a dataset then use Art's setup: |
| Free forum by Nabble | Edit this page |
