For this example we will continue to use the {rocket} data.

rocket<-read.csv("https://raw.githubusercontent.com/kitadasmalley/sp21_MATH376LMT/main/data/rocketProp.csv",
                 header=TRUE)
colnames(rocket)<-c("obs", "shear", "age")

# fitting and store the SLR model
mod<-lm(shear~age, rocket)

Confidence Interval for \(\sigma^2\)

Recall the following

A \(100\times (1-\alpha)%\) confidence interval for \(\sigma^2\) is given by

\[[\frac{SS(Res)}{\chi^2_{n-2, \alpha/2}}, \frac{SS(Res)}{\chi^2_{n-2, 1-\alpha/2}}]\]

In our example:

ss_res<-sum(mod$residuals^2)
ss_res
## [1] 166254.9
n<-length(mod$residuals)
n
## [1] 20

We need \(\chi^2_{n-2, \alpha/2}\) for the lower bound:

# 0.975 quantile --> Use for lower bound
qchisq(0.975, df=n-2)
## [1] 31.52638

We need \(\chi^2_{n-2, 1-\alpha/2}\) for the upper bound:

# 0.025 quantile --> Use for upper bound
qchisq(0.025, df=n-2)
## [1] 8.230746

Then calculate the interval

# lower bound
LB<-ss_res/qchisq(0.975, df=n-2)
LB
## [1] 5273.516
# upper bound
UB<-ss_res/qchisq(0.025, df=n-2)
UB
## [1] 20199.24

ANOVA

anova(mod)
## Analysis of Variance Table
## 
## Response: shear
##           Df  Sum Sq Mean Sq F value    Pr(>F)    
## age        1 1527483 1527483  165.38 1.643e-10 ***
## Residuals 18  166255    9236                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Note that this does not give the row for Total, but we can compute that ourselves.

Coefficient of Determination, \(R^2\)

Let \[R^2=\frac{SS(Reg)}{SS(Tot)}=1-\frac{SS(Res)}{SS(Tot)}\]

  • \(SS(Reg)=1527483\)
  • \(SS(Tot)=1527483+166255=1693738\)
ss_reg<-1527483

ss_tot=ss_reg+ss_res
ss_tot
## [1] 1693738
R2<-ss_reg/ss_tot
R2
## [1] 0.9018414
Corollary: \(r^2=R^2\)
cor(rocket$shear, rocket$age)
## [1] -0.9496533
cor(rocket$shear, rocket$age)^2
## [1] 0.9018414