Problems with the error Feb 22 2019

Today

Problems with the errors

Generalized Least Squares

Y=Xβ+ϵ

Let S be the matrix square root of Σ, i.e. Σ=SST.

Define a new regression equation by multiplying both sides by S1: S1Y=S1Xβ+S1ϵY=Xβ+ϵ

Your Turn

Show Var(ϵ)=Var(S1ϵ)=σ2I.

Show the least squares estimates for the new regression equation reduce to: β^=(XTΣ1X)1XTΣ1Y

Common cases of GLS

In R

?lm # use weights argument
library(nlme)
?gls # has weights and/or correlation argument

Oat yields

Data from an experiment to compare 8 varieties of oats. The growing area was heterogeneous and so was grouped into 5 blocks. Each variety was sown once within each block and the yield in grams per 16ft row was recorded.

yieldi=β0+β1varietyi+ϵii=1,,40 Var(ϵi)=σ2,Cor(ϵi,ϵj)={ρ,blocki=if blockj0,otherwise

library(nlme) 
fit_gls <- gls(yield ~ variety, data = oatvar, 
  correlation = corCompSymm(form = ~ 1 | block))

Oat yields in R

intervals(fit_gls)
## Approximate 95% confidence intervals
## 
##  Coefficients:
##                  lower  est.       upper
## (Intercept) 291.542999 334.4 377.2570009
## variety2     -4.903898  42.2  89.3038984
## variety3    -18.903898  28.2  75.3038984
## variety4    -94.703898 -47.6  -0.4961016
## variety5     57.896102 105.0 152.1038984
## variety6    -50.903898  -3.8  43.3038984
## variety7    -63.103898 -16.0  31.1038984
## variety8      2.696102  49.8  96.9038984
## attr(,"label")
## [1] "Coefficients:"
## 
##  Correlation structure:
##          lower      est.     upper
## Rho 0.06596382 0.3959955 0.7493731
## attr(,"label")
## [1] "Correlation structure:"
## 
##  Residual standard error:
##    lower     est.    upper 
## 33.39319 47.04679 66.28298

Lack of fit F-tests

In practice

Example

data(corrosion, package = "faraway")
lm_cor <- lm(loss ~ Fe, data = corrosion)
lm_sat <- lm(loss ~ factor(Fe), data = corrosion)
anova(lm_cor, lm_sat)
## Analysis of Variance Table
## 
## Model 1: loss ~ Fe
## Model 2: loss ~ factor(Fe)
##   Res.Df     RSS Df Sum of Sq      F   Pr(>F)   
## 1     11 102.850                                
## 2      6  11.782  5    91.069 9.2756 0.008623 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# significant lack of fit

Robust regression

Remember to define our least squares estimates we looked for β to minimise i=1n(yixiTβ)2

In practice, since we are squaring residuals, observations with large residuals carry a lot of weight. For, robust regression, we want to downweight the observations with large residuals.

The idea of M-estimators is to extend this to the general situation where we want to find β to minimise i=1nρ(yixiTβ) where ρ() is some function we specify.

i=1nρ(yixiTβ)

The models are usually fit in an iterative process.

Least trimmed squares

Minimise the smallest residuals i=1qe(i)2 where q is some number smaller than n and e(i) is the ith smallest residual.

One choice, q=n/2+(p+1)/2

Annual numbers of telephone calls in Belgium