# Simple Linear Regression

A linear comparison of  only two quantitative variables.&#x20;

![](/files/-LgVSrpy0CtXmw_vPkxq)

![](/files/-LgVT-7aQ5aVgdUrqo5X)

### Correlation Coefficient r

The strenght and direction of a linear relationship.&#x20;

![](/files/-LgVU5ITOEf5zCgY4fwU)

It's always between -1 and 1. &#x20;

![](/files/-LgVUGvc4RVx6-f3krox)

r is a very field dependant measure. The bounderies are different in social sciences because humans are unpredictable, than environmental sciences.&#x20;

But in general:&#x20;

![](/files/-LgVUuKfir06vd9Eq4mq)

### Linear regression line

![](/files/-LgVVZxb-o-tWnaAzry8)

b0 is used for the statistic (sample) and Beta0 for the parameter - the population.&#x20;

![](/files/-LgVVh48YyxmP_Mk3rKb)

![](/files/-LgVVmIIuYC743R3xGHL)

y-hat defines the point of the line while the y defines the point of the real measure.&#x20;

### Least-Squares algorithm

![](/files/-LgVXUWssXmuHyghkZyv)

The main algorithm used to find the best fit line is called the **least-squares** algorithm, which finds the line that minimizes

![](/files/-LgVXQRfPG8lVnnTcwEp)

![](/files/-LgVXtV4gzwYyvpzpRYZ)

There are other functions like below, but this one is built into python by default, it tends to work well for most data sets,  and has calculus properties that make it good to use.&#x20;

![](/files/-LgVYG0aYUzibUs-JYHY)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://julienbeaulieu.gitbook.io/wiki/sciences/math/statistics/simple-linear-regression.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
