Limitations of linear models

Generalized Linear Models in R

Richard Erickson

Instructor

Course overview

  • Chapter 1: Review and limits of linear model and Poisson regressions
  • Chapter 2: Logistic (Binomial) regression
  • Chapter 3: Interpreting and plotting GLMs
  • Chapter 4: Multiple regression with GLMs
Generalized Linear Models in R

Workhorse of data science

Linear modes: Workhorse of data science

1 US Department of Agriculture https://www.nal.usda.gov/exhibits/ipd/localfoods/exhibits/show/farmto–table/the–roads–of–rural–america
Generalized Linear Models in R

Linear models

  • How can linear coefficients explain the data?
  • Intercept for baseline effect
  • Slope for linear predictor
  • $y = \beta_0 + \beta_1 x + \epsilon $
Generalized Linear Models in R

Linear models in R

lm(y ~ x, data = dat)
Generalized Linear Models in R

Assumption of linearity

Example of linear and non-linear data

Generalized Linear Models in R

Assumption of normality

Normal vs non-normal residuals

Generalized Linear Models in R

Assumption of continuous variables

Continuous compared to non-continuous data.

Generalized Linear Models in R

Boxplot of chick weights at end of study

Generalized Linear Models in R

Chick diets impact on weight

  • ChickWeight data from datasets package

  • ChickWeightsEnd last observation from study

  • How do diets 2, 3, and 4 compare to diet 1?

lm(formula = weight ~ Diet, data = ChickWeightEnd)
    Call:
    lm(formula = weight ~ Diet, data = ChickWeightEnd)
    Coefficients:
    (Intercept)        Diet2        Diet3        Diet4  
         177.75        36.95        92.55        60.81
Generalized Linear Models in R

What about survivorship or counts?

  • What about chick survivorship or chick counts?
  • Neither are continuous!
  • We need a new tool
  • The generalized linear model
Generalized Linear Models in R

Generalized linear model

  • Similar to linear models
  • Non-normal error distribution
  • Link functions: $y = \psi(b_0 + b_1 x + \epsilon)$
Generalized Linear Models in R

GLMs in R

glm( y ~ x, data = data, family = "gaussian")
  • lm() same as glm( ..., family = "gaussian")
Generalized Linear Models in R

Let's practice!!

Generalized Linear Models in R

Preparing Video For Download...