@@ -4,7 +4,7 @@ jupytext:
44 extension : .md
55 format_name : myst
66 format_version : 0.13
7- jupytext_version : 1.14.4
7+ jupytext_version : 1.16.1
88kernelspec :
99 display_name : Python 3 (ipykernel)
1010 language : python
@@ -17,6 +17,8 @@ kernelspec:
1717import numpy as np
1818import pandas as pd
1919import matplotlib.pyplot as plt
20+ import pyodide_http
21+ pyodide_http.patch_all()
2022```
2123
2224The 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
6062---
6163mystnb:
6264 figure:
63- caption: " Scatter plot"
65+ caption: Scatter plot
6466 name: sales-v-temp1
6567---
6668ax = df.plot(
@@ -92,7 +94,7 @@ df['Y_hat'] = α + β * df['X']
9294---
9395mystnb:
9496 figure:
95- caption: " Scatter plot with a line of fit"
97+ caption: Scatter plot with a line of fit
9698 name: sales-v-temp2
9799---
98100fig, ax = plt.subplots()
@@ -114,7 +116,7 @@ df['Y_hat'] = α + β * df['X']
114116---
115117mystnb:
116118 figure:
117- caption: " Scatter plot with a line of fit #2"
119+ caption: ' Scatter plot with a line of fit #2'
118120 name: sales-v-temp3
119121---
120122fig, ax = plt.subplots()
@@ -132,7 +134,7 @@ df['Y_hat'] = α + β * df['X']
132134---
133135mystnb:
134136 figure:
135- caption: " Scatter plot with a line of fit #3"
137+ caption: ' Scatter plot with a line of fit #3'
136138 name: sales-v-temp4
137139---
138140fig, ax = plt.subplots()
164166---
165167mystnb:
166168 figure:
167- caption: " Plot of the residuals"
169+ caption: Plot of the residuals
168170 name: plt-residuals
169171---
170172fig, ax = plt.subplots()
@@ -213,7 +215,7 @@ Plotting the error
213215---
214216mystnb:
215217 figure:
216- caption: " Plotting the error"
218+ caption: Plotting the error
217219 name: plt-errors
218220---
219221ax = pd.Series(errors).plot(xlabel='β', ylabel='error')
@@ -234,7 +236,7 @@ Plotting the error
234236---
235237mystnb:
236238 figure:
237- caption: " Plotting the error (2)"
239+ caption: Plotting the error (2)
238240 name: plt-errors-2
239241---
240242ax = pd.Series(errors).plot(xlabel='α', ylabel='error')
@@ -371,7 +373,7 @@ Now we can plot the OLS solution
371373---
372374mystnb:
373375 figure:
374- caption: " OLS line of best fit"
376+ caption: OLS line of best fit
375377 name: plt-ols
376378---
377379df['Y_hat'] = α + β * df['X']
@@ -413,7 +415,7 @@ You can download {download}`a copy of the data here <https://github.com/QuantEco
413415**Q3:** Use `pandas` to import the `csv` formatted data and plot a few different countries of interest
414416
415417```{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"
417419df = pd.read_csv(data_url, nrows=10)
418420```
419421
0 commit comments