To use linear regression to predict gas prices in 2025, we need to find the equation of the line that best fits the data.
Let the independent variable (x) represent the year and the dependent variable (y) represent the gas prices.
Using the given data, we can calculate the slope (m) and y-intercept (b) of the regression line.
Step 1: Calculate the average value of x and y:
- Sum of x = 2002 + 2003 + ... + 2011 = 20,083
- Sum of y = 0.70 + 1.04 + ... + 2.56 = 15.81
Step 2: Calculate the sum of the products x * y:
- Sum of x * y = (2002 * 0.70) + (2003 * 1.04) + ... + (2011 * 2.56) = 40,892.68
Step 3: Calculate the sum of the squares of x:
- Sum of x^2 = (2002^2) + (2003^2) + ... + (2011^2) = 40,321,305
Step 4: Calculate the slope (m):
- m = (n * sum(x * y) - sum(x) * sum(y)) / (n * sum(x^2) - (sum(x))^2)
- n is the number of data points, which is 10 in this case
- Plug in the values:
m = (10 * 40,892.68 - 20,083 * 15.81) / (10 * 40,321,305 - (20,083)^2)
m ≈ 0.1400
Step 5: Calculate the y-intercept (b):
- b = (sum(y) - m * sum(x)) / n
- Plug in the values:
b = (15.81 - 0.1400 * 20,083) / 10
b ≈ -256.0243
Therefore, the linear regression equation is:
y = 0.1400x - 256.0243
To predict the gas price in 2025 (x = 2025), substitute x = 2025 into the equation:
y = 0.1400 * 2025 - 256.0243
y ≈ 283.4757
Therefore, the predicted gas price in 2025 is approximately $283.48.
Average gas prices in Columbia S.C. is listed in the following table.
YEAR GAS PRICES
2002 $ 0.70
2003 1.04
2004 1.15
2005 1.38
2006 1.86
2007 1.70
2008 2.55
2009 1.29
2010 2.22
2011 2.56
Use the linear regression equation to predict how much you expect gas to cost in 2025?
1 answer