Announcement

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

  • New regression for every new observation in a time serie with the same time serie as the observation before.

    Hello Stata guys,

    I have some issue with data for my master thesis. I hope that you can help.

    My data is structured in the following way. I have a period from 31-01-2000 to 31-12-2013 where I have 400 unique observations. Not all of the obersvations have the same periods i.e. some are present trought the whole time serie, some are only existing for 3 years.

    However, I have to regress a four factor model on each observation i.e. simply running an OLS regression for each observation trought the time serie that are present for this observation.

    Can anybody help me with a code or other commands that makes this relative easy in STATA?

    The commands/code should simply run the same regression on all uniquie observation. The data lenght of the data used in each regression is dependent on the lengt of the time serie for that particular obseravtions.

    It is fine if I get 400 regression overview in STATA.

    The bad way to solve this issue would be to run these 400 regression manually

    Best,
    René

  • #2
    By observation, do you mean you have a unbalanced panel dataset, where there are 400 different cross sectional units (individuals, firms ..), each with its own time series?
    If this is the case, you could use statsby (see help statsby) to get a dataset collecting the coefficients over the regressions, or a combination of levelsof and foreach to run all the regressions and store them. Let say your regression is reg y x and you want to run it for different values of obs wich identifies "observations"

    Code:
    levelsof obs, local(id)
    foreach x in `id' {
    reg y x if  id==`x'
    est store reg`x'
    }
    PD: Please provide tags for your question, so it can be searched by future users. Suggested tags are: Data Management, Regression.
    Last edited by Jorge Eduardo Perez Perez; 09 Apr 2014, 15:43.
    Jorge Eduardo Pérez Pérez
    www.jorgeperezperez.com

    Comment

    Working...
    X