@@ -4,7 +4,7 @@ jupytext:
4
4
extension : .md
5
5
format_name : myst
6
6
format_version : 0.13
7
- jupytext_version : 1.14.4
7
+ jupytext_version : 1.16.1
8
8
kernelspec :
9
9
display_name : Python 3 (ipykernel)
10
10
language : python
@@ -17,6 +17,8 @@ kernelspec:
17
17
import numpy as np
18
18
import pandas as pd
19
19
import matplotlib.pyplot as plt
20
+ import pyodide_http
21
+ pyodide_http.patch_all()
20
22
```
21
23
22
24
The simple regression model estimates the relationship between two variables $x_i$ and $y_i$
@@ -60,7 +62,7 @@ We can use a scatter plot of the data to see the relationship between $y_i$ (ice
60
62
---
61
63
mystnb:
62
64
figure:
63
- caption: " Scatter plot"
65
+ caption: Scatter plot
64
66
name: sales-v-temp1
65
67
---
66
68
ax = df.plot(
@@ -92,7 +94,7 @@ df['Y_hat'] = α + β * df['X']
92
94
---
93
95
mystnb:
94
96
figure:
95
- caption: " Scatter plot with a line of fit"
97
+ caption: Scatter plot with a line of fit
96
98
name: sales-v-temp2
97
99
---
98
100
fig, ax = plt.subplots()
@@ -114,7 +116,7 @@ df['Y_hat'] = α + β * df['X']
114
116
---
115
117
mystnb:
116
118
figure:
117
- caption: " Scatter plot with a line of fit #2"
119
+ caption: ' Scatter plot with a line of fit #2'
118
120
name: sales-v-temp3
119
121
---
120
122
fig, ax = plt.subplots()
@@ -132,7 +134,7 @@ df['Y_hat'] = α + β * df['X']
132
134
---
133
135
mystnb:
134
136
figure:
135
- caption: " Scatter plot with a line of fit #3"
137
+ caption: ' Scatter plot with a line of fit #3'
136
138
name: sales-v-temp4
137
139
---
138
140
fig, ax = plt.subplots()
164
166
---
165
167
mystnb:
166
168
figure:
167
- caption: " Plot of the residuals"
169
+ caption: Plot of the residuals
168
170
name: plt-residuals
169
171
---
170
172
fig, ax = plt.subplots()
@@ -213,7 +215,7 @@ Plotting the error
213
215
---
214
216
mystnb:
215
217
figure:
216
- caption: " Plotting the error"
218
+ caption: Plotting the error
217
219
name: plt-errors
218
220
---
219
221
ax = pd.Series(errors).plot(xlabel='β', ylabel='error')
@@ -234,7 +236,7 @@ Plotting the error
234
236
---
235
237
mystnb:
236
238
figure:
237
- caption: " Plotting the error (2)"
239
+ caption: Plotting the error (2)
238
240
name: plt-errors-2
239
241
---
240
242
ax = pd.Series(errors).plot(xlabel='α', ylabel='error')
@@ -371,7 +373,7 @@ Now we can plot the OLS solution
371
373
---
372
374
mystnb:
373
375
figure:
374
- caption: " OLS line of best fit"
376
+ caption: OLS line of best fit
375
377
name: plt-ols
376
378
---
377
379
df['Y_hat'] = α + β * df['X']
@@ -413,7 +415,7 @@ You can download {download}`a copy of the data here <https://github.com/QuantEco
413
415
**Q3:** Use `pandas` to import the `csv` formatted data and plot a few different countries of interest
414
416
415
417
```{code-cell} ipython3
416
- data_url = "https://github. com/QuantEcon/lecture-python-intro/raw /main/lectures/_static/lecture_specific/simple_linear_regression/life-expectancy-vs-gdp-per-capita.csv"
418
+ data_url = "https://raw.githubusercontent. com/QuantEcon/lecture-python-intro/main/lectures/_static/lecture_specific/simple_linear_regression/life-expectancy-vs-gdp-per-capita.csv"
417
419
df = pd.read_csv(data_url, nrows=10)
418
420
```
419
421
0 commit comments