Hi All,
I have a dataset that resembles the following:
In the above, data on GDP and employment is stored by year. There is no reason to believe that the relationship between GDP and employment is stable over the course of the various years in my dataset. As such, I wish to estimate a separate regression of GDP on employment (regress GDP employment) by year, and generate predicted values for GDP based on the regression to be stored in the same column, call it Predicted. As such, the final dataset should have an extra column wherein each cell corresponds to the fitted value of GDP based on the value of employment obtained from the beta specific to the regression in that year. Are there any ways to do this besides resorting to mata?
Many thanks.
I have a dataset that resembles the following:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(year GDP employment) 1990 12 123 1990 321 23 1990 123 213 1990 123 32 1990 123 213 1991 123 123 1991 3 2 1991 21 23 1991 213 321 1991 21 123 end
In the above, data on GDP and employment is stored by year. There is no reason to believe that the relationship between GDP and employment is stable over the course of the various years in my dataset. As such, I wish to estimate a separate regression of GDP on employment (regress GDP employment) by year, and generate predicted values for GDP based on the regression to be stored in the same column, call it Predicted. As such, the final dataset should have an extra column wherein each cell corresponds to the fitted value of GDP based on the value of employment obtained from the beta specific to the regression in that year. Are there any ways to do this besides resorting to mata?
Many thanks.
Comment