.R
), R markdown (.Rmd
), or Sweave (.Rnw
)setwd()
rm(list=ls())
attach()
Pick a data set and perform the following steps. (For each step, either write R code or text (commented-out if you’re writing R code).
lm()
. In comments/text, explain why you chose a particular model (i.e. including or excluding predictors, including or excluding interactions).dotwhisker::dwplot(your_model)
, library(effects); plot(allEffects(your_model))
, or sjPlot::plot_model(your_model)
to summarize your model.Do not do any model/variable selection steps (we’ll talk about this in class).
Some data sets you could try:
rock
: perm
is the response variable. Do you notice any concerns with non-independence in the data?mtcars
: mpg
is the response variable. It is suggested that you pick one or two predictor variables to work with (do not do stepwise selection), e.g. disp
, cyl
, and am
. If you do use all possible predictor variables, comment on why this might not give good results.prostate
(in the faraway
package): lpsa
is the response variable.swiss
: Fertility
is the response variable.You can also see help(package="datasets")
or install.packages("carData"); help(package="carData")
for more options (obviously, not all of these data sets will be suitable examples for linear regression).