Announcement

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

  • Writing a formula in which stata chooses a value or 1

    Hi!

    I'm trying to use this formula to calculate eGFR: eGFR = 142*min(standardized Scr/K, 1)^α *max(standardized Scr/K, 1)^-1.200 *0.9938Age *1.012 [if female]
    Scr= creatinine, e.g. creatinine=2.4.

    In this formula, the min(standardized Scr/K, 1) means that you either choose the creatinine value divided by kappa, OR 1. The same goes for the max-one.

    I'm looking for advice on how to write the command so Stata realizes this. Grateful for any help!

  • #2
    I realised it might be hard to understand from my explanation: if the Scr/K is less than 1, it should choose that value. otherwise it should choose 1. The same goes for the maximum; if the Scr/K is larger than 1, it should choose that. Otherwise it should choose 1.

    Comment


    • #3
      I'm not sure I follow what the problem is.

      min() and max() are both functions available in Stata. See e.g.
      Code:
      help min()

      Comment


      • #4
        My problem is that i dont know how to write “Scr/k if less than 1, otherwise 1” in the equation.

        Comment


        • #5
          This is how the min() function works:
          Code:
          . scalar Scr = 5
          . scalar K = 10
          . dis min(Scr/K,1)
          .5
          . scalar K = 2
          . dis min(Scr/K,1)
          1

          Comment


          • #6
            Thank you Hemanshu! I hade a typo making it not work. Thanks a lot!

            Comment

            Working...
            X