Announcement

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

  • xtreg fixed effect and estimate using wls

    Dear Statalist,

    Following is the code for firm and year fixed effect using xtreg

    Code:
     xtset companyid year_
    xtreg Y X1 X2 X3 i.year, fe

    May I know how can I change this model to etimate it using wls (weighted Least Squares) ?
    I know I can use ..., be wls instead of fe. But,what I need to know is how can I keep ....,fe and still use wls in the same xtreg
    Last edited by krishantha Ainsworth; 01 Dec 2021, 21:35.

  • #2
    Hey, your code would look like

    Code:
    xtreg Y X1 X2 X3 i.year [pweight=var], fe
    Last edited by Jared Greathouse; 01 Dec 2021, 21:37.

    Comment


    • #3
      Hi Jared, Thank you for your reply. But it gives me an error

      var not found

      Comment


      • #4
        -xtreg, be- fits a between-effects model at firm level with the length of periods for each firm as a weight if -wls- is specified. Fixed-effects model is estimated on firm-year level, and you don't need such wls as in -xtreg, be-.

        But I guess you are attempting to deal with the issue of heteroskedasticity via WLS. In practice, we would directly assume a heterosk-robust standard errors, as below, unless you can correctly specify the form of heterosk.

        Code:
        xtreg Y X1 X2 X3 i.year, fe vce(cluster companyid)
        The advice in #2 requires a generated weight for WLS. You may refer to #6 of this thread -- But it's usually unnecessary to do so.

        Comment


        • #5
          Hi Fei,
          Thanks for your reply. But I don't think I can get what I want out of your code.
          If I run
          Code:
           xtreg Y X1 X2 X3 i.year,be wls
          I get a massive boost in R-squared which is not as same as
          Code:
           xtreg Y X1 X2 X3 i.year, fe vce(cluster companyid)
          That's why
          I'm looking for
          Code:
          xtset companyid year 
          xtreg Y X1 X2 X3 i.year, fe
          with wls

          Comment


          • #6
            Krishantha:
            Fei gave good advice.
            You actually used two different estimators; hence, no wonder that yiour results differ.
            Please also note that:
            1) we look at different Rsq consistent with the -xtreg- specification (for instance, within Rsq is the most relevant R indicator for -fe- specification);
            2) under -xtreg-, both -robust- and -vce(cluster clusterid)- option deal with both heteroskedsticity and autocorrelation; this may partially explain the difference in your results vs -wls- only;
            3) last but (by no means) not least, sharing what you typed and what Stata gave you back (as per FAQ) is the best way to increase your chances to get more helpful replies. Thanks..
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Fei Wang I'm confused. Maybe I'm not thinking about it properly, but isn't WLS simply OLS weighted by a given variable? I know I'm over simplifying here, but I thought dealing with heteroskedasticity is a distinct idea from the weights you give your estimates...... unless..... we use weighting to deal with heteroskedasticity?

              Comment


              • #8
                Jared Greathouse Yes, you are right. WLS, without any context, simply means a least squares estimation with weights. But in some standard (introductory) textbooks, WLS is specifically used to handle heteroskedasticity. In practice, we would always start with robust standard errors, but theories show that using WLS to deal with heterosk is more efficient when one can correctly specify the form of heterosk. The OP didn't state clearly, but I guess the question is related to using WLS to handle heterosk.

                Comment

                Working...
                X