Announcement

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

  • xtreg re and insufficient observation error

    Click image for larger version

Name:	1.JPG
Views:	1
Size:	61.7 KB
ID:	1666032
    Hi!!

    I have panel data; independent variable-market cap, MTB(market to book), ROA(return on asset), tangibility, growth, covid-19(dummy variable)/ dependent variable-leverage ratio of corporate/ TIme: fyear from 2016 to 2021 and ID: compid(companies ID)

    I am trying to run the command "xtreg dependent variable independent variable if fyear == 2016, re" to get regression results for 2016.
    However, I get "insufficient observation''
    I would like to get a table that contains the coefficient of each independent variables with p-value in each year like the above following pic including the dummy variable (covid-19).

    If I am doing it wrong, please let me know!

    All your help and advice are appreciated.


  • #2
    Hi JaeHong, it would help in this case, and always, if you would write out what you give to Stata when it returns "insufficient observation". Without that it's often hard to say what may be going wrong. For example, are you using xtset correctly? Do you have enough observations per group to get results (evidently not so far)?

    Comment


    • #3
      JaeHong:
      as an aside to Jackson's helpful advice, it is easy to replicate your problem:
      Code:
      . use "https://www.stata-press.com/data/r17/nlswork.dta"
      (National Longitudinal Survey of Young Women, 14-24 years old in 1968)
      
      . xtreg ln_wage c.age##c.age if year==70, re
      insufficient observations
      r(2001);
      The reason of that rests on the quasi-demeaning equation of the -re- estimator:
      If we take a look at the left-hand side of if we see that:
      Code:
      (yit-thetaybari)
      If we consider 1 year only, the results of what between brackets is 0:
      Code:
      . egen wanted=mean(ln_wage) if idcode==1 & year==70
      
      
      . g check= ln_wage- wanted if year==70 & idcode==1
      
      
      . sum check
      
          Variable |        Obs        Mean    Std. dev.       Min        Max
      -------------+---------------------------------------------------------
             check |          1           0           .          0          0
      
      .
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        @Jackson, I do have more than 1500 observations for each year from 2016 to 2021 including compid and fyear.

        Comment


        • #5
          Code:
          //gvkey destring//
          egen compid =group( gvkey)

          destring gvkey, replace force

          //Leverage ratio//
          gen debt = dltt + dlc
          gen leverage = debt/at


          //generate Size//
          gen marketcap = prccd*cshoc
          gen size = at

          //generate MTB Ratio//
          gen bookvalue = at - lt
          gen MTB = (marketcap/1000000)/bookvalue

          //generate Growth//
          sort compid fyear
          gen prev = _n -1
          gen at_growth = (at - at[prev])/at[prev] if gvkey == gvkey[prev]


          //generate Profitability//
          gen ni = nicon
          gen roa = 100*(ni/at)

          //generate Tangbility//
          gen tang = (at - intan - lt)/at

          //generate the Covid//
          gen covid = 0
          replace covid = 1 if fyear>2019

          //define//
          global compid compid
          global fyear fyear
          global ylist leverage
          global xlist marketcap MTB at_growth roa tang covid

          describe $compid $fyear $ylist $xlist
          summarize $compid $fyear $ylist $xlist

          //Summarize IVs for each year//
          summarize leverage MTB size roa tang if fyear == 2016

          //Set data as panel data//
          drop if at_growth == .
          drop if fyear==fyear[_n-1]
          sort $compid $fyear
          xtset $compid $fyear
          xtdescribe

          and than,

          xtreg leverage MTB size at_growth roa tang covid if fyear == 2016, re

          Comment

          Working...
          X