Hello there! First of all, a very happy and fulfilling 2017 for all of us. I would make an econometric-new-year joke but I'm sparing you that experience.
Here's the thing - I am trying to calculate the within estimator by running the pooled OLS on time-demeaned data and comparing that to the within estimator calculated by Stata. They should be the same, but aren’t, so I’m doing something wrong. My Stata code goes below and should run smoothly. If anyone could help me figure out what’s cooking I’d be super grateful. Thanks a lot!
version 13 set more off clear * The dataset is composed of random variables that I created for * this purpose. So here i’m setting the number of observations and * a seed to make results replicable set obs 1000 set seed 1953 * generating an “individual-level” unique ID gen id = _n * generating dependent and independent variables for three “years” * by assigning random values to all observations foreach x in x97 x98 x99 y97 y98 y99 { gen `x' = uniform() } * reshaping this data into a panel dataset reshape long x y, i(id) j(year) * letting Stata know that this is a panel dataset xtset year * calculating the time-averages for each unique individual egen xmean = mean(x), by(id) egen ymean = mean(y), by(id) * calculating the time-demeaned x and y gen x_umlaut = x - xmean gen y_umlaut = y - ymean * calculating pooled OLS on the time-demeaned variables (1) reg y_umlaut x_umlaut, robust * calculating the Stata within estimator (2) xtreg y x, fe
The coefficients for (1) and (2) are not even close. Beta (1) is -.0146094 while Beta (2) is -.0031224. What am I doing wrong here?
Submitted December 31, 2016 at 04:23PM by plurabilities http://ift.tt/2ipnYUa
No comments:
Post a Comment