Skip to content

Commit 10b3f49

Browse files
authored
Merge pull request #10 from rickecon/main
Merging
2 parents d165818 + 2967598 commit 10b3f49

File tree

7 files changed

+474
-12
lines changed

7 files changed

+474
-12
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.0.5] - 2023-10-27 05:00:00
9+
10+
### Added
11+
- Updates the Basic Empirical Methods section
12+
813
## [0.0.4] - 2023-10-27 02:00:00
914

1015
### Added
@@ -38,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3843

3944

4045

46+
[0.0.5]: https://github.com/OpenSourceEcon/CompMethods/compare/v0.0.4...v0.0.5
4147
[0.0.4]: https://github.com/OpenSourceEcon/CompMethods/compare/v0.0.3...v0.0.4
4248
[0.0.3]: https://github.com/OpenSourceEcon/CompMethods/compare/v0.0.2...v0.0.3
4349
[0.0.2]: https://github.com/OpenSourceEcon/CompMethods/compare/v0.0.1...v0.0.2

data/BasicEmpirMethods/Auto.csv

Lines changed: 398 additions & 0 deletions
Large diffs are not rendered by default.

docs/book/CompMethods_references.bib

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,14 @@ @BOOK{HumpherysJarvis:2020
322322
volume = {2},
323323
}
324324

325+
@Book{JamesEtAl:2017,
326+
AUTHOR = {Gareth James and Daniela Witten and Trevor Hastie and Robert Tibshirani},
327+
TITLE = {An Introduction to Statistical Learning with Applications in R},
328+
PUBLISHER = {Springer},
329+
YEAR = {2017},
330+
series = {Springer Texts in Statistics},
331+
}
332+
325333
@BOOK{Judd:1998,
326334
AUTHOR = {Kenneth L. Judd},
327335
TITLE = {Numerical Methods in Economics},

docs/book/_toc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ parts:
2121
- file: git/intro
2222
- caption: Basic Causal Inference
2323
chapters:
24-
- file: caus_inf/intro
24+
- file: caus_inf/BasicEmpirMethods
2525
- caption: Basic Machine Learning
2626
chapters:
2727
- file: basic_ml/intro
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
jupytext:
3+
formats: md:myst
4+
text_representation:
5+
extension: .md
6+
format_name: myst
7+
kernelspec:
8+
display_name: Python 3
9+
language: python
10+
name: python3
11+
---
12+
13+
(Chap_BasicEmpirMethods)=
14+
# Basic Empirical Methods
15+
16+
Put basic empirical methods here. {numref}`ExerBasicEmpir_MultLinRegress`
17+
18+
19+
(SecBasicEmpirExercises)=
20+
## Exercises
21+
22+
```{exercise-start} Multiple linear regression
23+
:label: ExerBasicEmpir_MultLinRegress
24+
:class: green
25+
```
26+
For this problem, you will use the 397 observations from the [`Auto.csv`](https://github.com/OpenSourceEcon/CompMethods/tree/main/data/BasicEmpirMethods/Auto.csv) dataset in the [`/data/BasicEmpirMethods/`](https://github.com/OpenSourceEcon/CompMethods/tree/main/data/BasicEmpirMethods) folder of the repository for this book.[^Auto] This dataset includes 397 observations on miles per gallon (`mpg`), number of cylinders (`cylinders`), engine displacement (`displacement`), horsepower (`horsepower`), vehicle weight (`weight`), acceleration (`acceleration`), vehicle year (`year`), vehicle origin (`origin`), and vehicle name (`name`).
27+
1. Import the data using the [`pandas.read_csv()`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html) function. Look for characters that seem out of place that might indicate missing values. Replace them with missing values using the `na_values=...` option.
28+
2. Produce a scatterplot matrix which includes all of the quantitative variables `mpg`, `cylinders`, `displacement`, `horsepower`, `weight`, `acceleration`, `year`, `origin`. Call your DataFrame of quantitative variables `df_quant`. [Use the pandas scatterplot function in the code block below.]
29+
```python
30+
from pandas.plotting import scatter_matrix
31+
32+
scatter_matrix(df_quant, alpha=0.3, figsize=(6, 6), diagonal='kde')
33+
```
34+
3. Compute the correlation matrix for the quantitative variables ($8\times 8$) using the [`pandas.DataFrame.corr()`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.corr.html) method.
35+
4. Estimate the following multiple linear regression model of $mpg_i$ on all other quantitative variables, where $u_i$ is an error term for each observation, using Python's `statsmodels.api.OLS()` function.
36+
\begin{equation*}
37+
\begin{split}
38+
mpg_i &= \beta_0 + \beta_1 cylinders_i + \beta_2 displacement_i + \beta_3 horsepower_i + ... \\
39+
&\qquad \beta_4 weight_i + \beta_5 acceleration_i + \beta_6 year_i + \beta_7 origin_i + u_i
40+
\end{split}
41+
\end{equation*}
42+
* Which of the coefficients is statistically significant at the 1\% level?
43+
* Which of the coefficients is NOT statistically significant at the 10\% level?
44+
* Give an interpretation in words of the estimated coefficient $\hat{\beta}_6$ on $year_i$ using the estimated value of $\hat{\beta}_6$.
45+
5. Looking at your scatterplot matrix from part (2), what are the three variables that look most likely to have a nonlinear relationship with $mpg_i$?
46+
* Estimate a new multiple regression model by OLS in which you include squared terms on the three variables you identified as having a nonlinear relationship to $mpg_i$ as well as a squared term on $acceleration_i$.
47+
* Report your adjusted R-squared statistic. Is it better or worse than the adjusted R-squared from part (4)?
48+
* What happened to the statistical significance of the $displacement_i$ variable coefficient and the coefficient on its squared term?
49+
* What happened to the statistical significance of the cylinders variable?
50+
6. Using the regression model from part (5) and the `.predict()` function, what would be the predicted miles per gallon $mpg$ of a car with 6 cylinders, displacement of 200, horsepower of 100, a weight of 3,100, acceleration of 15.1, model year of 1999, and origin of 1?
51+
```{exercise-end}
52+
```
53+
54+
55+
(SecBasicEmpirFootnotes)=
56+
## Footnotes
57+
58+
The footnotes from this chapter.
59+
60+
[^Auto]: The [`Auto.csv`](https://github.com/OpenSourceEcon/CompMethods/tree/main/data/BasicEmpirMethods/Auto.csv) dataset comes from {cite}`JamesEtAl:2017` (ch. 3) and is also available at http://www-bcf.usc.edu/~gareth/ISL/data.html.

docs/book/caus_inf/intro.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setup(
99
name="CompMethods",
10-
version="0.0.4",
10+
version="0.0.5",
1111
author="Richard W. Evans",
1212
author_email="rickecon@gmail.com",
1313
long_description=readme,

0 commit comments

Comments
 (0)