Extract Diagonals from a Correlations Table

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Extract Diagonals from a Correlations Table

Jon Bernard-2
Dear SPSSers,

I have correlations between ratings at two points in time on 5 items,
provided by the syntax below:

CORRELATIONS
  /VARIABLES=a01 to a05 WITH b01 to b05
  /PRINT=TWOTAIL NOSIG
  /MISSING=PAIRWISE .

I used OMS to put the table into a new SAV file, which was then cleaned to
remove the N and sig values, leaving only the r-values.

I would like to create a new variable, the value of which is the the
diagonal value in each row.  I would use MAX to do this, but the diagonal
values are not necessarily the maximum values in each row.

Fake sample before and after data are provided below:

*** Before .

DATA LIST LIST /case_lbl (A4) var1 to var5 .
BEGIN DATA
"var1" .20 .19 .17 .12 .04
"var2" .09 .16 .01 .03 .14
"var3" .15 .11 .17 .04 .02
"var4" .10 .04 .06 .09 .05
"var5" .04 .17 .01 .11 .30
END DATA .

*** After .

DATA LIST LIST /case_lbl (A4) var1 to var5 diag .
BEGIN DATA
"var1" .20 .19 .17 .12 .14 .20
"var2" .09 .16 .01 .03 .14 .16
"var3" .15 .11 .17 .04 .02 .17
"var4" .10 .04 .06 .09 .05 .09
"var5" .04 .17 .01 .11 .30 .30
END DATA .

Can anyone help with a reference or solution?  I should note that while I
have some experience with basic syntax, I have little with macros and
scripts, and none with Python.

Thank you in advance for your advice.

-Jon
Reply | Threaded
Open this post in threaded view
|

Re: Extract Diagonals from a Correlations Table

ViAnn Beadle
As stated, this syntax will do that for you:

DATA LIST LIST /case_lbl (A4) var1 to var5 .
BEGIN DATA
"var1" .20 .19 .17 .12 .14
"var2" .09 .16 .01 .03 .14
"var3" .15 .11 .17 .04 .02
"var4" .10 .04 .06 .09 .05
"var5" .04 .17 .01 .11 .30
END DATA .
vector v=var1 to var5.
compute diag=v($casenum).

Use Execute or some procedure to pass the data. You don't say what you want
to do after you compute this value so I'll stop here.

$casenum is a system variable which is just the case number.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jon
Bernard
Sent: Thursday, October 04, 2007 2:23 PM
To: [hidden email]
Subject: Extract Diagonals from a Correlations Table

Dear SPSSers,

I have correlations between ratings at two points in time on 5 items,
provided by the syntax below:

CORRELATIONS
  /VARIABLES=a01 to a05 WITH b01 to b05
  /PRINT=TWOTAIL NOSIG
  /MISSING=PAIRWISE .

I used OMS to put the table into a new SAV file, which was then cleaned to
remove the N and sig values, leaving only the r-values.

I would like to create a new variable, the value of which is the the
diagonal value in each row.  I would use MAX to do this, but the diagonal
values are not necessarily the maximum values in each row.

Fake sample before and after data are provided below:

*** Before .

DATA LIST LIST /case_lbl (A4) var1 to var5 .
BEGIN DATA
"var1" .20 .19 .17 .12 .04
"var2" .09 .16 .01 .03 .14
"var3" .15 .11 .17 .04 .02
"var4" .10 .04 .06 .09 .05
"var5" .04 .17 .01 .11 .30
END DATA .

*** After .

DATA LIST LIST /case_lbl (A4) var1 to var5 diag .
BEGIN DATA
"var1" .20 .19 .17 .12 .14 .20
"var2" .09 .16 .01 .03 .14 .16
"var3" .15 .11 .17 .04 .02 .17
"var4" .10 .04 .06 .09 .05 .09
"var5" .04 .17 .01 .11 .30 .30
END DATA .

Can anyone help with a reference or solution?  I should note that while I
have some experience with basic syntax, I have little with macros and
scripts, and none with Python.

Thank you in advance for your advice.

-Jon
Reply | Threaded
Open this post in threaded view
|

Chi-Square in Crosstabs

Gary Oliver
Hi All

I have 3 survey questions each with a before and after answer from two
groups (N=393, N=540). I have put this in an SPSS data file. There are
seven variables corresponding to the three before and three after survey
questions plus one variable as a group coding dummy variable to identify
the two groups.

The crosstabs option does not allow me to run the computation.

