SPSS Statistics

SPSS Statistics

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


#Analytics
#SPSSStatistics
#Analyticstools
 View Only
  • 1.  Linear Discrimination Analysis: Saving Output

    Posted 10/11/22 10:41 AM
    Hi all,

    I have a me-specific question about formatting SPSS output from linear discrimination analysis

    I'm measuring brain response (microvolts) using EEG while people play a game that involves pressing a button. The outcome measure of the task is reaction time... a "good" trial is one in which the participant presses the button promptly, and a "bad" trial is one in which they zone out and press the button late. I want to train a classifier to see if individual trials can be classified into "fast," "medium" or "slow" based on the brain response. Since every brain is different, want to run a separate model for each person who plays the game. I then want to compare model performance across people to see if there are certain features (for example: participant age) that are associated with better model performance.

    SPSS gives a lot of output when you run LDA, and I'm looking to isolate some specific ones. Is there a way I can ask SPSS to tell me only the percent correctly classified (number shown in the yellow highlight in Screenshot1.png)? This will be helpful as I compare model performance across participants. It would be doubly helpful if there was a way that SPSS could organize those values coherently for me. I've attached a screenshot to illustrate what the ideal output would look like (Screenshot2.png).

    Thanks so much for your help!

    Best,
    KW


    ------------------------------
    Kathryn WT
    ------------------------------

    #SPSSStatistics


  • 2.  RE: Linear Discrimination Analysis: Saving Output

    Posted 10/11/22 11:17 AM
    Hi. OK, so you need a table consisting of (number correctly classified) / (Total N) for both groups.

    It sounds like a job for OMS and Python to me.

    In very general terms, you use:
    1. The OMS command to select only that table from Discrim.
    2. Python to get the data out of it, do the right math, and put it in a table.

    If you want me to put a prototype together for you, send me the data and syntax.
    marcantr@us.ibm.com


    ------------------------------
    Rick Marcantonio
    Quality Assurance
    IBM
    ------------------------------



  • 3.  RE: Linear Discrimination Analysis: Saving Output

    Posted 10/11/22 11:23 AM
    Another way to do that would be to save the predicted class from discriminant; then do a compute on correct or incorrect - compute dis_1 eq dv, where dv is the dependent variable.
    You would get the overall pct correct from descriptives, but you could use split files on the case id to get that for each subject or define other groupings for the table using descriptives or summarize.

    --





  • 4.  RE: Linear Discrimination Analysis: Saving Output

    Posted 10/11/22 12:52 PM

    This is an example, using one of the datasets we ship with the product.

    dataset close all.
    
    get file '/Applications/IBM SPSS Statistics/Resources/Samples/English/Employee data.sav'.
    
    dataset declare d.
    
    oms /select all /destination viewer=no /tag="_n_".
    oms /select tables /if subtypes='Classification Results' /destination format=sav outfile=d /tag="x".
    
    DISCRIMINANT
     /GROUPS=jobcat(1 3) /VARIABLES=salary salbegin jobtime prevexp /STATISTICS=TABLE.
    
    omsend tag="x".
    
    dataset activate d.
    select if Var2 = "Count".
    execute.
    
    delete variables command_ to var3 total.
    
    omsend tag="_n_".
    
    BEGIN PROGRAM.
    import spss
    dataCursor=spss.Cursor()
    data=dataCursor.fetchall()
    dataCursor.close()
    d=list(data)
    
    N=0
    success=0
    c=0
    r=0
    
    for row in d:
      c=0
      for cell_data in row:
        N=N+cell_data
        if r == c:
          success=success+cell_data
        c=c+1
      r=r+1
    
    pct=success/N
    results=[N,success,pct]
    
    spss.StartProcedure("Results", "RESULTS")
    tbl = spss.BasePivotTable("Classification Results", "CR", caption="DISCRIM model")
    tbl.SimplePivotTable(rowdim="Case",
      rowlabels=['1'],
      coldim="",
      collabels=['N',"N(Success)","Pct(Success)"],
      cells = results )
    spss.EndProcedure()
    
    END PROGRAM.​



    ------------------------------
    Rick Marcantonio
    Quality Assurance
    IBM
    ------------------------------