Professional Documents
Culture Documents
DF Blog
DF Blog
/* Note that the sum of the residuals is equal to zero per the OLS first
order conditions when a constant is included in the model. I use that property
here to solve for one of the residuals based on the sum of the other
(in this case) 9. */
/*
Note that this agrees to the residual, u_hat, for the first observation.
This is why we have nine degrees of freedom. Once we
know the other nine residuals, the last one is "fixed" in the
sample based on the sum of the residuals equaling zero
when a constant is included in the regression.
Second, we examine a model with a constant term and one regressor. There are
two parameter estimates, B0 and B1, so two degrees of freedom are lost. */
reg y x1
predict double u_hat, resid
/*
First equation from the OLS first order conditions to solve for the
first two residuals:
u1 + u2 + resid_sum = 0, so solve for u1
u1 + u2 + -1.5522751 = 0
u1 + u2 = 1.5522751
u1 = 1.5522751 - u2
Second equation from the OLS first order conditions needed to solve for the
first two residuals: sum(xi*u_hati) = 0 */
list u_hat in 2
/* Note that this agrees to the second residual to the sixth decimal place
list u_hat in 1
/* Note that this agress to the first residual to the sixth decimal place
This shows how a degree of freedom is lost for each paramter estimated.
Each time a new regressor is added, the sum of each regressor times the residual
has to equal zero per OLS conditions. That means that you have one more
equation constraint added to the system per regressor. Here, there are eight
degrees of freedom because once those eight are given, the other
two may be solved for based on the two equations that restrict the system. */