Intro Lab 10

John Fieberg

Goals

  • Linear regression with a continuous and categorical predictor

    • With and without interactions
  • Compare models using AIC, t-tests, adusted \(R^2\)

  • Diagnostics (again!)

Bonus:

  • Exposure to ggplot

  • Exposure to stepwise model selection, model averaging

Data set

Mole rats: energy expenditure vs. body mass

  • worker caste
  • lazy caste
Picture of a mole rat

Scatterplots of log energy expenditure versus log mass with regression lines overlaid.
  • lm(ln.energy ~ ln.mass + caste, data=MoleRats)
  • lm(ln.energy ~ ln.mass + caste + ln.mass:caste, data=MoleRats)

The latter expression is equivalent to:

lm(ln.energy ~ ln.mass*caste, data=MoleRats)

Abundance of longnose dace (Rhinichthys cataractae) in 75-meter sections of a stream.

Picture of a longnose dace.

Explore factors related to abundance…

Stepwise selection

  1. Start with a “full model”:

fullmod<-lm(longnosedace ~ acreage+do2+maxdepth+no3+so4+temp, data=dace)

  1. Check assumptions…

Loop:

  1. Fit all models with 1 less variable. Compare models using AIC.
  2. If the current model has the lowest AIC, stop. If not, drop the least significant variable and go back to step 3.

Model averaging

  1. Fit multiple models (ideally, specified a priori)
  2. Calculate AIC for each model
  3. Determine model weights, \(w_i = \frac{\exp(-AIC_i/2)}{\sum_m exp(-AIC_m/2)}\)
  4. Determine model average coefficients = \(\sum_m w_m \hat{\beta}_m\)
  5. Determine SE that attempt to account for model uncertainty

Full model

Determine how much complexity you can afford (how many variables you can afford to include given your sample size)

\(p = n/10-n/20\)

Fit a single model (with no model selection)





Giudice, J., J. Fieberg, and M. Lenarz. 2012. Spending degrees of freedom in a poor economy: a case study of building a sightability model for Moose in northeastern Minnesota. Journal of Wildlife Management 76:75-87.