Solved – Degrees of freedom in GLS

rregression

Here I perform a GLS regression in R and the degrees of freedom is reported as "Degrees of freedom: 60 total; 58 residual". In this regression I see five parameters that are being estimated: the slope of the regression line, the intercept of the regression line, the residual standard deviation, the constant of the variance function, and the power of the variance function. When I go to generate prediction intervals for the regression line what degrees of freedom should I use? Anticipating the answer is not 55, why aren't the degrees of freedom 55?

library(nlme)

X <- c(1,1,1,1,1,1,1,1,1,1,4,4,4,4,4,4,4,4,4,4,
  10,10,10,10,10,10,10,10,10,10,20,20,20,20,20,20,
  20,20,20,20,30,30,30,30,30,30,30,30,30,30,40,40,   
  40,40,40,40,40,40,40,40)

Y <- c(1.07,1.01,0.99,1.09,0.94,1.00,1.01,0.98,1.00,
  1.03,3.66,3.75,3.77,3.92,4.08,3.99,3.95,4.10,
  3.88,4.04,10.13,10.2,9.77,10.28,8.71,9.79,9.82,
  9.85,10.07,9.63,20.22,19.46,19.02,20.06,20.94,
  19.92,19.96,20.04,19.67,19.96,31.04,31.4,31.84,
  30.77,32.13,31.17,30.36,29.95,30.74,30.67,41.14,
  40.29,42.77,38.36,39.17,39.61,40.73,39.42,40.72,
  40.24)

m <- data.frame(X,Y)

fit <- gls(Y ~ X,weights=varConstPower(form = ~ X),data=m)
summary(fit)

Best Answer

Bottom line is that the differences between using 58 degrees of freedom and 55 degrees of freedom is negligible unless you are using likelihood-ratio tests. The standard t-test and F-based analysis of variance inference is not strongly affected by the (denominator) degrees of freedom in that range.

In linear regression the "degrees of freedom" are derived from the dimension of linear subspaces of the sample space and only involve the coefficients, not the residual standard deviation. So if you have 60 observations and fit a linear model with two coefficients the residuals must lie in the subspace orthogonal to the two-dimensional span of the model matrix. The dimension of the residual subspace is 58 hence 58 degrees of freedom.

It comes down to how you want to use the degrees of freedom. If you are counting parameters for a likelihood-ratio test there are five parameters in this model. If you are using t and F distributions for inference about the coefficients we would generally use 58 and recognize that we are making inferences conditional on the fitted variance function.

Related Question