Announcement

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

  • ivanpersie
    replied
    Hi guys, I have run the asreg and i keep getting the variable Oilret coefficent and Std.Err being omiited yet i would like to use them in th stage my model. What could be the reason?

    xtset permno modate
    panel variable: permno (unbalanced)
    time variable: modate, 1990m2 to 2017m12, but with gaps
    delta: 1 month

    . asreg Ret_Rf mktrf Oilret, fmb

    Fama-MacBeth (1973) Two-Step procedure Number of obs = 780240
    Num. time periods = 335
    F( 2, 334) = 1.46
    Prob > F = 0.2328
    avg. R-squared = 0.0000
    ------------------------------------------------------------------------------
    | Fama-MacBeth
    Ret_Rf | Coef. Std. Err. t P>|t| [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    mktrf | -.0077381 .006395 -1.21 0.227 -.0203178 .0048415
    Oilret | 0 (omitted)
    _cons | -.0312543 .0054391 -5.75 0.000 -.0419536 -.0205551
    ------------------------------------------------------------------------------

    Leave a comment:


  • Nick Cox
    replied
    10 years is far too few for the model you cite if you fit it the way you did. Put differently, it's not at all the same model, as it appears that it would be applied to data for several companies.

    I never try to fit a model with 35 parameters, but if I did I would want hundreds of data points at least.I am not an economist and I fear that you need advice from someone who is.

    Leave a comment:


  • Stefanie Peiffer
    replied
    Thank you Nick Cox for your quick response.
    I am using Stata for my Master Thesis for the first time, so I should probably tell more about what I want to do.

    I am replicating an academic paper, which outlines the following model:

    Actual Leverage = ß0 + ß1*FirmSize +ß2*RDExp + ß3*Advertising Exp + ß4*TangibleAssets + 20 Year Dummy Variables and 10 Industry Dummy Variables

    I want to run this Regression for each Company in my Data set, based on a past number of years (the number of years, I can Chose freely, so I could also use window 10 if that helps).
    So I thought I Need to use a rolling Regression, where asreg seemed a faster and better alternative as the new variables are stored in the original data set.

    I will then use the all ß coefficients to calculate a new variable called TargetLeverage for each Observation in my data set.

    So if I understand you correctly, I Need to Chose a window that is bigger than my number of Independent variables?

    Thank you so much for your help

    Leave a comment:


  • Nick Cox
    replied
    You are asking for an equivalent of

    Code:
    regress ActualLeverage_w FirmSize_w RDExp_w AdvertisingExp_w TangibleAssets_w
    for windows of 5 observations. So with 4 predictors you are estimating 5 parameters from 5 values.

    That can't be done usefully. It's on all fours with fitting a straight line to 2 distinct points. Here is a dopey example.

    Code:
    .  sysuse auto
    (1978 Automobile Data)
    
    . regress mpg price weight trunk length in 1/5
    
          Source |       SS           df       MS      Number of obs   =         5
    -------------+----------------------------------   F(4, 0)         =         .
           Model |        38.8         4         9.7   Prob > F        =         .
        Residual |           0         0           .   R-squared       =    1.0000
    -------------+----------------------------------   Adj R-squared   =         .
           Total |        38.8         4         9.7   Root MSE        =         0
    
    ------------------------------------------------------------------------------
             mpg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           price |   -.000583          .        .       .            .           .
          weight |  -.0072496          .        .       .            .           .
           trunk |  -.0949042          .        .       .            .           .
          length |   .1212445          .        .       .            .           .
           _cons |   24.12378          .        .       .            .           .
    ------------------------------------------------------------------------------
    You need a longer window or a simpler model. No program can solve this otherwise. (If asreg doesn't give you R-square identically 1, that is a side puzzle.)

    Alternatively, if you meant to pool your companies, don't supply the by: prefix.
    Last edited by Nick Cox; 13 May 2018, 09:17.

    Leave a comment:


  • Stefanie Peiffer
    replied
    Dear Attaullah Shah ,

    your programme seems very helpful for my intended analysis. However, I am unfortunately experiencing a problem when running the described command.

    I have an unbalanced Panel Data set with:
    xtset GlobalCompanyCode DataYearFiscal, yearly

    After preparing my dataset (deleting observations with missing values, computing the variables and so on), I ran the following command

    bys GlobalCompanyKey: asreg ActualLeverage_w FirmSize_w RDExp_w AdvertisingExp_w TangibleAssets_w , wind(DataYearFiscal 5)

    the command runs smoothly without any error message and also generates the variables mentioned in your post, such as beta coefficients and R².
    However, when I browse my data, those variables have only missing values.

    Could you please tell me, what I am doing wrong?
    Thank you so much in advance
    Kind regards
    Stefanie Peiffer

    Student at Maastricht University, the Netherlands

    Leave a comment:


  • Attaullah Shah
    replied
    Dear Katharine Adame , the updated version of asreg requires two arguments in the option window. Therefore, if you change the command to the following, it will solve the problem. Please note that I assume your time variable is named as year. If it is named differently, then replace year with actual name of the variable.
    Code:
    bys permno: asreg retlessrf mkt_prem, wind(year 10) se fit

    Leave a comment:


  • Nick Cox
    replied
    I can't try to debug asreg for you, or alternatively explain what's wrong with your code, not least because its Mata code is hidden and there is no data example here.

    While Attaullah Shah is explaining what went wrong, an alternative is rangestat from SSC by Robert Picard and friends. Here is some token code: The regression here is presumably just silly.

    Code:
    webuse grunfeld , clear 
    rangestat (reg) mvalue kstock, interval(year -9 0) by(company) 
    gen fitted = b_cons + b_kstock * kstock
    I don't understand the exact definition of windows in asreg from a quick glance at its help. If window(10) means (e.g.) the previous 10 values, not including the present observation, your rangestat equivalent would be interval(year -10 -1)

    Leave a comment:


  • Katharine Adame
    replied
    Hi Attaullah,

    Thank you so much for this very helpful package. I was hoping you might be able to help me understand why I am receiving the following error:
    asregw(): 3301 subscript invalid
    <istmt>: - function returned error

    I am running the following regression:
    bys permno: asreg retlessrf mkt_prem, wind(10) se fit

    I ran tsset on the data beforehand (unbalanced panel with gaps). Do you have any ideas? I'm really hoping to get this command to work as it seems much preferable to the rolling command.

    Thank you!

    Leave a comment:


  • Attaullah Shah
    replied
    As an update to the previous post, I am happy to share that an updated version of asreg is now available on SSC. New users can type
    Code:
    ssc install asreg
    and existing users can update the ado files by
    Code:
    adoupdate asreg, update
    The updated version fixes a minor bug in the earlier version that was leaving behind a temporary variable.

    Leave a comment:

Working...
X