Announcement

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

  • Why do I put parentheses ( ) around a variable that the results are different?

    Dear All,
    I calculated the willingness to pay by stata 11.0 from 2 equations.
    1.
    Code:
    nlcom  ((_b[ba_salary]*15000)+_b[inf7]+_b[log7]+_b[ asc])/(-_b[ ba_salary])
    
           _nl_1:  ((_b[ba_salary]*15000)+_b[inf7]+_b[log7]+_b[ asc])/(-_b[ ba_salary])
    
    ------------------------------------------------------------------------------
          choice |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           _nl_1 |   6551.413   1530.388     4.28   0.000     3551.907    9550.919
    ------------------------------------------------------------------------------
    and
    2.
    Code:
    nlcom  (_b[ba_salary]*15000)+_b[inf7]+_b[log7]+_b[ asc]/(-_b[ ba_salary])
    
           _nl_1:  (_b[ba_salary]*15000)+_b[inf7]+_b[log7]+_b[ asc]/(-_b[ ba_salary])
    
    ------------------------------------------------------------------------------
          choice |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           _nl_1 |   16676.88   1497.943    11.13   0.000     13740.97     19612.8
    ------------------------------------------------------------------------------
    why are coef. present a different value?

    Thank you very much
    Best Wishes
    Sukunta Muadthong

  • #2
    The order of operations in math (with no parentheses or within parentheses is 1) exponents 2) multiplication and/ or division 3) addition and/or subtraction

    So, the first equation does this first because it is in parentheses
    Code:
    ( (_b[ba_salary]*15000)+_b[inf7]+_b[log7]+_b[ asc] )
    Then takes that result and divides by
    Code:
    (-_b[ ba_salary])

    The second equation does the division before the addition
    Code:
    _b[ asc]/(-_b[ ba_salary])
    Then adds that result to
    Code:
    (_b[ba_salary]*15000)+_b[inf7]+_b[log7]

    A more simplified example

    Code:
    *divide first then add
    10+10+100 /  2
    = 10 + 10 + 50
    = 70
    
    *add first because in parentheses then divide
    (10 + 10 + 100) / 2
    = 120 / 2
    = 60
    Stata/MP 14.1 (64-bit x86-64)
    Revision 19 May 2016
    Win 8.1

    Comment


    • #3
      Dear Carole J.Wilson,
      OH .. thank you very much for your kindness. that is very clear .

      Best Wishes,
      Sukunta Muadthong

      Comment

      Working...
      X