Announcement

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

  • -reghdfe-: how to use it correctly?

    Hi Statalist,

    I need your help as I am stuck since a while. I would like to use -reghdfe- for my context, but I never used.
    I'm currently working on a database of new vehicles registered in Spain. Here's a quick look at my current dataset. My dataset contains 1,340,682 observations:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str23 brand str60 model str4 fuel long(engine_cap muni_code) double power_kw int co2 float fiscal_power double price long ev_type_encoded
    "FORD" "FOCUS" "0" 999 29051 92 125 7.82 19088.88888888889 0
    "FORD" "FOCUS" "0" 999 30016 92 108 7.82 19088.88888888889 0
    "FORD" "FOCUS" "0" 999 15036 92 108 7.82 19088.88888888889 0
    "FORD" "FOCUS" "0" 999  7040 92 108 7.82 19088.88888888889 0
    "FORD" "FOCUS" "0" 999  8187 92 107 7.82 19088.88888888889 0
    "FORD" "FOCUS" "0" 999 14060 92 107 7.82 19088.88888888889 0
    end
    label values ev_type_encoded ev_type_encoded
    In this database, we have several vehicle characteristics, such as fuel, cubic capacity of the engine, municipal code, whether the vehicle is a BEV, HEV, PHEV, conventional combustion, etc. and the price. The price has been merged with another database, according to some key characteristics (fuel, engine capacity, eletric vehicle or not, etc.).

    I tried to regress this, but the values are small and wanted to know if this makes sense. Otherwise, I don't know how to get started with this. Could someone help me and tell me if I'm doing something wrong, please?

    Code:
    gen log_price = ln(price)
    reghdfe log_price engine_cap power_kw i.ev_type_encoded, absorb(model brand)
    and the respective result:

    Code:
    note: 1bn.ev_type_encoded is probably collinear with the fixed effects (all partialled-out values are close to zero; tol = 1.0e-09)
    
    HDFE Linear regression                            Number of obs   =  1,340,671
    Absorbing 2 HDFE groups                           F(   3,1340315) =  242457.52
                                                      Prob > F        =     0.0000
                                                      R-squared       =     0.9437
                                                      Adj R-squared   =     0.9436
                                                      Within R-sq.    =     0.3518
                                                      Root MSE        =     0.0867
    
    ---------------------------------------------------------------------------------
          log_price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    ----------------+----------------------------------------------------------------
         engine_cap |   .0002434   4.48e-07   542.91   0.000     .0002425    .0002443
           power_kw |   .0037554   7.19e-06   522.19   0.000     .0037413    .0037695
                    |
    ev_type_encoded |
               BEV  |          0  (omitted)
               HEV  |    .023146   .0016264    14.23   0.000     .0199582    .0263337
                    |
              _cons |    9.20634   .0008689  1.1e+04   0.000     9.204637    9.208043
    ---------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    -----------------------------------------------------+
     Absorbed FE | Categories  - Redundant  = Num. Coefs |
    -------------+---------------------------------------|
           model |       353           0         353     |
           brand |        34          34           0     |
    -----------------------------------------------------+
    • Perhaps one more question: Is -reghdfe- the same as -xtreg-?
    • Should I include the municipality code in the regression as a fixed effect? Basically I want to see the effect of a new policy that came into vigour in 2018, and requires anyone wishing to enter Madrid city centre by car to have either an electric car (BEV, FCEV) or a hybrid car (HEV, PHEV). It is the only place in Spain to have introduced such a measure.


    Thank you VERY much in advance for your help. I'm really stuck.
    Lovely day.

    Michael
    Last edited by Michael Duarte Goncalves; 10 May 2024, 05:30.

  • #2
    .Once you know the make and model, adding information about ev_type, fuel , kilowatts or engine capacity doeesn't add any information to the regression, unless there is variation in those characteristics within the make and model. That is what the "Note:" is saying. Stata drops the redundant variables. It would help if you said what you hoped to learn from the regression. I would have guessed you wanted to know if the new law increased the demand for electric or hybrid cars. That might be expresssed in price, but more likely in quantity, I would imagine.

    Comment


    • #3
      Hi Daniel Feenberg,

      Thanks for your feedback and help! It is clear now about the note.
      Basically, I would like to know from the regression whether electric vehicles are more expensive on average than conventional ones, or even hybrids, controlling for make and model.

      For the moment, I'd like to see whether, for example, for the same model-brand, hybrid-electric versions are generally more expensive than conventional ones.

      The final objective being to observe if I observe since May 2018 an increase in purchases in electric/hybrid vehicles, and if the latter are more expensive than other types of vehicles (classic ones: diesel, gasoline), controlling on various factors that may be important, such as the brand-model, the engine capacity.

      The other aim is to somewhat find the price elasticity of demand, according to some key characteristics.

      But I'm a bit stuck.

      Thank you again for your help and time!
      Lovely day.
      Last edited by Michael Duarte Goncalves; 10 May 2024, 09:36.

      Comment

      Working...
      X