Announcement

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

  • Appropriate statistical model for this data

    Hello, I have data on stolen cars from a U.S. city for the year 2024. Below is a dataex sample. The variable id identifies individuals; stolen_cars is the number of cars stolen from each individual; and the date variable records when the theft occurred. I’m interested in testing whether more cars were stolen during April 18–28, 2024. I created an indicator variable, intervention, that denotes whether the theft occurred outside this window (i.e., prior to April 18, 2024 or after April 28, 2024). I initially considered an ARIMA model, but the data are panel rather than a single time series. I also considered an interrupted time-series approach but wasn’t sure which model would be most appropriate. Would a segmented negative binomial regression be suitable? Any suggestions would be appreciated.


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte(id stolen_cars) str9 date byte intervention
    1 1 "1-Jan-24"  0
    2 3 "1-Jan-24"  0
    3 1 "1-Jan-24"  0
    4 2 "2-Jan-24"  0
    5 1 "18-Apr-24" 1
    6 1 "18-Apr-24" 1
    7 1 "30-Apr-24" 2
    8 1 "7-May-24"  2
    9 2 "7-May-24"  2
    end

  • #2
    Luis:
    why not going:
    Code:
    egen new_time=group( date)
    . poisson stolen_cars i.intervention i.new_time
    note: 2.new_time omitted because of collinearity.
    note: 5.new_time omitted because of collinearity.
    
    Iteration 0:  Log likelihood = -11.021237  
    Iteration 1:  Log likelihood = -11.021236  
    
    Poisson regression                                      Number of obs =      9
                                                            LR chi2(4)    =   0.75
                                                            Prob > chi2   = 0.9447
    Log likelihood = -11.021236                             Pseudo R2     = 0.0330
    
    ------------------------------------------------------------------------------
     stolen_cars | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
    intervention |
              1  |  -.5108255     .83666    -0.61   0.541    -2.150649    1.128998
              2  |  -.1053605   .7302967    -0.14   0.885    -1.536716    1.325995
                 |
        new_time |
              2  |          0  (omitted)
              3  |   .1823217     .83666     0.22   0.827    -1.457502    1.822145
              4  |   -.405465     1.1547    -0.35   0.725    -2.668636    1.857706
              5  |          0  (omitted)
                 |
           _cons |   .5108256   .4472136     1.14   0.253    -.3656969    1.387348
    ------------------------------------------------------------------------------
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      In addition to Carlo's helpful response, it would be interesting to know the distribution and descriptives of stolen_cars. This could help you decide whether poisson or nbreg are more appropriate.
      Best wishes

      Stata 18.0 MP | ORCID | Google Scholar

      Comment


      • #4
        the summary of the stolen_cars variable, it seems there's underdispersion so negative binomial regression instead of poisson right?

        Code:
           Percentiles      Smallest
         1%            1              1
         5%            1              1
        10%            1              1       Obs               2,210
        25%            1              1       Sum of wgt.       2,210
        
        50%            1                      Mean           1.115385
                                Largest       Std. dev.      .4726934
        75%            1              6
        90%            1              7       Variance       .2234391
        95%            2              7       Skewness        7.03407
        99%            3              9       Kurtosis       77.41599
        
        .

        Comment


        • #5
          When the conditional variance is greater than the conditional mean, nbreg seems better, but in your case you can go with poisson.
          https://stats.oarc.ucla.edu/stata/da...al-regression/

          You can also test:
          Code:
          tabstat stolen_cars, by(intervention) stats(mean var n)
          What is also unclear to me now: do you mean more cars stolen per thief in a given time or more thefts, in total?
          Last edited by Felix Bittmann; 19 Sep 2025, 08:21.
          Best wishes

          Stata 18.0 MP | ORCID | Google Scholar

          Comment


          • #6
            I thought you could use negative binomial for under-dispersion for a moment, it seems you can't

            Comment


            • #7
              Originally posted by Felix Bittmann View Post
              When the conditional variance is greater than the conditional mean, nbreg seems better, but in your case you can go with poisson.
              https://stats.oarc.ucla.edu/stata/da...al-regression/

              You can also test:
              Code:
              tabstat stolen_cars, by(intervention) stats(mean var n)
              What is also unclear to me now: do you mean more cars stolen per thief in a given time or more thefts, in total?
              I’m assessing whether the daily incidence of reported car thefts increased during a 10-day city festival (April 18–28, 2024). Because this window is much shorter than the rest of the year, I focus on the rate of thefts (e.g., thefts per day) rather than total counts, comparing the festival period with non-festival days.

              Comment


              • #8
                I am not sure if this works as you intend. As far as I understand, each row in your data contains information about how many cars a thief has stolen on a given day. I read that you want to know whether thefts, in general, go up in a given period. This can either be because thief is stealing more cars per day or that simply more thieves are active. To me it makes more sense to check whether more cars, in total, get stolen in the "treatment" period.
                Code:
                . clear all
                
                . set seed 123
                
                . set obs 90
                Number of observations (_N) was 0, now 90.
                
                . gen id = _n
                
                . gen stolen = runiformint(1,4)
                
                . recode id (1/20 = 1 "Pre") (21/70 = 2 "Treat") (71/90 = 3 "Post"), gen(intervention)
                (89 differences between id and intervention)
                
                . tab intervention     //20 thieves are active in the pre and post phase but 50 in the treatment phase
                
                  RECODE of |
                         id |      Freq.     Percent        Cum.
                ------------+-----------------------------------
                        Pre |         20       22.22       22.22
                      Treat |         50       55.56       77.78
                       Post |         20       22.22      100.00
                ------------+-----------------------------------
                      Total |         90      100.00
                
                .
                .
                . poisson stolen i.intervention    //the results show that the average number of cars stolen per day per thief is identical in all three periods
                
                Iteration 0:  Log likelihood = -144.80096  
                Iteration 1:  Log likelihood = -144.80096  
                
                Poisson regression                                      Number of obs =     90
                                                                        LR chi2(2)    =   0.82
                                                                        Prob > chi2   = 0.6633
                Log likelihood = -144.80096                             Pseudo R2     = 0.0028
                
                ------------------------------------------------------------------------------
                      stolen | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
                -------------+----------------------------------------------------------------
                intervention |
                      Treat  |  -.1033424   .1620072    -0.64   0.524    -.4208706    .2141859
                       Post  |  -.1786918   .1998023    -0.89   0.371     -.570297    .2129135
                             |
                       _cons |   1.011601     .13484     7.50   0.000     .7473194    1.275882
                ------------------------------------------------------------------------------
                
                . margins intervention
                
                Adjusted predictions                                        Number of obs = 90
                Model VCE: OIM
                
                Expression: Predicted number of events, predict()
                
                ------------------------------------------------------------------------------
                             |            Delta-method
                             |     Margin   std. err.      z    P>|z|     [95% conf. interval]
                -------------+----------------------------------------------------------------
                intervention |
                        Pre  |       2.75   .3708099     7.42   0.000     2.023226    3.476774
                      Treat  |       2.48   .2227106    11.14   0.000     2.043495    2.916505
                       Post  |        2.3   .3391165     6.78   0.000     1.635344    2.964656
                ------------------------------------------------------------------------------
                
                .
                . collapse (sum) stolen, by(intervention)
                
                . list   // Here we see that much more cars got stolen in the treatment period that in the other ones, even if the length of each period is identical (by definition of this data example)
                
                     +-------------------+
                     | interv~n   stolen |
                     |-------------------|
                  1. |      Pre       55 |
                  2. |    Treat      124 |
                  3. |     Post       46 |
                     +-------------------+
                This example shows data for 3 periods. We just assume that each period is 10 days. While the average cars stolen per thief are identical (poisson shows this), the treatment period has overall more stolen cars. This is only shown then collapsing the data. Is this what you want to find out?
                Last edited by Felix Bittmann; 19 Sep 2025, 10:28.
                Best wishes

                Stata 18.0 MP | ORCID | Google Scholar

                Comment


                • #9
                  Felix Bittmann Yes, but I'm wondering if there could be a way to deal with possible autocorrelation in the time series data? Could I use an ARIMA model of some sort?

                  Comment


                  • #10
                    Luis:
                    you can replace the default standard errors with -vce(cluster id)- if you have at least 30 -id-.
                    This way, the -poisson- accomodates for potential overdispersion and autocorrelation of the epsilon.
                    Kind regards,
                    Carlo
                    (Stata 19.0)

                    Comment

                    Working...
                    X