You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We will continue with the iris data set and check if there might be an association between the Sepal length and the Petal length.
Plot the petal length against the sepal length to see if there might be a linear relationship between them.
Do histograms of the Sepal Length and the Petal Length to check that they seem to follow a normal distribution
You will probably notice that the histograms shows something that doesn’t look completely normal. The reason is that the two length variables depends a lot on the species. In the plot below you can see the different species in different colors. Since the species influence the length so much we need to consider it when analyzing the lengths.
Use the lm() function to do a linear regression. Use Sepal Length as response variable and Petal Length as predictor. Save the regression in a variable and look at the results using the summary() function.
Now, do the same regression again, but include Species as covariate (predictor). Compare the effects (i.e. the slopes) for Petal Length in both models. In the second model the effect is smaller. That is because a lot of the Sepal Length is described by the Species.