How to use Stata drawing to test autocorrelation? Some friends may not know how to do it, so now the editor will explain to you the method of Stata drawing to test autocorrelation. Friends in need can come and take a look. I hope it can help you.
First, open the data set prepared by the editor, and then make preliminary observations on the data set.
Through observation, we can know that t is a time variable. In the first step, we should set the variable t to represent time.
tsset t
We perform regression on existing data
reg y x1 x2 x3
Interpretation: Regress variables. In actual analysis, you only need to bring in the explained variables and explanatory variables you want to analyze.
(The picture is an example I gave)
If the data in the actual application is a time series, then there is a high possibility of autocorrelation, so we can observe whether there is autocorrelation by drawing a scatter plot of the residuals and the lag of the residuals.
predict e1,r
twoway scatter e1 L.e1 || lfit e1 L.e1
Explanation: 1. Option r is residual, which represents the residual
2. Twoway scatter means drawing a scatter plot, || means drawing them side by side on one picture, L. means lag, and lfit means linear fit. For more information, please refer to my other experiences.
Through observation, we can see that there is a correlation between the time trend and the residual scatter plot, and we can initially believe that there is a first-order positive autocorrelation.
We can further draw a scatter plot of second-order lag
twoway scatter e1 L2.e1 || lfit e1 L2.e1
Observing that the straight line is almost horizontal, we initially judge that there is no second-order lag autocorrelation.
Further, we can use stata to draw the autocorrelation plot of the residuals
ac 1
Explanation: 1.ac represents autocorrelation
By observing the autocorrelation plot, we can see that except for the first-order autocorrelation, which is very close to the 95% confidence interval, the others can better reject the null hypothesis of the existence of autocorrelation. The gray area represents the confidence interval of autocorrelation.
The above is the method shared by the editor to test autocorrelation in Stata drawing. Friends who don’t know how to do it should hurry up and learn it.