Fun Share: Linear Regression anyone?

Linear regression is the most common tool used for prediction and forecasting. It is based on sets of data that seem to exhibit some kind of linear relationship - ie. if some independent variable goes up, the dependent variable goes up too, etc. when you plot these sets of data on a scatter plot, you can visually see the clustering that shows this relationship. Linear regression is the process that comes up with a straight line that goes through all these points with the best “fit”. Linear regression is used mainly in prediction and forecasting.

consider this data series of several subjects,of different ages, and the amount of glucose in their blood.
image

if you plot these points on a scatter plot, you can see the trend that suggests that there is a relationship between age and glucose count.

this thunkable app demonstrates how linear regression is used to compute the best fitting line through those points:
lr_chart

here are the blocks for the demo.

the app itself does not do the chart (i used an external tool to do the chart). The app returns the outcome of linear regression -the Slope and Intercept

when you plug these values into this formula

y = Slope * x + Iintercept

you get the equation of a straight line which cuts (ie. intercepts) the y axis at y=Intercept and with an inclination (ie. slope,vertical rise per unit horizontal distance) with the value of slope.

from the data above, the slope of the line varies such that for each unit change in x (age), y (glucose level) goes up by 0.3852 and when the age is zero, the glucose level is 65.1416 - the intercept (i guess it means a newborn baby already has a glucose level of 65.1416 at birth),

this line (represented by the slope and intercept) may be used to predict the estimated glucose level of someone who is 70 years old by solving this equation

y = 0,3852 * 70 + 65.1416
y = 92.1056, around 92

here is the link.
https://x.thunkable.com/copy/9acdc4b01c31d41b68ea855086addf69

2 Likes