Announcement

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

  • satisfies a threshold on at 3 or more days per week

    Hi I am trying to generate a variable which satisfies these assumptions if mod_to_vigorous_activity >=1 | vigorous_activity >=1 on at least 3 or more days per recording
    Measurement day = is the day of recording measured 1-8


    right now i GOT up to here :

    Code:
    bys id: egen who65= 1 if mod_to_vigorous_activity>=1 | vigorous_activity
    I'm stuck trying to incorporate the measurement day.......
    Can anyone help?

    Many thanks


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long id byte measurementday float(mod_to_vigorous_activity vigorous_activity)
      10 1      .     .
      10 2 30.833     3
      10 3 16.833 1.917
      10 4 25.083 1.833
      10 5 28.417 3.083
      10 6  20.75   2.5
      10 7     18  2.75
      10 8      .     .
    1032 1      .     .
    1032 2 22.917 1.083
    1032 3     30  .833
    1032 4 16.917  .333
    1032 5 19.333  .333
    1032 6  21.25  .583
    1032 7 27.667  .167
    1032 8      .     .
    1055 1 67.167   2.5
    1055 2 64.667  5.25
    1055 3 75.083 5.833
    1055 4 71.083 4.083
    end

  • #2
    Perhaps

    Code:
    bys id: egen count= total((!missing(mod_to_vigorous_activity) & mod_to_vigorous_activity) | (!missing(vigorous_activity) & vigorous_activity))
    gen who65= count>=3

    Comment


    • #3
      Thanks for your input, but that doesn’t take into consideration this ID:

      Code:
      1032 7 27.667 .167
      as although vigorous is not missing it is still <1
      this would mean if I change my threshold from 1 to 5, this would not work.


      1032 7 27.667 .167
      Last edited by Tara Boyle; 15 Aug 2024, 07:09.

      Comment


      • #4
        Change

        (!missing(mod_to_vigorous_activity) & mod_to_vigorous_activity) | (!missing(vigorous_activity) & vigorous_activity)
        to

        Code:
        (!missing(mod_to_vigorous_activity) & mod_to_vigorous_activity>=1) | (!missing(vigorous_activity) & vigorous_activity>=1)

        Comment

        Working...
        X