Announcement

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

  • Cross sectional data with year fixed effects

    Hello, my model looks like this
    SLL = a + B*GR + i.country + i.year + i.ID + Ei
    the dependent variable is a dummy variable that takes 1 if a bank issued an SLL, otherwise 0, the problem is I'm dealing with a period of 3 years from 2020 to 2023 and i want to include Year fixed effects, how i can add it to my data table and interpret it in stata

    Thank you
    ID SLL 2020 SLL 2021 SLL 2022
    1 0 1 1
    2 1 1 1
    3 0 0 1
    4 1 0 1

  • #2
    Jattioui:
    welcome to this forum.
    I would -reshape- in -long- format my data, so to have an unique -SLL_new_ variable.
    Then, If you have repeated cross-sectional data, you may want to consider -logit- -i.SLL_new-.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thank you so much sir for your attention,

      so i have to start the regression one SLL variable for one year (2020), then i repeat the regression for the other years ? could i get one table where i get consistent results over the years ? or it going to be unique results for each yer ?

      thanks

      Comment


      • #4
        Jattioui:
        I meant something along the following lines:
        Code:
        . set obs 4
        Number of observations (_N) was 0, now 4.
        
        . g SLL_2020=0
        
        . g SLL_2021=0
        
        . g SLL_2022=0
        
        . replace SLL_2020 = 2020 in 2
        
        
        . replace SLL_2020 = 2020 in 4
        
        
        . replace SLL_2021 = 2021 in 1
        
        
        . replace SLL_2021 = 2021 in 2
        
        
        . replace SLL_2022=2022 if SLL_2022==0
        
        .  stack SLL_* , into( SLL_new) clear
        
        . drop if SLL_new==0
        
        . bysort SLL_new: g id=_n
        
        . drop _stack
        
        . list
        
             +--------------+
             | SLL_new   id |
             |--------------|
          1. |    2020    1 |
          2. |    2020    2 |
          3. |    2021    1 |
          4. |    2021    2 |
          5. |    2022    1 |
             |--------------|
          6. |    2022    2 |
          7. |    2022    3 |
          8. |    2022    4 |
             +--------------+
        
        . g y=runiform()*1000
        
        . regress y i.SLL_new
        
              Source |       SS           df       MS      Number of obs   =         8
        -------------+----------------------------------   F(2, 5)         =      1.00
               Model |  137548.527         2  68774.2633   Prob > F        =    0.4327
            Residual |  345509.669         5  69101.9339   R-squared       =    0.2847
        -------------+----------------------------------   Adj R-squared   =   -0.0014
               Total |  483058.196         7  69008.3137   Root MSE        =    262.87
        
        ------------------------------------------------------------------------------
                   y | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
        -------------+----------------------------------------------------------------
             SLL_new |
               2021  |  -225.2771   262.8725    -0.86   0.431    -901.0123    450.4581
               2022  |    95.6866   227.6542     0.42   0.692    -489.5172    680.8904
                     |
               _cons |   307.8787   185.8789     1.66   0.159    -169.9382    785.6956
        ------------------------------------------------------------------------------
        
        .
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Thanks you so much sir,

          i think i solved it using excel formulas, just one question , i have a country variable containing ISO 2 letters code, should i uncode it to numerical variable ?

          best regards


          Comment


          • #6
            Jattioui:
            yes, you should, as in the following toy-example:
            Code:
             use "C:\Program Files\Stata18\ado\base\a\auto.dta"
            (1978 automobile data)
            
            . encode make, gen(num_make)
            
            . list make num_make in 1/10
            
                 +-------------------------------+
                 | make                 num_make |
                 |-------------------------------|
              1. | AMC Concord       AMC Concord |
              2. | AMC Pacer           AMC Pacer |
              3. | AMC Spirit         AMC Spirit |
              4. | Buick Century   Buick Century |
              5. | Buick Electra   Buick Electra |
                 |-------------------------------|
              6. | Buick LeSabre   Buick LeSabre |
              7. | Buick Opel         Buick Opel |
              8. | Buick Regal       Buick Regal |
              9. | Buick Riviera   Buick Riviera |
             10. | Buick Skylark   Buick Skylark |
                 +-------------------------------+
            
            .
            Caveat emptor: take a look at the -encode- entry, Stata .pdf manual and focus your attention on the reported instances when -encode- behaves unexpectedly.
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment

            Working...
            X