Purpose
To work on the multiple regression problem in this chapter

> setwd("C:/Cauldron/garage/R/soulcraft/Volatility/Learn/Dobson-GLM")
> data <- read.csv("test10.csv", header = T, stringsAsFactors = F)

Fit a model

> fit <- lm(c ~ a + w + p, data)
> fit.sum <- (summary(fit))
> sqrt(deviance(fit)/(20 - 4)) * sqrt(diag(fit.sum$cov.unscaled))
(Intercept)           a           w           p
13.07128293  0.10932548  0.08328895  0.63489286
> fit1 <- lm(c ~ w + p, data)
> anova(fit1, fit)
Analysis of Variance Table
Model 1: c ~ w + p Model 2: c ~ a + w + p Res.Df RSS Df Sum of Sq F Pr(>F) 1 17 606.02 2 16 567.66 1 38.36 1.0812 0.3139

One can use aov function to get anova output

> setwd("C:/Cauldron/garage/R/soulcraft/Volatility/Learn/Dobson-GLM")
> data <- read.csv("test11.csv", header = T, stringsAsFactors = F)
> data <- stack(data)
> colnames(data) <- c("value", "category")
> summary(aov(data$value ~ data$category))
              Df  Sum Sq Mean Sq F value  Pr(>F)
data$category  2  3.7663  1.8832  4.8461 0.01591 *
Residuals     27 10.4921  0.3886
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  1. To get the same output as above, fit a linear model and do an anova on the fit object
> fit <- lm(value ~ category, data)
> anova(fit)
Analysis of Variance Table
Response: value Df Sum Sq Mean Sq F value Pr(>F) category 2 3.7663 1.8832 4.8461 0.01591 * Residuals 27 10.4921 0.3886 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1