# Linear Functions

## Fitting Linear Models to Data


### Learning Objectives

1. Plot points in a rectangular coordinate system (IA 3.1.1).
2. Find an equation of the line given two points (IA 3.3.3).

### Objectives: Plot points in a rectangular coordinate system (IA 3.1.1) and find an equation of the line given two points. (IA 3.3.3)

In this section we will be plotting collections of data points and looking for patterns in these data sets. A scatterplot is a collection of points plotted on the same coordinate system. When trying to fit a function to a data set it is important to note if there is a pattern to the data set and whether that pattern is linear or nonlinear. If the dependent variable increases as the independent variable increases, we call this a positive association. If the dependent variable decreases as the independent variable increases, we call this a negative association.


### Practice Makes Perfect

A professor is attempting to identify trends among final exam scores. His class has a mixture of students, so he wonders if there is any relationship between age and final exam scores. One way for him to analyze the scores is by creating a diagram that relates the age of each student to the exam score received. In this section, we will examine one such diagram known as a scatter plot.

### Drawing and Interpreting Scatter Plots

A scatter plot is a graph of plotted points that may show a relationship between two sets of data. If the relationship is from a linear model, or a model that is nearly linear, the professor can draw conclusions using his knowledge of linear functions.  shows a sample scatter plot.
Notice this scatter plot does not indicate a linear relationship. The points do not appear to follow a trend. In other words, there does not appear to be a relationship between the age of the student and the score on the final exam.

### Finding the Line of Best Fit

Once we recognize a need for a linear function to model that data, the natural follow-up question is “what is that linear function?” One way to approximate our linear function is to sketch the line that seems to best fit the data. Then we can extend the line until we can verify the y-intercept. We can approximate the slope of the line by extending it until we can estimate the 
    

### Recognizing Interpolation or Extrapolation

While the data for most examples does not fall perfectly on the line, the equation is our best guess as to how the relationship will behave outside of the values for which we have data. We use a process known as interpolation when we predict a value inside the domain and range of the data. The process of extrapolation is used when we predict a value outside the domain and range of the data.
 compares the two processes for the cricket-chirp data addressed in . We can see that interpolation would occur if we used our model to predict temperature when the values for chirps are between 18.5 and 44. Extrapolation would occur if we used our model to predict temperature when the values for chirps are less than 18.5 or greater than 44.
There is a difference between making predictions inside the domain and range of values for which we have data and outside that domain and range. Predicting a value outside of the domain and range has its limitations. When our model no longer applies after a certain point, it is sometimes called model breakdown. For example, predicting a cost function for a period of two years may involve examining the data where the input is the time in years and the output is the cost. But if we try to extrapolate a cost when 
    that is in 50 years, the model would not apply because we could not account for factors fifty years in the future.

### Finding the Line of Best Fit Using a Graphing Utility 

While eyeballing a line works reasonably well, there are statistical techniques for fitting a line to data that minimize the differences between the line and data valuesTechnically, the method minimizes the sum of the squared differences in the vertical direction between the line and the data values.. One such technique is called least squares regression and can be computed by many graphing calculators, spreadsheet software, statistical software, and many web-based calculatorsFor example, http://www.shodor.org/unchem/math/lls/leastsq.html. Least squares regression is one means to determine the line that best fits the data, and here we will refer to this method as linear regression.

### Distinguishing Between Linear and Nonlinear Models

As we saw above with the cricket-chirp model, some data exhibit strong linear trends, but other data, like the final exam scores plotted by age, are clearly nonlinear. Most calculators and computer software can also provide us with the correlation coefficient, which is a measure of how closely the line fits the data. Many graphing calculators require the user to turn a "diagnostic on" selection to find the correlation coefficient, which mathematicians label as 
    The correlation coefficient provides an easy way to get an idea of how close to a line the data falls.
We should compute the correlation coefficient only for data that follows a linear pattern or to determine the degree to which a data set is linear. If the data exhibits a nonlinear pattern, the correlation coefficient for a linear regression is meaningless. To get a sense for the relationship between the value of 
    and the graph of the data,  shows some large data sets with their correlation coefficients. Remember, for all plots, the horizontal axis shows the input and the vertical axis shows the output.

