By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
A linear regression model uses a linear equation to predict the value of a dependent variable based on one or more independent variables. The least squares line is a specific type of linear regression model that minimizes the sum of the squared residuals between observed data points and the predicted line.
Linear regression is a fundamental technique in data analysis, widely used in various fields, including:
The least squares line is a linear equation of the form:
$$y = \beta_0 + \beta_1x$$
where:
The goal of the least squares line is to minimize the sum of the squared residuals between observed data points and the predicted line.
Residuals are the differences between observed data points and the predicted line. They are calculated as:
$$e_i = y_i - (\beta_0 + \beta_1x_i)$$
R-squared measures the proportion of the variance in the dependent variable that is explained by the independent variable(s). It is calculated as:
$$R^2 = 1 - \frac{\sum e_i^2}{\sum (y_i - \bar{y})^2}$$
To solve a linear regression problem, follow these steps:
A company wants to predict the price of a new product based on the number of features it has. The data is as follows:
Find the least squares line and calculate R-squared.
First, we need to calculate the mean of the independent variable (features) and the dependent variable (price).
$$\bar{x} = \frac{2 + 3 + 4 + 5 + 6}{5} = 4$$
$$\bar{y} = \frac{100 + 120 + 150 + 180 + 200}{5} = 150$$
Next, we need to calculate the deviations from the mean for both variables.
Then, we need to calculate the slope ($\beta_1$) and the y-intercept ($\beta_0$) of the least squares line.
$$\beta_1 = \frac{\sum (x_i - \bar{x})(y_i - \bar{y})}{\sum (x_i - \bar{x})^2}$$
$$\beta_1 = \frac{(-2)(-50) + (-1)(-30) + (0)(0) + (1)(30) + (2)(50)}{(-2)^2 + (-1)^2 + (0)^2 + (1)^2 + (2)^2}$$
$$\beta_1 = \frac{100 + 30 + 0 + 30 + 100}{4 + 1 + 0 + 1 + 4}$$
$$\beta_1 = \frac{260}{10}$$
$$\beta_1 = 26$$
$$\beta_0 = \bar{y} - \beta_1 \bar{x}$$
$$\beta_0 = 150 - 26(4)$$
$$\beta_0 = 150 - 104$$
$$\beta_0 = 46$$
The least squares line is:
$$y = 46 + 26x$$
Finally, we need to calculate the residuals and R-squared.
$$e_i = y_i - (46 + 26x_i)$$
$$e_i = y_i - 46 - 26x_i$$
$$e_i = (y_i - 46) - 26x_i$$
$$e_i = (y_i - 46) - 26(x_i - 4)$$
$$e_i = (y_i -
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.