Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • A problem with transforming my data from double to float

    Dear friends,

    I have a continuous variable. When I check variables manager, it still says the variable is double. Why do I see that the variable is still a double one?
    Thank you,
    Best,

    Here is my code and error:

    Code: "recast float chinaimports"

    Error "chinaimports: 4044 values would be changed; not changed"

    Best Regards






  • #2
    See the output of the following command for the answer.

    Code:
    help recast
    -recast- is defensive by nature, and prevents you from accidentally losing data (precision, in this case).

    Comment


    • #3
      Dear Leonardo,

      Thank you so much,

      I will check again.

      Comment


      • #4
        As the error tells you, recasting from double to float will cause 4044 observations within chinaimports to lose some precision through slight rounding, because float is a less precise datatype than double (see help data_types).

        After reading through help data_types and understanding the difference between float and double, reconsider if there is a specific reason you wish to recast your variable to float. If you do have a specific reason, and still want to proceed with the knowledge that you will lose precision in 4044 observations, then use recast's -force- option to go ahead with the operation despite the data loss.
        Last edited by Ali Atia; 19 Apr 2022, 14:31.

        Comment


        • #5
          Dear Ali,

          I preparing my dataset for running various regression models including pooled-time series, fixed effects, and to some extent Poisson for a different dependent "count" variable,
          I just think to transform in order to see how it affects my results. But, you are right, there might be no reason for doing that.

          Best Regards,


          Comment


          • #6
            Originally posted by Nihat Mugurtay View Post
            Dear Ali,

            I preparing my dataset for running various regression models including pooled-time series, fixed effects, and to some extent Poisson for a different dependent "count" variable,
            I just think to transform in order to see how it affects my results. But, you are right, there might be no reason for doing that.

            Best Regards,

            If that's all you are trying to do, then I suggest it doesn't make sense. Indeed, you may event want to run -compress- because it might be that your variables stored in double precision are in fact integers (so really only need byte, int, or long storage types). Let's imagine the results do change as a result of storage as either being stored as float (single) or double precision, then they will be differing likely only in the 5th decimal point or beyond. And if they did, so what? To see meaningfully different results at that level of precision probably implies some crazy level of precision is demanded by your problem, and that is very very unlikely.

            Comment


            • #7
              Dear Leonardo,

              Thank you a lot, now I understand your point. My work does not require an obsession with precision.

              Best,

              Comment

              Working...
              X