Here, due to nature of my data I need to collapse my repeated cross section data to panel data ( the following sample shows my collapsed data at county and year level ). I need to run the first stage of IV regression on this collapsed panel data on year and County level. Then I need to store the first stage , to run the second stage on my regular repeated cross section data.
Since I am manually estimating first stage with my collapsed data , I need to store the estimates. Then after estimating the first stage estimates , I need to load my second set of data ( which is repeated cross section data out of which I got my collapsed data ). But, after loading second set of data , if I run the following command this error message shows up. I know if I can make a small change in the following command, then I'll be able to transition my first stage estimates to loading my second set of data and estimating second stage. I just don't know how I can do that.
Can anyone help how after finishing first stage with my collapsed data , I can load the second data to accomplish second stage given the following set of command ? If you need data , then I've posted my sample data in this post. ( https://www.statalist.org/forums/for...s-section-data )
Since I am manually estimating first stage with my collapsed data , I need to store the estimates. Then after estimating the first stage estimates , I need to load my second set of data ( which is repeated cross section data out of which I got my collapsed data ). But, after loading second set of data , if I run the following command this error message shows up. I know if I can make a small change in the following command, then I'll be able to transition my first stage estimates to loading my second set of data and estimating second stage. I just don't know how I can do that.
Can anyone help how after finishing first stage with my collapsed data , I can load the second data to accomplish second stage given the following set of command ? If you need data , then I've posted my sample data in this post. ( https://www.statalist.org/forums/for...s-section-data )
Code:
variable xfit not found r(111);
Code:
***manually estimate a 2SLS regression log using my_results100, replace qui: reg x i.IV_one#i.IV_two male ismarried wasmarried age age2 black asian hispanic lths hsdegree somecollege i.year i.county , cluster(county) log close cap drop xfit predict xfit, xb * Second stage reg dep_var xfit male ismarried wasmarried age age2 black asian hispanic lths hsdegree somecollege i.year i.county , cluster(county) local st2se = _se[xfit] * Degree of freedom local dof = (`e(N)'-`e(df_m)') di `dof' tempvar esave qui estsave, gen(`esave') qui estsave, from(`esave') tempname V matrix `V' = e(V) matrix b=e(b) * computing residuals by hand cap drop eps2_2 y_fit predict y_fit gen double eps2_2 = (y-y_fit)^2 qui: sum eps2_2 local csse2 = `r(sum)' * get root mean squared error local st2rmse = sqrt(`csse2'/(`dof')) di `st2rmse' local st2r = (`csse2'/(`dof'))