Simple Correlation Matrix

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

Re: Simple Correlation Matrix

PRogman
I found this in the archive. I have been trying to present prettier correlation tables and thought I could use this. After some random walks in the basic scriptworld I have managed to convert the script to work, it also seems to work as a non-autoscript.
Unfortunately it is quite slow...
The data is hidden and can be recovered by changing the text color in the table.
Hopefully someone will find it useful... Remember to change the path to Global.wwd to your system.

/PR

By the way, the SPSSINC MODIFY TABLE does not work - all but the header is removed and lost.

Corr_Table_Correlations_KeepLower.wwd 

...
* Sample data [Marta GG] *.
INPUT PROGRAM.
- VECTOR x(20).
- LOOP #I = 1 TO 100.
-  LOOP #J = 1 TO 20.
-   COMPUTE x(#J) = NORMAL(1).
-  END LOOP.
-  END CASE.
- END LOOP.
- END FILE.
END INPUT PROGRAM.
EXE.

* Peck *.
SPSSINC MODIFY TABLES subtype="'Correlations'"
  SELECT="Sig. (2-tailed)" "N"
  DIMENSION= ROWS
  LEVEL = -1  PROCESS = PRECEDING HIDE=TRUE.

[Output...]
Correlations
                x1 x2 x3 x4 x5 x6 x7 x8 x9 x10

Warning
16619,An error occured in the Pivot Table.,


Reply | Threaded
Open this post in threaded view
|

Re: Simple Correlation Matrix

Jon K Peck
Your MODIFY TABLES syntax should be this.
SPSSINC MODIFY TABLES SUBTYPE='"Correlations"' SELECT=0 DIMENSION=ROWS PROCESS=PRECEDING
/styles customfunction=
"formatcorrmat.cleancorr(hidecounts=True, hidel=False, lowertri=True, hideinsig=.05, emphasis=1.)".

You can generate this from Utilities > Format Correlation Matrix.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        PRogman <[hidden email]>
To:        [hidden email],
Date:        03/03/2014 08:24 AM
Subject:        Re: [SPSSX-L] Simple Correlation Matrix
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




I found this in the archive. I have been trying to present prettier
correlation tables and thought I could use this. After some random walks in
the basic scriptworld I have managed to convert the script to work, it also
seems to work as a non-autoscript.
Unfortunately it is quite slow...
The data is hidden and can be recovered by changing the text color in the
table.
Hopefully someone will find it useful... Remember to change the path to
Global.wwd to your system.

/PR

By the way, the SPSSINC MODIFY TABLE does not work - all but the header is
removed and lost.

Corr_Table_Correlations_KeepLower.wwd
<
http://spssx-discussion.1045642.n5.nabble.com/file/n5724698/Corr_Table_Correlations_KeepLower.wwd>

...
* Sample data [Marta GG] *.
INPUT PROGRAM.
- VECTOR x(20).
- LOOP #I = 1 TO 100.
-  LOOP #J = 1 TO 20.
-   COMPUTE x(#J) = NORMAL(1).
-  END LOOP.
-  END CASE.
- END LOOP.
- END FILE.
END INPUT PROGRAM.
EXE.

* Peck *.
SPSSINC MODIFY TABLES subtype="'Correlations'"
 SELECT="Sig. (2-tailed)" "N"
 DIMENSION= ROWS
 LEVEL = -1  PROCESS = PRECEDING HIDE=TRUE.

[Output...]
Correlations
               x1      x2      x3      x4      x5      x6      x7      x8      x9      x10

Warning
16619,An error occured in the Pivot Table.,






--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Simple-Correlation-Matrix-tp1090500p5724698.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

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


Reply | Threaded
Open this post in threaded view
|

Re: Simple Correlation Matrix

Bruce Weaver
Administrator
In reply to this post by Yochi Cohen-Charash
Someone recently resurrected this thread.  Looking at it again a few years later, here are a couple of simple approaches for Yochi and others with the same basic question.

* In 2009, Yochi Cohen-Charash asked how to get a "simple correlation matrix,
* without scripts and complicated commands".
* Two methods are illustrated below.

NEW FILE.
DATASET CLOSE all.
* Sample data--from Marta GG's macro example.
INPUT PROGRAM.
- VECTOR x(20).
- LOOP #I = 1 TO 100.
-  LOOP #J = 1 TO 20.
-   COMPUTE x(#J) = NORMAL(1).
-  END LOOP.
-  END CASE.
- END LOOP.
- END FILE.
END INPUT PROGRAM.
EXECUTE.

* [1] Use RELIABILITY to get the full matrix.

RELIABILITY
  /VARIABLES=x1 TO x20
  /SCALE('ALL VARIABLES') ALL
  /STATISTICS=CORRELATIONS.

* I believe RELIABILITY uses PAIRWISE deletion.
* To get LISTWISE deletion, set your own filter first.

* [2] Use MVA to get the main diagonal and lower half.
*     This method requires the Missing Values Analysis add-on module.
*     One could also use OMS to suppress the unwanted bits of the MVA output.

MVA VARIABLES=x1 TO x20
  /NOUNIVARIATE
  /LISTWISE
  /PAIRWISE.


HTH.


Yochi Cohen-Charash wrote
Bruce,

Thanks much for continuing the trend.

Jon, I must admit I only want to get a simple correlation matrix, without
scripts and complicated commands I need to write for that. I am a
psychologist, not a programmer or a statistician, not am I a fan of these.
Any way you can make it easy for people like me, working with version 17
(after upgrading from version 11.5, in which it was very easy to get)?

Thanks much,

Yochi

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Peck, Jon
Sent: Tuesday, September 08, 2009 12:29 PM
To: [hidden email]
Subject: Re: Simple Correlation Matrix

I don't have that script - I'll take a look if you want to send it, but the
general procedure is just to add a line like
    Set objPivotTable = scriptContext.GetOutputItem()
and removing the parameter list from the Sub statement.
That gives you the equivalent of the objPivotTable you would previously have
gotten through the parameter list.
From there on, the code would be the same.

To use this as an autoscript, you attach it to the particular table type in
Edit>Options>Script and it will be triggered whenever a table of the
specified type is created.

HTH,
Jon

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Bruce Weaver
Sent: Tuesday, September 08, 2009 9:13 AM
To: [hidden email]
Subject: Re: [SPSSX-L] Simple Correlation Matrix

Peck, Jon wrote:
>
> See below.
>
> --- snip ---
> [BW]
> So, I suspect the answer from SPSS will be, "Do it with Python".
>
> [peck]
> No, that is not the answer from SPSS.  Although it would be easy to do
> this task with Python using the SPSSINC MODIFY TABLES extension command,
> you can easily convert an old Basic autoscript.  In most cases that
> amounts to adding one line of code to the script as described in the help
> and saving it as a separate file.  That change was made so that the same
> script could be used either as an autoscript or a regular script.
>
> If someone wants to do this with MODIFY TABLES, though, I can add a tiny
> function to the customstylefunctions module that comes with the command
> that would blank the upper or lower triangle.
>
> Regards,
> Jon Peck
>

Hi Jon.  I take issue with that "easily".  ;-)  I suspect it's easy for
visual basic programmers, but I'm not one of them.  (I was more a Turbo
Pascal guy back in the day.)  I've tried to follow the instructions for
converting the legacy autoscript for correlation matrices to something that
will run in v17, but I'm having a problem at this step:

* Use the scriptContext object (always available) to get the values required
by the autoscript, such as the output item that triggered the autoscript.

An example is given (for Descriptives_Table_DescriptiveStatistics_Create),
but I am unable to work out from it exactly what additions/changes I have to
make to the autoscript that formats correlation matrices.  I think a lot of
users are not visual basic programmers, and so would find it helpful if
converted legacy autoscripts were available for download from the Tech
Support website.  Is this possible?

Thanks,
Bruce


-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/
"When all else fails, RTFM."

NOTE:  My Hotmail account is for posting only, and is not monitored
regularly.
If you wish to send me an e-mail, please use the address shown in my sig
file.
--
View this message in context:
http://www.nabble.com/Simple-Correlation-Matrix-tp25224408p25348154.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Simple Correlation Matrix

Bruce Weaver
Administrator
Earlier, I said:

* I believe RELIABILITY uses PAIRWISE deletion.
* To get LISTWISE deletion, set your own filter first.

I was on my way to a meeting when I posted that, and didn't take the time to check.  Now that I have checked, I can tell you I got it wrong!  The correlations from RELIABILITY use LISTWISE deletion.  For example...

* Change path to folder where SPSS sample data files are stored.
GET FILE = "C:\SPSSdata\survey_sample.sav".

CORRELATIONS
  /VARIABLES=age to speduc
  /MISSING=PAIRWISE .

CORRELATIONS
  /VARIABLES=age to speduc
  /MISSING=LISTWISE .

RELIABILITY
  /VARIABLES=age to speduc
  /SCALE('ALL VARIABLES') ALL
  /STATISTICS=CORR.

OUTPUT:

CORRELATIONS + PAIRWISE:
1.000  -.175  -.350  -.345  -.161
-.175  1.000   .455   .386    .593
-.350   .455  1.000   .651   .414
-.345   .386    .651 1.000   .338
-.161   .593    .414   .338 1.000

CORRELATIONS + LISTWISE:
1.000   -.102   -.313   -.304    -.123
-.102   1.000    .477     .433     .581
-.313    .477   1.000     .655     .399
-.304    .433     .655 1.000     .366
-.123    .581     .399  .366     1.000

RELIABILITY:
1.000   -.102   -.313   -.304    -.123
-.102   1.000    .477     .433     .581
-.313    .477   1.000     .655     .399
-.304    .433     .655 1.000     .366
-.123    .581     .399  .366     1.000

HTH.

Bruce Weaver wrote
Someone recently resurrected this thread.  Looking at it again a few years later, here are a couple of simple approaches for Yochi and others with the same basic question.

* In 2009, Yochi Cohen-Charash asked how to get a "simple correlation matrix,
* without scripts and complicated commands".
* Two methods are illustrated below.

NEW FILE.
DATASET CLOSE all.
* Sample data--from Marta GG's macro example.
INPUT PROGRAM.
- VECTOR x(20).
- LOOP #I = 1 TO 100.
-  LOOP #J = 1 TO 20.
-   COMPUTE x(#J) = NORMAL(1).
-  END LOOP.
-  END CASE.
- END LOOP.
- END FILE.
END INPUT PROGRAM.
EXECUTE.

* [1] Use RELIABILITY to get the full matrix.

RELIABILITY
  /VARIABLES=x1 TO x20
  /SCALE('ALL VARIABLES') ALL
  /STATISTICS=CORRELATIONS.

* I believe RELIABILITY uses PAIRWISE deletion.
* To get LISTWISE deletion, set your own filter first.

* [2] Use MVA to get the main diagonal and lower half.
*     This method requires the Missing Values Analysis add-on module.
*     One could also use OMS to suppress the unwanted bits of the MVA output.

MVA VARIABLES=x1 TO x20
  /NOUNIVARIATE
  /LISTWISE
  /PAIRWISE.


HTH.


Yochi Cohen-Charash wrote
Bruce,

Thanks much for continuing the trend.

Jon, I must admit I only want to get a simple correlation matrix, without
scripts and complicated commands I need to write for that. I am a
psychologist, not a programmer or a statistician, not am I a fan of these.
Any way you can make it easy for people like me, working with version 17
(after upgrading from version 11.5, in which it was very easy to get)?

Thanks much,

Yochi

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Peck, Jon
Sent: Tuesday, September 08, 2009 12:29 PM
To: [hidden email]
Subject: Re: Simple Correlation Matrix

I don't have that script - I'll take a look if you want to send it, but the
general procedure is just to add a line like
    Set objPivotTable = scriptContext.GetOutputItem()
and removing the parameter list from the Sub statement.
That gives you the equivalent of the objPivotTable you would previously have
gotten through the parameter list.
From there on, the code would be the same.

To use this as an autoscript, you attach it to the particular table type in
Edit>Options>Script and it will be triggered whenever a table of the
specified type is created.

HTH,
Jon

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Bruce Weaver
Sent: Tuesday, September 08, 2009 9:13 AM
To: [hidden email]
Subject: Re: [SPSSX-L] Simple Correlation Matrix

Peck, Jon wrote:
>
> See below.
>
> --- snip ---
> [BW]
> So, I suspect the answer from SPSS will be, "Do it with Python".
>
> [peck]
> No, that is not the answer from SPSS.  Although it would be easy to do
> this task with Python using the SPSSINC MODIFY TABLES extension command,
> you can easily convert an old Basic autoscript.  In most cases that
> amounts to adding one line of code to the script as described in the help
> and saving it as a separate file.  That change was made so that the same
> script could be used either as an autoscript or a regular script.
>
> If someone wants to do this with MODIFY TABLES, though, I can add a tiny
> function to the customstylefunctions module that comes with the command
> that would blank the upper or lower triangle.
>
> Regards,
> Jon Peck
>

Hi Jon.  I take issue with that "easily".  ;-)  I suspect it's easy for
visual basic programmers, but I'm not one of them.  (I was more a Turbo
Pascal guy back in the day.)  I've tried to follow the instructions for
converting the legacy autoscript for correlation matrices to something that
will run in v17, but I'm having a problem at this step:

* Use the scriptContext object (always available) to get the values required
by the autoscript, such as the output item that triggered the autoscript.

An example is given (for Descriptives_Table_DescriptiveStatistics_Create),
but I am unable to work out from it exactly what additions/changes I have to
make to the autoscript that formats correlation matrices.  I think a lot of
users are not visual basic programmers, and so would find it helpful if
converted legacy autoscripts were available for download from the Tech
Support website.  Is this possible?

Thanks,
Bruce


-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/
"When all else fails, RTFM."

NOTE:  My Hotmail account is for posting only, and is not monitored
regularly.
If you wish to send me an e-mail, please use the address shown in my sig
file.
--
View this message in context:
http://www.nabble.com/Simple-Correlation-Matrix-tp25224408p25348154.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Simple Correlation Matrix

PRogman
In reply to this post by Jon K Peck
I missed that extension! Great! It is much better than the script! I will also look into the different customstyles.py. That could be really useful.

Thank you!
PR
12