UP | HOME

Exercise 25

Line of best fit

Let x be a vector starting at 1 and ending at 100. Let y be a vector equal to (x * 0.15) + N where N is a vector of random values chosen from a gaussian distribution with mean 0.0 and standard deviation 1.0.

Generate a scatterplot of (x vs y) and overlay on the plot, the line of best fit after fitting a linear model to the data: \(\hat{y} = \beta_{0} + \beta{1}x\).

e25plot1.jpg

add a legend:

e25plot2.jpg

add the equation of the line:


Paul Gribble | fall 2014
This work is licensed under a Creative Commons Attribution 4.0 International License
Creative Commons License