Announcement

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

  • Natural log function

    Dear Statalist members,

    I am running simple code to calculate stock return:

    generate var1return=log(var1 /L.var1)

    Suppose var1=2080 and L.var1=1980.

    var1return=0.04927105084

    When I replicate the same prosedure in excel var1return=0.04927104901

    Difference is 0.00000000183. My target variable is mean return.The difference between return estimated in Stata and Excel gets bigger for a big sample.

    Are you aware of the reason for that difference?

  • #2
    Use a double variable if you want more precision. Stata can echo that result; the problem is that your own generate command produces a float.

    Code:
    . di %23.18f   ln(2080/1980)
       0.049271049006782835

    Comment


    • #3
      Thank you Nick. It works perfectly now.

      Comment

      Working...
      X