Example: Fit a Linear Regression Model

In this example you fit a linear regression model to predict the 1987 salaries of Major League Baseball players as a function of several explanatory variables in the Baseball data set. The response variable is salary. The example examines three explanatory variables: two measures of hitting performance and one measure of longevity. The explanatory variables are described in the following list:

  • no_hits, the number of hits in 1986

  • no_home, the number of home runs in 1986

  • yr_major, the number of years that the player had been in the major leagues as of 1987

The example has four major steps:

  1. Apply a logarithmic transformation to the response variable.

  2. Set name to be the variables whose values are used to label observations.

  3. Run the Linear Regression analysis.

  4. Interpret the various plots that the analysis can produce.