Announcement

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

  • Count regression for admissions in pediatric psychiatry. Am I doing correctly?

    Dear all,
    I have a dataset in which each row represents a hospitalization in a pediatric psychiatry.
    For each patient (id) there is the sex, year, diagnosis (from diagnosis1 to diagnosis13), whether the day of hospitalization was a school day or not, the month and the season.
    I would like to understand if the incidence increases over the years, and if over the years for example one sex increases compared to the other, or one diagnosis compared to the other etc.

    The data is organized like this:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input int(year id) double age byte sex str9 month str6 stagione str10 school byte(diagnosis1 diagnosis2 diagnosis3 diagnosis4 diagnosis5 diagnosis6 diagnosis7 diagnosis8 diagnosis9 diagnosis10 diagnosis11 diagnosis12 diagnosis13)
    2014  14   14 0 "January"   "Winter" "School"     0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  64 15.2 1 "January"   "Winter" "School"     0 1 0 0 0 0 1 1 1 1 0 0 0
    2014  40 17.3 1 "January"   "Winter" "School"     0 1 1 0 0 0 0 1 0 0 1 0 0
    2014  66 17.7 0 "January"   "Winter" "School"     0 0 0 1 0 0 0 0 0 0 0 1 0
    2014  67 16.3 1 "January"   "Winter" "School"     0 0 0 0 0 0 0 0 0 0 0 1 0
    2014  68 14.9 0 "January"   "Winter" "School"     0 0 1 0 0 0 0 0 0 0 0 1 0
    2014  61 12.1 0 "January"   "Winter" "School"     0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  69 15.8 0 "January"   "Winter" "School"     0 0 0 0 0 0 0 0 0 0 1 1 0
    2014  66 17.8 0 "February"  "Winter" "Non School" 0 0 0 1 0 0 0 0 0 0 0 0 0
    2014  17 15.7 0 "February"  "Winter" "School"     0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  72 14.6 1 "February"  "Winter" "School"     0 0 0 0 0 0 0 0 0 0 0 0 1
    2014  50 12.9 0 "February"  "Winter" "School"     0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  74 16.5 0 "February"  "Winter" "School"     0 0 0 0 0 0 0 1 1 0 0 0 0
    2014  75 18.9 1 "February"  "Winter" "Non School" 0 0 0 1 0 0 0 0 0 0 0 0 0
    2014  35 17.4 1 "February"  "Winter" "School"     0 0 0 1 0 0 0 0 0 0 0 0 0
    2014  79 17.7 1 "February"  "Winter" "School"     0 1 0 0 0 0 0 0 0 1 0 0 0
    2014  82 14.6 1 "February"  "Winter" "School"     0 0 1 0 0 0 0 0 0 0 1 0 1
    2014  22 16.4 1 "February"  "Winter" "School"     1 0 0 0 0 0 0 1 0 0 0 0 0
    2014  17 15.7 0 "February"  "Winter" "School"     0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  43 16.4 0 "February"  "Winter" "School"     1 0 0 0 0 0 0 1 0 0 0 0 0
    2014  84 14.7 0 "March"     "Winter" "Non School" 0 1 0 0 0 0 0 0 0 0 0 0 0
    2014  83 16.9 0 "March"     "Winter" "Non School" 0 1 0 0 0 0 0 1 0 0 0 0 0
    2014  85 17.7 1 "March"     "Winter" "Non School" 0 0 0 0 0 0 0 1 0 0 1 0 0
    2014  38   15 1 "March"     "Winter" "Non School" 0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  86 18.9 0 "March"     "Winter" "Non School" 0 0 1 1 0 0 0 0 0 0 0 1 0
    2014  87 17.9 1 "March"     "Winter" "Non School" 0 1 1 0 0 0 0 1 1 0 0 1 1
    2014  88 15.8 1 "March"     "Winter" "School"     0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  38   15 1 "March"     "Winter" "School"     0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  61 12.2 0 "March"     "Winter" "School"     0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  71 15.8 1 "March"     "Winter" "School"     0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  40 17.5 1 "March"     "Spring" "School"     0 1 1 0 0 0 0 1 0 0 1 0 0
    2014  43 16.5 0 "March"     "Spring" "Non School" 1 0 0 0 0 0 0 1 0 0 0 0 0
    2014  94 12.8 1 "March"     "Spring" "School"     0 0 0 1 0 0 0 1 0 0 0 0 0
    2014  84 14.8 0 "March"     "Spring" "School"     0 1 1 0 0 0 0 0 0 1 0 0 0
    2014  40 17.5 1 "March"     "Spring" "School"     0 1 1 0 0 0 0 1 0 0 1 1 0
    2014  83   17 0 "APril"     "Spring" "School"     0 1 0 0 0 0 0 0 0 0 0 0 0
    2014  96 14.7 0 "APril"     "Spring" "School"     0 0 0 1 1 0 1 1 1 0 1 1 0
    2014  71 15.9 1 "APril"     "Spring" "School"     0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  52 16.2 1 "APril"     "Spring" "School"     1 0 1 0 0 0 0 1 0 0 0 0 0
    2014  98 16.6 1 "APril"     "Spring" "Non School" 0 0 0 1 0 0 0 0 0 0 0 0 0
    2014  94 12.9 1 "APril"     "Spring" "Non School" 0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  61 12.3 0 "APril"     "Spring" "Non School" 0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  98 16.6 1 "APril"     "Spring" "Non School" 0 0 0 1 0 0 0 0 0 0 0 0 0
    2014  99 13.5 1 "APril"     "Spring" "Non School" 0 0 1 0 0 0 0 1 0 0 0 1 0
    2014  94 12.9 1 "APril"     "Spring" "Non School" 0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  94 12.9 1 "APril"     "Spring" "School"     0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  40 17.6 1 "APril"     "Spring" "School"     0 1 1 0 0 0 0 1 0 0 1 1 0
    2014 104 16.3 0 "May"       "Spring" "School"     0 0 1 0 0 0 0 1 0 0 0 0 0
    2014 105 18.4 0 "May"       "Spring" "School"     1 0 0 1 0 0 0 0 0 0 0 0 0
    2014 106 10.7 0 "May"       "Spring" "School"     0 0 0 1 0 0 0 1 1 0 0 0 0
    2014  52 16.3 1 "May"       "Spring" "School"     1 0 0 0 0 0 0 1 0 0 0 0 0
    2014 107 14.8 1 "May"       "Spring" "Non School" 0 0 0 1 0 1 0 0 0 0 1 0 0
    2014  80 15.3 0 "May"       "Spring" "School"     0 0 0 0 0 0 1 1 0 0 0 0 0
    2014 109 14.6 0 "May"       "Spring" "School"     0 0 0 0 0 0 1 1 1 0 0 0 0
    2014 111 13.8 1 "May"       "Spring" "School"     0 0 0 0 0 0 0 0 0 0 1 1 0
    2014 112 14.4 1 "May"       "Spring" "School"     0 0 0 0 0 0 1 0 1 0 1 1 0
    2014  52 16.3 1 "May"       "Spring" "School"     1 0 0 0 0 0 0 1 0 0 0 0 0
    2014 114 16.1 1 "May"       "Spring" "School"     0 0 1 0 0 0 0 0 0 0 0 0 0
    2014 115 14.8 1 "May"       "Spring" "School"     0 0 0 1 0 0 1 1 1 0 0 0 0
    2014 116 17.1 1 "May"       "Spring" "School"     0 0 0 0 0 0 0 1 0 0 0 0 0
    2014 118 15.4 1 "May"       "Spring" "Non School" 0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  94   13 1 "June"      "Spring" "School"     0 0 0 0 0 0 0 1 0 0 1 0 0
    2014 119 15.2 1 "June"      "Spring" "School"     0 0 0 1 1 0 0 0 1 0 0 0 0
    2014  94 13.1 1 "June"      "Spring" "School"     0 0 1 0 0 0 0 1 0 0 0 0 0
    2014 120   18 0 "June"      "Spring" "Non School" 0 0 1 1 1 0 1 0 0 0 0 1 0
    2014  94 13.1 1 "July"      "SUmmer" "Non School" 0 0 1 0 0 0 0 1 0 0 0 0 0
    2014  30 15.9 0 "July"      "SUmmer" "Non School" 0 0 1 1 0 0 0 0 0 0 0 0 0
    2014 125 14.8 1 "July"      "SUmmer" "Non School" 0 0 1 0 0 0 1 1 0 0 1 0 0
    2014  82   15 1 "July"      "SUmmer" "Non School" 0 0 0 0 0 0 0 0 0 0 1 0 0
    2014 128   16 1 "July"      "SUmmer" "Non School" 0 0 0 1 0 0 0 0 0 0 1 0 0
    2014 130 17.8 1 "July"      "SUmmer" "Non School" 0 0 1 1 0 0 1 0 0 0 0 0 1
    2014 132 14.6 1 "August"    "SUmmer" "Non School" 0 0 1 1 0 0 0 0 1 0 0 0 0
    2014  82   15 1 "August"    "SUmmer" "Non School" 0 0 1 0 0 0 0 1 0 0 0 0 0
    2014  80 15.6 0 "August"    "SUmmer" "Non School" 0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  38 15.5 1 "August"    "SUmmer" "Non School" 0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  28 18.7 1 "August"    "SUmmer" "Non School" 0 1 1 0 0 0 0 0 0 0 0 0 0
    2014 136 17.6 1 "August"    "SUmmer" "Non School" 0 0 0 1 0 0 1 1 1 0 0 0 1
    2014 106 11.1 0 "September" "SUmmer" "School"     0 0 1 0 0 0 0 1 1 1 0 0 0
    2014 139 15.8 1 "September" "SUmmer" "School"     0 0 1 0 0 0 0 0 1 0 1 1 0
    2014 124   14 0 "September" "SUmmer" "School"     0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  82 15.1 1 "September" "SUmmer" "School"     1 0 0 0 0 0 0 1 0 0 0 0 0
    2014 141 16.6 0 "September" "SUmmer" "School"     0 0 0 1 1 0 0 0 0 0 0 0 0
    2014 145 14.5 0 "September" "SUmmer" "School"     0 0 1 1 0 0 0 0 0 0 0 1 0
    2014 109 14.9 0 "September" "SUmmer" "Non School" 0 0 0 0 0 0 1 1 0 0 0 0 0
    2014  35   18 1 "September" "SUmmer" "School"     0 1 1 1 0 0 0 0 0 0 1 0 0
    2014  94 13.3 1 "September" "Autumn" "School"     0 0 0 0 0 0 0 1 0 0 0 0 0
    2014 148 15.9 0 "September" "Autumn" "School"     0 1 1 1 1 0 0 1 1 0 0 0 0
    2014 127 13.3 1 "September" "Autumn" "School"     0 0 1 0 0 0 0 0 1 0 1 0 0
    2014 149 15.2 1 "September" "Autumn" "Non School" 0 0 0 1 0 0 0 0 0 0 0 0 0
    2014 150 16.9 1 "September" "Autumn" "School"     0 0 0 0 1 0 0 0 0 0 0 0 0
    2014  94 13.4 1 "September" "Autumn" "School"     0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  40   18 1 "September" "Autumn" "School"     0 1 1 0 0 0 0 1 0 0 1 0 0
    2014  94 13.4 1 "October"   "Autumn" "School"     0 0 0 0 0 0 0 1 0 0 0 0 0
    2014 130 17.9 1 "October"   "Autumn" "School"     0 0 1 1 0 0 0 0 0 0 0 0 0
    2014  38 15.6 1 "October"   "Autumn" "School"     0 0 0 0 0 0 0 1 0 0 0 0 0
    2014 152 16.5 1 "October"   "Autumn" "School"     0 0 0 1 0 0 0 0 1 0 0 0 0
    2014  17 16.3 0 "October"   "Autumn" "School"     0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  17 16.3 0 "October"   "Autumn" "School"     0 0 0 0 0 0 0 1 0 0 0 0 0
    2014  94 13.4 1 "October"   "Autumn" "Non School" 0 0 0 0 0 0 0 1 0 0 0 0 0
    2014 153 14.5 0 "October"   "Autumn" "School"     0 0 1 0 0 0 0 0 1 0 0 0 0
    end
    My idea is to collapse to monthly counts, stratified by sex, diagnosis, etc., and then do a regression by counts.
    I would do it like this:
    Code:
    collapse (count) admissions = id (mean) age , by(month school year sex)
    poisson admissions i.year i.sex i.school i.month, irr
    I would not put any offset because I assume that each month is more or less of equal length.

    I'd possibly evaluate the interaction:
    Code:
    poisson admissions i.year##i.sex i.school i.month, irr
    Am I doing something wrong?
    Do you think this give me the answer I'm asking data?

    Thank you very much for your help.
    Gianfranco

  • #2
    I was thinking about the question of month length only yesterday -- but in the context of climatology and hydrology, where too it is common if not conventional to ignore variations from month to month.

    In this case, you could say I think that what you're estimating depends on a mix of month-dependent factors, including

    1. whatever varies as climate and weather vary -- including day length, etc.

    2. whatever varies culturally with time of year e.g. starting and stopping of school teaching, holidays, when psychiatrists take holidays, etc.

    3. the month length, as that alone leads to variations of the order of 10%.

    But your month variable is at present string and needs to be encoded. In what I can see everything looks fine apart from the spelling APril.

    Do not encode using the default alphabetical order. Here is some technique. I note that months and seasons don't always correspond tone to one.

    Also SUmmer needs a fix.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str9 month str6 stagione
    "January"   "Winter"
    "February"  "Winter"
    "March"     "Winter"
    "March"     "Spring"
    "APril"     "Spring"
    "May"       "Spring"
    "June"      "Spring"
    "July"      "SUmmer"
    "August"    "SUmmer"
    "September" "SUmmer"
    "September" "Autumn"
    "October"   "Autumn"
    end
    
    replace month = proper(month)
    replace stagione = proper(stagione)
    
    tokenize "`c(Months)'" 
    
    forval m=1/12 { 
        label def MONTH `m' "``m''", add 
    }
    
    label def SEASON 1 Winter 2 Spring 3 Summer 4 Autumn 
    
    label list 
    
    encode month, gen(MONTH) label(MONTH)
    
    encode stagione, gen(SEASON) label(SEASON)
    
    list 
    
    list, nola
    Results

    Code:
    . * Example generated by -dataex-. For more info, type help dataex
    . clear
    
    . input str9 month str6 stagione
    
             month   stagione
      1. "January"   "Winter"
      2. "February"  "Winter"
      3. "March"     "Winter"
      4. "March"     "Spring"
      5. "APril"     "Spring"
      6. "May"       "Spring"
      7. "June"      "Spring"
      8. "July"      "SUmmer"
      9. "August"    "SUmmer"
     10. "September" "SUmmer"
     11. "September" "Autumn"
     12. "October"   "Autumn"
     13. end
    
    . 
    . replace month = proper(month)
    (1 real change made)
    
    . replace stagione = proper(stagione)
    (3 real changes made)
    
    . 
    . tokenize "`c(Months)'" 
    
    . 
    . forval m=1/12 { 
      2.         label def MONTH `m' "``m''", add 
      3. }
    
    . 
    . label def SEASON 1 Winter 2 Spring 3 Summer 4 Autumn 
    
    . 
    . label list 
    SEASON:
               1 Winter
               2 Spring
               3 Summer
               4 Autumn
    MONTH:
               1 January
               2 February
               3 March
               4 April
               5 May
               6 June
               7 July
               8 August
               9 September
              10 October
              11 November
              12 December
    
    . 
    . encode month, gen(MONTH) label(MONTH)
    
    . 
    . encode stagione, gen(SEASON) label(SEASON)
    
    . 
    . list 
    
         +-------------------------------------------+
         |     month   stagione       MONTH   SEASON |
         |-------------------------------------------|
      1. |   January     Winter     January   Winter |
      2. |  February     Winter    February   Winter |
      3. |     March     Winter       March   Winter |
      4. |     March     Spring       March   Spring |
      5. |     April     Spring       April   Spring |
         |-------------------------------------------|
      6. |       May     Spring         May   Spring |
      7. |      June     Spring        June   Spring |
      8. |      July     Summer        July   Summer |
      9. |    August     Summer      August   Summer |
     10. | September     Summer   September   Summer |
         |-------------------------------------------|
     11. | September     Autumn   September   Autumn |
     12. |   October     Autumn     October   Autumn |
         +-------------------------------------------+
    
    . 
    . list, nola 
    
         +---------------------------------------+
         |     month   stagione   MONTH   SEASON |
         |---------------------------------------|
      1. |   January     Winter       1        1 |
      2. |  February     Winter       2        1 |
      3. |     March     Winter       3        1 |
      4. |     March     Spring       3        2 |
      5. |     April     Spring       4        2 |
         |---------------------------------------|
      6. |       May     Spring       5        2 |
      7. |      June     Spring       6        2 |
      8. |      July     Summer       7        3 |
      9. |    August     Summer       8        3 |
     10. | September     Summer       9        3 |
         |---------------------------------------|
     11. | September     Autumn       9        4 |
     12. |   October     Autumn      10        4 |
         +---------------------------------------+

    Comment


    • #3
      Thanks a lot, Nick Cox! Please forgive my ignorance:
      essentially, the Month and Season variables have been transformed into numeric ones, with all the associated advantages.

      Do you think my idea to analyze them using collapse with count regression is still valid?

      Thanks again! Gianfranco

      Comment


      • #4
        Surely, I would start with Poisson regression here.

        Comment


        • #5
          poisson with robust standard errors

          Comment


          • #6
            Dear Nick Cox and George Ford ,
            first of all, thanks again for your support.

            I have a problem here with this analysis:
            the "collapse" command, as it is designed, does NOT return cells with zero counts.

            This, I imagine, can lead to biased estimates of poisson regression (quasi-poisson, negative binomial, and so on...).
            Do you agree with this? If I remember correctly, Clyde Schechter talked about it in a post from a few years ago that I can't find now.

            I tried to use the "contract" command but it does not return the means of the continuous variables (for example age) that I would like to use as a covariate.

            Do you have any idea how to solve the problem?

            Thanks again everyone!

            Comment


            • #7
              If you don't have any observations of some kind, a fortiori there aren't data on covariates to average any way. Or are there?

              If I don't have data on numbers of green cats, I can't average their length or weight, for example.

              Comment


              • #8
                Sure. If a cell (i.e. a certain combination of year, month, school, sex...) were empty, then I would have a missing value.

                The thing that is not clear to me is whether using collapse and omitting the empty cells could have biased estimates.

                I would say yes: if, let's say, in October 2018 I had zero hospitalizations among males, I would have zero in the relative cell.

                But if I do not produce the cell, and therefore do not consider it in the analysis, in my Poisson regression I will have an overestimation of the October coefficient and that of the males.

                What do you think Nick Cox ?

                Comment


                • #9
                  The explanation seems to be that you have a subset of children but there might have been no admissions under certain conditions. That make sense, but you could use collapse followed by fillin, or have an approach in which you combine collapse and contract, merging the results files.
                  Last edited by Nick Cox; 05 Dec 2024, 09:21.

                  Comment


                  • #10
                    Great. Thank you very much!

                    Comment

                    Working...
                    X