Chapter 11: Linear Regression and Model Building

Links to a carefully curated collection of Youtube videos provide a host of additional sourcs for you to develop your ability to use R software in an engaging and accessible manner.

Video Link 11.1: ‘Linear regression R’

Question: How do we conduct a linear regression in R?

Answer: We use the lm() function in R, where we first specify the outcome variable and then the predictor variable.

 

Video 11.2: ‘Multiple linear regression in R’

Question: What does it mean when we are using multiple linear regression instead of (bivariate) linear regression?

Answer: It means that we have multiple explanatory variables in a regression instead of just one explanatory variable.

 

Video Link 11.3: ‘Change reference/baseline category for a categorical variable in regression model’

Question 1: What is the default baseline/reference category R uses for a categorical explanatory variable in a linear regression?

Answer: The default category is the first category in a categorical explanatory variable.

Question 2: How is the baseline/reference category changed in R in the video?

Answer: The reference category is changed by using the relevel() function and specifying that ‘yes’ is the reference category.

 

Video Link 11.4: ‘Linear regression (statistical testing and prediction)’

Question: How is the linear fit line added to the ggplot() code?

Answer: By including geom_smooth(method='lm').