Limitations of linear models

Model Linear Tergeneralisasi di 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
Model Linear Tergeneralisasi di 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
Model Linear Tergeneralisasi di 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 $
Model Linear Tergeneralisasi di R

Linear models in R

lm(y ~ x, data = dat)
Model Linear Tergeneralisasi di R

Assumption of linearity

Example of linear and non-linear data

Model Linear Tergeneralisasi di R

Assumption of normality

Normal vs non-normal residuals

Model Linear Tergeneralisasi di R

Assumption of continuous variables

Continuous compared to non-continuous data.

Model Linear Tergeneralisasi di R

Boxplot of chick weights at end of study

Model Linear Tergeneralisasi di 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
Model Linear Tergeneralisasi di 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
Model Linear Tergeneralisasi di R

Generalized linear model

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

GLMs in R

glm( y ~ x, data = data, family = "gaussian")
  • lm() same as glm( ..., family = "gaussian")
Model Linear Tergeneralisasi di R

Let's practice!!

Model Linear Tergeneralisasi di R

Preparing Video For Download...