I have looked in help and my SPSS books (eg Pallant) but the examples
they give a unlike mine. Suggestions appreciated

Warm regards/gary
Reply | Threaded
Open this post in threaded view
|

Re: Extract Diagonals from a Correlations Table

Jon Bernard-2
In reply to this post by ViAnn Beadle
That is perfect, thank you very much, ViAnn!

Jon

On 10/4/07, ViAnn Beadle <[hidden email]> wrote:

>
> As stated, this syntax will do that for you:
>
> DATA LIST LIST /case_lbl (A4) var1 to var5 .
> BEGIN DATA
> "var1" .20 .19 .17 .12 .14
> "var2" .09 .16 .01 .03 .14
> "var3" .15 .11 .17 .04 .02
> "var4" .10 .04 .06 .09 .05
> "var5" .04 .17 .01 .11 .30
> END DATA .
> vector v=var1 to var5.
> compute diag=v($casenum).
>
> Use Execute or some procedure to pass the data. You don't say what you
> want
> to do after you compute this value so I'll stop here.
>
> $casenum is a system variable which is just the case number.
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
> Jon
> Bernard
> Sent: Thursday, October 04, 2007 2:23 PM
> To: [hidden email]
> Subject: Extract Diagonals from a Correlations Table
>
> Dear SPSSers,
>
> I have correlations between ratings at two points in time on 5 items,
> provided by the syntax below:
>
> CORRELATIONS
>   /VARIABLES=a01 to a05 WITH b01 to b05
>   /PRINT=TWOTAIL NOSIG
>   /MISSING=PAIRWISE .
>
> I used OMS to put the table into a new SAV file, which was then cleaned to
> remove the N and sig values, leaving only the r-values.
>
> I would like to create a new variable, the value of which is the the
> diagonal value in each row.  I would use MAX to do this, but the diagonal
> values are not necessarily the maximum values in each row.
>
> Fake sample before and after data are provided below:
>
> *** Before .
>
> DATA LIST LIST /case_lbl (A4) var1 to var5 .
> BEGIN DATA
> "var1" .20 .19 .17 .12 .04
> "var2" .09 .16 .01 .03 .14
> "var3" .15 .11 .17 .04 .02
> "var4" .10 .04 .06 .09 .05
> "var5" .04 .17 .01 .11 .30
> END DATA .
>
> *** After .
>
> DATA LIST LIST /case_lbl (A4) var1 to var5 diag .
> BEGIN DATA
> "var1" .20 .19 .17 .12 .14 .20
> "var2" .09 .16 .01 .03 .14 .16
> "var3" .15 .11 .17 .04 .02 .17
> "var4" .10 .04 .06 .09 .05 .09
> "var5" .04 .17 .01 .11 .30 .30
> END DATA .
>
> Can anyone help with a reference or solution?  I should note that while I
> have some experience with basic syntax, I have little with macros and
> scripts, and none with Python.
>
> Thank you in advance for your advice.
>
> -Jon
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Chi-Square in Crosstabs

statisticsdoc
In reply to this post by Gary Oliver
Gary,

