To begin to generate theories and hypotheses from data, it helps to be able to see the relationship between two variables. We can do this in a plot by adding a trendline to the figure, which fits a line to the data in order to identify the relationship. To do this, let's first download a new dataset here. These data allow us to see the relationship between unemployment rates and voting behavior, as well as look at voting behavior over time.

### Adding a Trendline

First, let's make a scatterplot of total voting percentages versus unemployment rates. Refer to earlier in the tutorial if you don't remember how to do this. We get the following figure:

Now we want to fit a line to this scatterplot that best represents the relationship between the data. It looks like higher unemployment rates correspond to higher voting rates. To see what a linear relationship looks like, we fit a line to this figure. Click on your figure to select it, then click on "Layout" under "Chart Tools". Click on "Trendline" like in the image below, and add a **linear** trendline.

This will give us a trendline like the one below:

Fitting trendlines allows for many options. Sometimes, we can hypothesize that the relationship between our variables is not simply linear. For example, we hypothesize that the relationship of voting behavior over time is not linear. In the following case, we chose to plot an polynomial trendline and we can see that it bends downwards and then upwards as time increases. This relationship would not be visible if we used a linear trendline.

### Formatting Trendlines

You can edit your trendline and see more options by right-clicking on the chart field to select it and choosing "Format Trendline" from the menu.

### Adding Equation and R-Squared

Apart from editing the visual appearance of our line, we can choose a number of other options. One of the most important is to display a measure of how well your linear relationship fits your data. The R-squared value is a summary of how much of the variance a particular line explains. In the format box, check the boxes to display the equation and the R-squared values on your graph (seen at the bottom of the Format Trendline dialogue box above).

We can now see the equation of the line and the proportion of variance in the data explained by the linear relationship. Visually, this is the same process as running a regression of the Y-variable on the X-variable.

### Adding Error Bars

**Chart Tools**select the

**Layout**tab and then

**Error B**

**ars**.

### << Back to Copying, Cutting, & Pasting Charts

### Continue to Linest Function >>

### Return to Table of Contents

Questions, comments, concerns?

Send an email to the Empirical Reasoning Lab

Or drop by during the Lab's open hours.