SPSS Statistics

 View Only
  • 1.  "completing" a sparse matrix

    Posted Tue January 26, 2021 09:55 AM

    Hello,

     

    Looking for suggestions to add missing entries to a sparse data matrix. For example, say I have the following:

    data list / var1 var2 var3 1-6.

    begin data.

    1 1 5

    1 2 6

    1 3 7

    2 1 8

    2 3 3

    end data.

     

    Notice record for combination var1=2 & var2=2 is missing. I would like to have the following output to complete the data. In SAS you can use the SPARSE option in PROC FREQ.

     

    1 1 5

    1 2 6

    1 3 7

    2 1 8

    2 2 .

    2 3 3

     

    Thank you!

     

    E.



    This e-mail and any files transmitted with it may contain privileged or confidential information. It is solely for use by the individual for whom it is intended, even if addressed incorrectly. If you received this e-mail in error, please notify the sender; do not disclose, copy, distribute, or take any action in reliance on the contents of this information; and delete it from your system. Any other use of this e-mail is prohibited.


    Thank you for your compliance.



    #SPSSStatistics


  • 2.  RE: "completing" a sparse matrix

    IBM Champion
    Posted Tue January 26, 2021 10:20 AM
    Are you looking to augment the dataset or just display all combinations in a table?  If the latter, CTABLES will do that as long as value labels exist for all values of the variables in question.

    If the former, a little custom Python code could augment the data, but how would you distinguish augmented cases from real ones if the real ones could have missing values?

    --





  • 3.  RE: "completing" a sparse matrix

    Posted Tue January 26, 2021 12:15 PM

     

    Thank you Jon. It is for the former, to augment the data. But not a "case by case" data, but an aggregated database. Say I have a database with GroupVar1 and GroupVar2, and I want to get one record for each possible GroupVar1 * GroupVar2 combination, even if a specific combination does not exist in the database. For example, if I were using the AGGREGATE command to count the number of cases, I would like to get N=0 for VAR1=VAR2=2 in the example below.

     

     

    E.

     

     






  • 4.  RE: "completing" a sparse matrix

    IBM Champion
    Posted Tue January 26, 2021 02:05 PM
    I have a little Python code I can send you if you send me your email address.

    --