Announcement

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

  • Stata command for comparing count/frequency data between two time periods?

    Hello Statalist,

    I'd like to ask which statistical model I need to use to compare frequency data (e.g., never, rarely, sometimes, frequently, always) and count/incidence data (yes, no) between two time periods within the same groups (not between group), and to get p-value?

    Thank you for your help in advance!

  • #2
    Your description of the variables in your dataset doesn't make sense to me for either a within-group or between-group data structure.

    For a within-group structure at each of two times with single groupwise count variable (in lieu of an individual member ID variable), I would have expected something like what you get after running the following lines.
    Code:
    version 17.0
    
    clear *
    
    // seedem
    set seed 823830557
    
    quietly set obs 5
    generate byte rarity_score1 = _n - 1
    
    quietly expand 5
    bysort rarity_score1: generate byte rarity_score2 = _n - 1
    
    label define RarityScores 0 Never 1 Rarely 2 Sometimes 3 Frequently 4 Always
    label values rarity_score? RarityScores
    
    generate int count = runiformint(50, 500)
    
    label variable rarity_score1 "Frequency data, Period 1"
    label variable rarity_score2 "Frequency data, Period 2"
    label variable count "Count/incidence data"
    
    list, noobs abbreviate(20) sepby(rarity_score1)
    
    exit
    Does your dataset look like that?

    Note that the "count/incidence data" variable is not Boolean, not a "(yes, no)" type.

    Comment


    • #3
      Thank you Jeseph!

      I added an example of the dataex. I'd like to compare hospital visit (hospital1 vs hospital2) and frequency (frequency1 vs frequency2). In this case, which statistical model I can use to get p-value?

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input float personid str3 hospital1 str10 frequency1 str4 hospital2 str10 frequency2
       1 "yes" "always"     "yes" "always"    
       2 "yes" "sometimes"  "yes" "always"    
       3 "yes" "never"      "yes" "sometimes" 
       4 "no"  "always"     "yes" "sometimes" 
       5 "no"  "rarely"     "yes" "rarely"    
       6 "no"  "frequently" "no"  "frequently"
       7 "no"  "sometimes"  "no"  "always"    
       8 "no"  "always"     "no"  "always"    
       9 "no"  "always"     "no"  "always"    
      10 "no"  "never"      "no"  "sometimes" 
      end

      Comment

      Working...
      X