SPSS Statistics

SPSS Statistics

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

 View Only
Expand all | Collapse all

dealing with floating point double-precision number issues in syntax

  • 1.  dealing with floating point double-precision number issues in syntax

    Posted Tue September 03, 2024 03:41 PM

    Hi,

    I am working with SPSS for managing and analyzing large datasets using syntax files and make use of aggregation procedures quite frequently. Over het last months I have experienced more and more problems in aggregating data because of small differences in computed variables which are supposed to be the same. e.g. the age of a subject (which is supposed to be in whole years, but had a standard formatting of F8.2) changed for some lines with data from the same subject from 35,0000000000 to 35,0000000002 years. This difference prevents the aggregation of other variables in case I mention age in the aggregation procedure as fixed variable. I solved the issue by rounding the age variable and changing the format to F8.0), but I want to make sure that this is the right solution, so that I am not running into problems with other aggregation procedures in the same and following syntaxes. Hope anyone can help me with this rather annoying issue.

    Kind regards,

    Hans van Oostenbrugge



    ------------------------------
    Hans Oostenbrugge
    ------------------------------


  • 2.  RE: dealing with floating point double-precision number issues in syntax

    Posted Tue September 03, 2024 05:50 PM
    The variable format only affects how values are displayed.  The full precision value is always used in computations, so changing the format from F8.2 to F8.0 actually has no effect on computation.  Variable formats are sometimes used as a basis for output displays in tables and charts, but, again, the full precision value is unaffected.  You might want to change the format to scientific notation just  to make it easier to see what the exact values are in diagnosing this behavior.

    All numeric values are kept as double precision floating point values, which means approximately 15 significant figures.  If you trace a value like 35,0000000002 that should be an integer back to its inputs, you should be able to see where that dangling digit came from.  It may be an issue with your data import, so look at the full precision input values.  Rounding those values may be appropriate.  Note also that some values cannot be represented exactly in floating point, because of the nature of floating point hardware,

    Of course, variable transformations could produce values like this, but that seems very unlikely in this example.

    There is a rather mysterious setting you can change via Edit > Options > Data that affects exactly how truncation and rounding are done in transformation functions, but I would refer you that dialog's Help for details.  This setting very rarely needs to be changed.

    --





  • 3.  RE: dealing with floating point double-precision number issues in syntax

    Posted Mon September 16, 2024 07:26 AM

    Thanks John,

    Although it does not completely solve my problem it provides me with directions where to look for this. 



    ------------------------------
    Hans Oostenbrugge
    ------------------------------