This page makes much more sense if you have read and understood Worksheet 06 in that here we build off some of the data from that worksheet. This time, however,we cannot use

`gnrnd4()`

new_L1 <- c(9.6,15.5,25,9.6,-8.3,1.7,7.3,10.2, -2.2,20.3,9.8,25.5,15.3,18.1,0.9,10.3, 3.8,13.3,8.9,7.7,2.8,-5.4,-4.7,9.5,23.1, 2.2,22.5,14.9,14.7,24.2) new_L2 <- c(-9.9,-25.2,-47,-12.3,24.6,4.1,-7.3,-13.8, 12.1,-35.5,-12.8,-37.7,-24.7,-30.9,5.7,-11, -0.2,-16.9,-10.7,-6.3,1.8,19.4,18.1,-9.8, -33.8,4.5,-33.7,-23.9,-19.4,-35.9) plot(new_L1,new_L2) ws06a_lm <- lm(new_L2~new_L1) ws06a_lm summary( ws06a_lm) abline( ws06a_lm, col="red", lwd=2) cor(new_L1,new_L2) new_resid <- residuals( ws06a_lm ) plot(new_L1,new_resid)

We will follow the usual procedure for doing our work on the USB drive. In particular, we have

- inserted our USB drive,
- created a directory called
on that drive`worksheet06a`

- have copied
from our root folder into our new folder,`model.R`

- have renamed that new copy of the file to the name
, and`ws06a.R`

- have double clicked on that file to open
**RStudio**.

Then, we highlight the commands given above on this we page as shown in Figure 1a.

We copy those commands (via the

`ws06a.R`

Now that we have all of the commands we can highlight the ones we want to execute and then run those commands. Figure 2 shows the two commands to put values into the variables

`new_L1`

`new_L2`

Just to help us understand the relationship of these values to the ones we reated in

`new_L1`

`L1`

`new_L2`

Running the lines highlighted in Figure 2produces the plot in Figure 3.

The similarity in the values we have in Figure 3 to those that we had for

Moving on we create a linear model for the relation between

`new_L1`

`new_L2`

The output, shown in Figure 5, gives rise to the regression equation

`y =7.753 + (-1.963)x`

The

`summary(ws06a_lm)`

The result of running the command is given in Figure 7.

We can compare the results shown in Figure 7 with those that we saw in the earlier example, shown here in Old Figure 15.

Again, we can detect differences, but they seem minor.

Figure 8 shows the command we need to add the regression line to the scatter plot.

Figure 9 shows that new graph.

Of course we want to find the

/center> The value of the

But now we get to the whole point of this worksheet, wewill look at the

As you should expect at this point, there is not much to see in the

However, the scatter plot shown in Figure 14 is the real change from the earlier example. Here the residual values are not all over the place. They form a definite, if strange, pattern. Seeing this would be enough to make us cautious about applying the linear regression equation. In particular, in this case, what we see is that as the

Not shown here are the usual steps of saving our file and quiting our

©Roger M. Palay Saline, MI 48176 February, 2017