### Fitting a Regression Line to a Set of Data 

Once we determine that a set of data is linear using the correlation coefficient, we can use the regression line to make predictions. As we learned above, a regression line is a line that is closest to the data in the scatter plot, which means that only one such line is a best fit for the data.

### Key Concepts

1. Scatter plots show the relationship between two sets of data. See .
2. Scatter plots may represent linear or non-linear models.
3. The line of best fit may be estimated or calculated, using a calculator or statistical software. See .
4. Interpolation can be used to predict values inside the domain and range of the data, whereas extrapolation can be used to predict values outside the domain and range of the data. See .
5. The correlation coefficient, 
    indicates the degree of linear relationship between data. See .
6. A regression line best fits the data. See .
7. The least squares regression line is found by minimizing the squares of the distances of points from a line passing through the data and may be used to make predictions regarding either of the variables. See .

### Section Exercises


### Verbal


### Algebraic

For the following exercises, draw a scatter plot for the data provided. Does the data appear to be linearly related?

### Graphical

For the following exercises, match each scatterplot with one of the four specified correlations in  and .
For the following exercises, draw a best-fit line for the plotted data.

### Numeric


### Technology

For the following exercises, use each set of data to calculate the regression line using a calculator or other technology tool, and determine the correlation coefficient to 3 decimal places of accuracy.

### Extensions

For the following exercises, consider this scenario: The profit of a company decreased steadily over a ten-year span. The following ordered pairs shows dollars and the number of units sold in hundreds and the profit in thousands of over the ten-year span, (number of units sold, profit) for specific recorded years:

   


### Real-World Applications

For the following exercises, consider this scenario: The population of a city increased steadily over a ten-year span. The following ordered pairs shows the population and the year over the ten-year span, (population, year) for specific recorded years:
 
   
  
For the following exercises, consider this scenario: The profit of a company increased steadily over a ten-year span. The following ordered pairs show the number of units sold in hundreds and the profit in thousands of over the ten year span, (number of units sold, profit) for specific recorded years:
 
   
  
For the following exercises, consider this scenario: The profit of a company decreased steadily over a ten-year span. The following ordered pairs show dollars and the number of units sold in hundreds and the profit in thousands of over the ten-year span (number of units sold, profit) for specific recorded years:
 
   
  

### Chapter Review Exercises


### Linear Functions

For the following exercises, determine whether the lines given by the equations below are parallel, perpendicular, or neither parallel nor perpendicular:
For the following exercises, find the x- and y- intercepts of the given equation
For the following exercises, use the descriptions of the pairs of lines to find the slopes of Line 1 and Line 2. Is each pair of lines parallel, perpendicular, or neither?

### Modeling with Linear Functions

For the following exercises, use the graph in  showing the profit, 
    in thousands of dollars, of a company in a given year, 
    where 
    represents years since 1980.
For the following exercise, consider this scenario: In 2004, a school population was 1,700. By 2012 the population had grown to 2,500.
For the following exercises, consider this scenario: In 2000, the moose population in a park was measured to be 6,500. By 2010, the population was measured to be 12,500. Assume the population continues to change linearly.
For the following exercises, consider this scenario: The median home values in subdivisions Pima Central and East Valley (adjusted for inflation) are shown in . Assume that the house values are changing linearly.

### Fitting Linear Models to Data

For the following exercises, consider the data in , which shows the percent of unemployed in a city of people 25 years or older who are college graduates is given below, by year. 
For the following exercises, consider this scenario: The population of a city increased steadily over a ten-year span. The following ordered pairs show the population and the year over the ten-year span (population, year) for specific recorded years:
 
   
  

### Chapter Practice Test

For the following exercises, determine whether the lines given by the equations below are parallel, perpendicular, or neither parallel nor perpendicular.
For the following exercises, use the graph in , showing the profit, 
    in thousands of dollars, of a company in a given year, 
    where 
    represents years since 1980.

  
  
For the following exercises, use , which shows the percent of unemployed persons 25 years or older who are college graduates in a particular city, by year.
For the following exercises, consider this scenario: The population of a city increased steadily over a ten-year span. The following ordered pairs shows the population (in hundreds) and the year over the ten-year span, (population, year) for specific recorded years:
 
   
  