Announcement

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

  • How to add Fixed Time effect to a multiple regression

    Hi everyone,
    i'm totally new to the use of Stata, so i'm still trying to get how it works. (I will probably ask something very obvious, but at the moment anything that is Stata-related is a mystery to me)
    I am doing a research on a a sample of 800 M&As realized from 2000 until 2013.
    I have a dependent variable Y and 1 Independent Variable X1 plus 3 other control variables (respectively X2,X3,X4).
    I have no problems in managing a simple multiple regression (Thank God you will say).
    So no problems....until now!
    I want to add a Fixed time effect according to the different years in which the various M&As have taken place.
    But i really do not know where to start:
    is there anybody so gentle to tell me what to do?
    You will have my endless admiration and gratitude for all of my life (i'm young, so my life should be long, hopefully) and it also mean a lot of positive karma, that's not bad at all.
    So thank you.

    I know i should also do something with the command xtset or xtreg...(i don't know how to set the time variables)

    However,
    Thank you!!

  • #2
    So, let's say that you have a variable which contains the date of the transaction. Let's call that variable date. (Note: it must be a numeric Stata internal format date variable. If what you have is something other than that, then you will need to convert it.)

    Then to add time fixed effects to your model you just add i.date to the list of regression variables. For example, your command might look like this:
    Code:
    xtreg y x1 x2 x3 x4 i.date, fe // OR re OR pa AS THE CASE MAY BE
    As for as doing something with xtset, your data must also contain some variable that identifies the panel identifier in your data. Let's call that variable panel. Then you can do
    Code:
    xtset panel date
    provided that panel and date together uniquely identify observations in the data. But if there can be more than one observation for the same panel on the same date, then you do just
    Code:
    xtset panel
    Do read the -xt- chapter of the [XT] volume of the PDF documentation that came with your Stata installation. It describes the overall approach that Stata uses for panel data analysis and introduces you to the basic commands. This investment of your time will be amply repaid with ability to more efficiently figure out solutions to your problems.

    Along the same lines, I recommend you also read the Getting Started [GS] and User's Guide [U] volumes of the PDF documentation. These will give you a bird's eye view of how Stata approaches data management and analysis generally and will introduce you to the basic commands that are used over and over in most problems. You will not retain all the details, but you will be exposed to the fundamentals and when encountering problems to solve, you will have a reasonable idea of which commands are likely to be part of the solution. You can then turn to the help files and manual sections on those commands to refresh your memory of syntax and details of their operation.

    Comment


    • #3
      ok thank you, i think that the problems i face are all related to set the panel.
      I have different observation for the same panel on the same date, but when i try doing "xtset panel" the system just says "panel variable not found".
      Could you help me in setting the panel with my variables?

      Comment


      • #4
        Valeria:
        you have to -xtset- your data with a -panelid- (mandatory) and a -timevar- (optional, if you do not plan to use time-series commands, such as lags and leads).
        That said, without an excerpt/example of your dataset posted via -dataex- (type -search dataex- from within Stata to install it), the replies you get will be unavoidably theoretical.
        Kind regards,
        Carlo
        (StataNow 18.5)

        Comment

        Working...
        X