Announcement

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

  • Time-series regression

    Hello everyone,

    I'm new to the topic Stata, and have a rather simple question, unfortunately I could not quite find the right answer in previous posts.

    I have to run a time-series regression for my dataset to evaluate fund performance to compare Jensens Alphas of my portfolios (with 1 factor - CAPM, or 3 factors - Fama French).
    My dataset consists of several portfolios, I have monthly returns for each portfolio, and the returns of the factors in the period 07/2003 to 12/2009.

    This is an example of my dataset. I just copied the first 17 returns of my first portfolio (Portfolio1) and the market factor (MktRF).
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    * dataex Portfolio1 MktRF date
    clear
    input double(Portfolio1 MktRF) float date
      2.991708664849368                2.35 522
     4.0425122517792085                2.34 523
    -1.3992360748587176               -1.24 524
      6.533121616215525                6.08 525
      1.933250246006822                1.35 526
     3.7992719659766725                4.29 527
     2.0829299988670735                2.15 528
     1.6863102088087467                 1.4 529
    -.13288865907503128               -1.32 530
    -3.5667886766823087               -1.83 531
      1.375006740249057                1.17 532
     2.2870527261727327                1.86 533
     -3.939782182699152               -4.06 534
    -.19048266712117615                 .08 535
     3.4802018436805704                 1.6 536
     2.4008613522892945                1.43 537
      6.010366755240809                4.54 538
    end
    format %tmNN/CCYY date
    I already declared my dataset to be a time-series dataset.
    Code:
    tsset date, monthly
    What is the code in Stata when I want to regress the dependent variable Portfolio1 to the independent variable MktRF in a time-series?
    Do I just include the date as an independent variable?
    Code:
    reg Portfolio1 MktRF date
    Or is it a little more complicated?
    Is reghdfe an option?

    Thank you very much for your help!
    Best,
    Sandra
    Last edited by Sandra Huber; 10 Feb 2019, 07:39.

  • #2
    If you have more than one portfolio, you'll want to treat the data as panel (xtset) not solely time series (tsset). Once you have time set your data, you can easily lag variables with L.
    I would expect the rhs variables to be the factors and only the factors - I don't see any reason to have date as a regressor.

    So,
    reg Protfolio1 MktRF

    is the basic equation. By the way, some folks stay with mainly lower case for variable names in Stata so they don't have to remember what is upper and what is lower.

    xtreg and regdhfe are both for panel estimators - unless you're seeing up the model as a panel estimation, I don't see how the come into the issue.

    Comment


    • #3
      Thank you for your answer.

      When I use panel data, what is my panel variable and the time value? I get this error when I use my time variable: time variable must contain only integer values
      r(451);
      Why do I need lag variables?

      Here is another example of my dataset with 3 portfolios, and 1 factor (mktrf) and the 2 factors (smb&hml):

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      * dataex pf1 pf2 pf3 mktrf smb hml date
      clear
      input double(pf1 pf2 pf3 mktrf smb hml) float date
        2.9932342345453543   1.4835422492463155   2.301902750776657                2.35                5.25               -1.15 522
       4.0425122517792085    1.224768676781519   2.706538567847075                2.34                 2.6                2.03 523
      -1.334534534534345   1.3770334581649042  -.5270026480873011               -1.24                 .79                 .02 524
        8.533121616215525    6.100094428357858   5.766198386546075                6.08                2.68                1.76 525
        1.967867853456575   3.7406958788857714   1.656756753222223                1.35                2.01                1.86 526
       3.7992719659766725   8.2072504082634845   5.169693132327267                4.29               -3.01                2.42 527
       6.082954656567656   1.5384471277494052  2.02978976744293134                2.15                 2.8                1.97 528
       1.6863102088087467    1.240287419737047  1.8904470115598544                 1.4               -1.43                 .49 529
      -.63288865907503128   -.9819926597742214   -.984712073903829               -1.32  1.7500000000000002                 .21 530
      -4.5667886766823087  -1.8457942872464528  -5.252788178720831               -1.83               -2.06               -2.62 531
        1.375006740249057   -.6869634475812807   .8228199199416934                1.17                -.21                -.39 532
       2.2870527261727327   9.6605994945503506  4.1455467664634247                1.86                2.26                1.38 533
       9.952974442353053   11.669495010046854   9.982871239769548                9.54                3.92               -3.12 534
      end
      format %tmNN/CCYY date

      I would very much appreciate further help.
      Thank you,
      Sandra

      Comment

      Working...
      X