---
title: "GLMs"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## GLMs -- Gaussian(link=identity)

Here's R's built-in `cars` dataset (speed of cars and the distances taken to stop).

```{r message=F}
require(ggplot2)
qplot(speed, dist,data=cars)
```

Let's no run a linear regression on it

```{r}
summary(lm(dist~speed, data=cars))
```

The same thing, but with GLM

```{r}
summary(glm(dist~speed, data=cars, family=gaussian(link=identity)))
```


Here's another way to get the overdispersion parameter:

```{r}
anova(lm(dist~speed, data=cars))
```

As you can see, the MSE (i.e., the mean squared error, or the mean squared residual (ajusted for the reduction in degrees of freedom) is the same as the estimated overdispersion.


