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:
The error is weights are not allowed.
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
Comment