Are you interested in a two-way analysis (e.g. pre- versus post- for a
specific question), or a three-way analysis (e.g. showing that the pre-post
relationship differs between groups, or that the post answer differs between
groups after controlling for the pre- response.  I am wondering whether your
research questions are ones that lend themselves to loglinear analysis and
logistic regression.

Best,

Stephen

For personalized and professional consultation in statistics and research
design, visit
www.statisticsdoc.com


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Gary Oliver
Sent: Thursday, October 04, 2007 7:13 PM
To: [hidden email]
Subject: Chi-Square in Crosstabs


Hi All

I have 3 survey questions each with a before and after answer from two
groups (N=393, N=540). I have put this in an SPSS data file. There are
seven variables corresponding to the three before and three after survey
questions plus one variable as a group coding dummy variable to identify
the two groups.

The crosstabs option does not allow me to run the computation.

I have looked in help and my SPSS books (eg Pallant) but the examples
they give a unlike mine. Suggestions appreciated

Warm regards/gary
Reply | Threaded
Open this post in threaded view
|

Re: Chi-Square in Crosstabs

ViAnn Beadle
In reply to this post by Gary Oliver
I'm not sure what you mean by the option "does not allow me to run the
computation". You should have two sub-tables, one for each group and a
chi-square value for each before and after table. What hypothesis are you
testing? IMHO, you have a within-subjects design here for which a chi-square
test does not seem to be suitable (note that I am not a statistician and
don't even pretend to be one on TV).

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Gary Oliver
Sent: Thursday, October 04, 2007 5:13 PM
To: [hidden email]
Subject: Chi-Square in Crosstabs

Hi All

I have 3 survey questions each with a before and after answer from two
groups (N=393, N=540). I have put this in an SPSS data file. There are
seven variables corresponding to the three before and three after survey
questions plus one variable as a group coding dummy variable to identify
the two groups.

The crosstabs option does not allow me to run the computation.

I have looked in help and my SPSS books (eg Pallant) but the examples
they give a unlike mine. Suggestions appreciated

Warm regards/gary
Reply | Threaded
Open this post in threaded view
|

Re: Chi-Square in Crosstabs

Björn Türoque
Gary,

Are you trying to match up cases pre test and post test? As an example, are
you looking at the same person's results from the first survey and comparing
these to the results to the second survey? Your problem may be the way your
data is stored, is the data set up so that you have each person as a case,
and each case has the results from the pre and post test stored?

Knowing how your data is stored is very important to the types of analysis
you can run.




On 10/4/07, ViAnn Beadle <[hidden email]> wrote:

>
> I'm not sure what you mean by the option "does not allow me to run the
> computation". You should have two sub-tables, one for each group and a
> chi-square value for each before and after table. What hypothesis are you
> testing? IMHO, you have a within-subjects design here for which a
> chi-square
> test does not seem to be suitable (note that I am not a statistician and
> don't even pretend to be one on TV).
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
> Gary Oliver
> Sent: Thursday, October 04, 2007 5:13 PM
> To: [hidden email]
> Subject: Chi-Square in Crosstabs
>
> Hi All
>
> I have 3 survey questions each with a before and after answer from two
> groups (N=393, N=540). I have put this in an SPSS data file. There are
> seven variables corresponding to the three before and three after survey
> questions plus one variable as a group coding dummy variable to identify
> the two groups.
>
> The crosstabs option does not allow me to run the computation.
>
> I have looked in help and my SPSS books (eg Pallant) but the examples
> they give a unlike mine. Suggestions appreciated
>
> Warm regards/gary
>



--
Björn Türoque
375 Hudson Street
New York, NY 10014-3657
212-366-2000

Some people are just born to rock!
Reply | Threaded
Open this post in threaded view
|

Re: Chi-Square in Crosstabs

Gary Oliver
Hi Bjorn (sorry I am missing the diacritic characters over the letters)

Thanks for your reply

I think you are correct referring to my data store (variables).

But I have exactly what you describe: a before and after variable and there are 540 cases

However that does not seem to be what SPSS crosstabs wants because the screen dialog box wants both row variables and column variables

Warm regards/gary

>>-----Original Message-----
>>From: SPSSX(r) Discussion [mailto:[hidden email]]
>>On Behalf Of Björn Türoque
>>Sent: Saturday, October 06, 2007 6:30 AM
>>To: [hidden email]
>>Subject: Re: Chi-Square in Crosstabs
>>
>>Gary,
>>
>>Are you trying to match up cases pre test and post test? As
>>an example, are you looking at the same person's results from
>>the first survey and comparing these to the results to the
>>second survey? Your problem may be the way your data is
>>stored, is the data set up so that you have each person as a
>>case, and each case has the results from the pre and post test stored?
>>
>>Knowing how your data is stored is very important to the
>>types of analysis you can run.
>>
>>
>>
>>
>>On 10/4/07, ViAnn Beadle <[hidden email]> wrote:
>>>
>>> I'm not sure what you mean by the option "does not allow me
>>to run the
>>> computation". You should have two sub-tables, one for each
>>group and a
>>> chi-square value for each before and after table. What
>>hypothesis are
>>> you testing? IMHO, you have a within-subjects design here
>>for which a
>>> chi-square test does not seem to be suitable (note that I am not a
>>> statistician and don't even pretend to be one on TV).
>>>
>>> -----Original Message-----
>>> From: SPSSX(r) Discussion [mailto:[hidden email]]
>>On Behalf
>>> Of Gary Oliver
>>> Sent: Thursday, October 04, 2007 5:13 PM
>>> To: [hidden email]
>>> Subject: Chi-Square in Crosstabs
>>>
>>> Hi All
>>>
>>> I have 3 survey questions each with a before and after
>>answer from two
>>> groups (N=393, N=540). I have put this in an SPSS data
>>file. There are
>>> seven variables corresponding to the three before and three after
>>> survey questions plus one variable as a group coding dummy
>>variable to
>>> identify the two groups.
>>>
>>> The crosstabs option does not allow me to run the computation.
>>>
>>> I have looked in help and my SPSS books (eg Pallant) but
>>the examples
>>> they give a unlike mine. Suggestions appreciated
>>>
>>> Warm regards/gary
>>>
>>
>>
>>
>>--
>>Björn Türoque
>>375 Hudson Street
>>New York, NY 10014-3657
>>212-366-2000
>>
>>Some people are just born to rock!
>>
Reply | Threaded
Open this post in threaded view
|

Re: Chi-Square in Crosstabs

Hector Maletta
         Gary,
         What SPSS wants to know when you are ordering a crosstabulation is
which variables (columns in your data editor) will appear in the rows of
your crosstabulation, and which variables will appear in the columns of your
crosstabulation. For instance, if you are ordering a table of gender by hair
color, you may have one row for each gender and one column for each hair
color, and thus gender is your row variable and hair color your column
variable in that particular tabulation. Or you may have it the other way if
you like. But both variables occupy columns in your data editor.
         You can design your table the way you like it best. Moreover, once
your table is produced you may easily rotate the table with the pivot table
editor (select the table and click on Pivot), putting genders in the columns
and hair colors in the rows.

         Hector

         -----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Gary Oliver
Sent: 06 October 2007 00:02
To: [hidden email]
Subject: Re: Chi-Square in Crosstabs

         Hi Bjorn (sorry I am missing the diacritic characters over the
letters)

         Thanks for your reply

         I think you are correct referring to my data store (variables).

         But I have exactly what you describe: a before and after variable
and there are 540 cases

         However that does not seem to be what SPSS crosstabs wants because
the screen dialog box wants both row variables and column variables

         Warm regards/gary

         >>-----Original Message-----
         >>From: SPSSX(r) Discussion [mailto:[hidden email]]
         >>On Behalf Of Björn Türoque
         >>Sent: Saturday, October 06, 2007 6:30 AM
         >>To: [hidden email]
         >>Subject: Re: Chi-Square in Crosstabs
         >>
         >>Gary,
         >>
         >>Are you trying to match up cases pre test and post test? As
         >>an example, are you looking at the same person's results from
         >>the first survey and comparing these to the results to the
         >>second survey? Your problem may be the way your data is
         >>stored, is the data set up so that you have each person as a
         >>case, and each case has the results from the pre and post test
stored?
         >>
         >>Knowing how your data is stored is very important to the
         >>types of analysis you can run.
         >>
         >>
         >>
         >>
         >>On 10/4/07, ViAnn Beadle <[hidden email]> wrote:
         >>>
         >>> I'm not sure what you mean by the option "does not allow me
         >>to run the
         >>> computation". You should have two sub-tables, one for each
         >>group and a
         >>> chi-square value for each before and after table. What
         >>hypothesis are
         >>> you testing? IMHO, you have a within-subjects design here
         >>for which a
         >>> chi-square test does not seem to be suitable (note that I am
not a
         >>> statistician and don't even pretend to be one on TV).
         >>>
         >>> -----Original Message-----
         >>> From: SPSSX(r) Discussion [mailto:[hidden email]]
         >>On Behalf
         >>> Of Gary Oliver
         >>> Sent: Thursday, October 04, 2007 5:13 PM
         >>> To: [hidden email]
         >>> Subject: Chi-Square in Crosstabs
         >>>
         >>> Hi All
         >>>
         >>> I have 3 survey questions each with a before and after
         >>answer from two
         >>> groups (N=393, N=540). I have put this in an SPSS data
         >>file. There are
         >>> seven variables corresponding to the three before and three
after
         >>> survey questions plus one variable as a group coding dummy
         >>variable to
         >>> identify the two groups.
         >>>
         >>> The crosstabs option does not allow me to run the computation.
         >>>
         >>> I have looked in help and my SPSS books (eg Pallant) but
         >>the examples
         >>> they give a unlike mine. Suggestions appreciated
         >>>
         >>> Warm regards/gary
         >>>
         >>
         >>
         >>
         >>--
         >>Björn Türoque
         >>375 Hudson Street
         >>New York, NY 10014-3657
         >>212-366-2000
         >>
         >>Some people are just born to rock!
         >>