Page 89 - Applied Statistics with R
P. 89

Chapter 7





                      Simple Linear Regression






                           “All models are wrong, but some are useful.”
                           — George E. P. Box


                      After reading this chapter you will be able to:


                         • Understand the concept of a model.
                         • Describe two ways in which regression coefficients are derived.
                         • Estimate and visualize a regression model using R.
                         • Interpret regression coefficients and statistics in the context of real-world
                           problems.
                         • Use a regression model to make predictions.



                      7.1 Modeling


                      Let’s consider a simple example of how the speed of a car affects its stopping
                      distance, that is, how far it travels before it comes to a stop. To examine this
                      relationship, we will use the cars dataset which, is a default R dataset. Thus,
                      we don’t need to load a package first; it is immediately available.

                      To get a first look at the data you can use the View() function inside RStudio.

                      View(cars)


                      We could also take a look at the variable names, the dimension of the data
                      frame, and some sample observations with str().



                                                        89
   84   85   86   87   88   89   90   91   92   93   94