Announcement

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

  • Random effects regression with weights? Error weights are not allowed

    The dependent variable measures the number of commuters for each municipality for 19 years. Commuting distance is one of the explanatory variables which is fixed across time, using fixed effects eliminates variable which is the motivation for using random effects. I believe that variance of commuting increases with population size so the square root of population average across the years is the weight. In other words the code is:

    Code:
    bysort numeric_id: egen pop_avg = mean(Population_size)
    
    gen sqrt_pop_avg = sqrt(pop_avg)
    
    xtreg Commuting Commuting_distanse Real_income Migration unemployment [pweight=sqrt_pop_avg], re
    The error is weights are not allowed.

  • #2
    You have correctly observed that -xtreg- does not support weights.

    Since you are going to do a random-effects regression, used -mixed- instead. It does support weights.

    But better still, what about using random effects Poisson regression and have pop_avg as the exposure variable? See -help mepoisson- for details.

    Comment


    • #3
      Use mixed with the -pw()- option instead. However, read about sampling weights in multilevel models first.

      Code:
      help mixed
      Note: Crossed with #2.

      Comment


      • #4
        Originally posted by Clyde Schechter View Post
        You have correctly observed that -xtreg- does not support weights.

        Since you are going to do a random-effects regression, used -mixed- instead. It does support weights.

        But better still, what about using random effects Poisson regression and have pop_avg as the exposure variable? See -help mepoisson- for details.
        Doesn't it also work if you multiply all observations in the dataset with 1/sqrt_pop_avg which is the weight. I tested this method and ran a fixed effect regression against:
        Code:
         
         xtreg Commuting Commuting_distanse Real_income Migration unemployment [pweight=sqrt_pop_avg], fe
        The results should've been the same but the coefficients, t-statistic etc. are different. If I could multiply all observations with 1/sqrt_pop_avg and then run
        Code:
        xtreg y x1 x2, re
        Are they equivalent?

        Comment


        • #5
          No. I think you are thinking of how -aweights- work with a simple one-level regression. But once you introduce the random effects, it's a different story.

          By the way, I'm not certain of this, but I think, based on what you said in #1 about pop_avg, that taking its square root to use as a weight is not the way to go. I think you would use pop_avg itself. The variance of an observation's outcome calculated as an average among n units is inversely proportional to n. And one generally then wants to weight the observations in inverse proportion to their outcome's variance, so proportional to n, not sqrt(n).

          Comment


          • #6
            I think the first order issue is how population is incorporated into into the mean function. It seems odd not to normalize the number of commuters by population, or control for population in the mean equation. But maybe you have a good reason. I would think the model with log(Commuting) and log(Population) is a natural start. Using population weights is only an efficiency issue. So, you can use xtreg, re vce(cluster id). I doubt Commuting is every close to zero, so Poisson regression might not be worth the bother. I'd use the pooled version because the RE Poisson estimator imposes a lot of extra assumptions.

            Comment

            Working...
            X