4 Linear Regression with One Regressor
This chapter introduces the basics in linear regression and shows how to perform regression analysis in R. In linear regression, the aim is to model the relationship between a dependent variable \(Y\) and one or more explanatory variables denoted by \(X_1, X_2, \dots, X_k\). Following the book we will focus on the concept of simple linear regression throughout the whole chapter. In simple linear regression, there is just one explanatory variable \(X_1\).
If, for example, a school cuts its class sizes by hiring new teachers, that is, the school lowers \(X_1\), the student-teacher ratios of its classes, how would this affect \(Y\), the performance of the students involved in a standardized test? With linear regression we can not only examine whether the student-teacher ratio does have an impact on the test results but we can also learn about the direction and the strength of this effect.
The following packages are needed for reproducing the code presented in this chapter:
AER - accompanies the Book Applied Econometrics with R Kleiber & Zeileis (2008) and provides useful functions and data sets.
MASS - a collection of functions for applied statistics.
Make sure these are installed before you go ahead and try to replicate the examples. The safest way to do so is by checking whether the following code chunk executes without any errors.
Kleiber, C., & Zeileis, A. (2008). Applied Econometrics with R. Springer.