SPSS Statistics

SPSS Statistics

Your hub for statistical analysis, data management, and data documentation. Connect, learn, and share with your peers! 

 View Only
  • 1.  Modifying Output of STATS CORRELATIONS: Highlight significant rows?

    Posted Sat February 25, 2023 08:46 AM
    The subject in other words: Can I highlight rows of STATS CORRELATIONS Tables where Lower C.I. and Upper C.I. are of the same sign?
    (Or will I have to use CORRELATIONS instead and modify its output based on p values?)


  • 2.  RE: Modifying Output of STATS CORRELATIONS: Highlight significant rows?

    Posted Sat February 25, 2023 10:30 AM
    The FORMAT CORRELATIONS (Utilities > Format Correlation Matrix) extension command, which requires SPSSINC MODIFY TABLES, has several options for formatting a correlation matrix, including bolding significant correlations.

    For STATS CORRELATIONS, you can do this using SPSSINC MODIFY TABLES with a small custom function.  Here is an example.  First, the custom function is defined; then SPSSINC MODIFY TABLES is used to apply it.  This just colors the correlations column, but it could easily be modified to color the whole row.  It is setting the background color to yellow, but it could do other forms of highlighting.

    * Run this once in a session.
    begin program python3.
    import customstylefunctions

    def colorsig(obj, i, j, numrows, numcols, section, more,custom):
        lower = float(obj.GetUnformattedValueAt(i,j))
        upper = float((obj.GetUnformattedValueAt(i,j+1)))
        prod = lower * upper
        if prod >= 0:
            obj.SetBackgroundColorAt(i, 0, customstylefunctions.RGB((255, 255, 0)))
    end program.


    STATS CORRELATIONS VARIABLES=bdate educ salary salbegin
    /WITH VARIABLES=jobtime prevexp
    /OPTIONS CONFLEVEL=95 METHOD=FISHER
    /MISSING EXCLUDE=YES PAIRWISE=YES.

    SPSSINC MODIFY TABLES subtype="CICORRELATIONS"
    SELECT="Lower C.I." DIMENSION= COLUMNS LEVEL = -1 PROCESS = PRECEDING
    /STYLES  APPLYTO=DATACELLS
    CUSTOMFUNCTION="__main__.colorsig".

    --





  • 3.  RE: Modifying Output of STATS CORRELATIONS: Highlight significant rows?

    Posted Sun February 26, 2023 04:13 PM
    Thank you very much, Jon.
    This is very helpful for me.