my-markdown-library 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/F24LS_md/ Lecture 4 - Public.md +347 -0
- data/F24LS_md/Lecture 1 - Introduction and Overview.md +327 -0
- data/F24LS_md/Lecture 10 - Development_.md +631 -0
- data/F24LS_md/Lecture 11 - Econometrics.md +345 -0
- data/F24LS_md/Lecture 12 - Finance.md +692 -0
- data/F24LS_md/Lecture 13 - Environmental Economics.md +299 -0
- data/F24LS_md/Lecture 15 - Conclusion.md +272 -0
- data/F24LS_md/Lecture 2 - Demand.md +349 -0
- data/F24LS_md/Lecture 3 - Supply.md +329 -0
- data/F24LS_md/Lecture 5 - Production C-D.md +291 -0
- data/F24LS_md/Lecture 6 - Utility and Latex.md +440 -0
- data/F24LS_md/Lecture 7 - Inequality.md +607 -0
- data/F24LS_md/Lecture 8 - Macroeconomics.md +704 -0
- data/F24LS_md/Lecture 8 - Macro.md +700 -0
- data/F24LS_md/Lecture 9 - Game Theory_.md +436 -0
- data/F24LS_md/summary.yaml +105 -0
- data/F24Lec_MD/LecNB_summary.yaml +206 -0
- data/F24Lec_MD/lec01/lec01.md +267 -0
- data/F24Lec_MD/lec02/Avocados_demand.md +425 -0
- data/F24Lec_MD/lec02/Demand_Steps_24.md +126 -0
- data/F24Lec_MD/lec02/PriceElasticity.md +83 -0
- data/F24Lec_MD/lec02/ScannerData_Beer.md +171 -0
- data/F24Lec_MD/lec02/demand-curve-Fa24.md +213 -0
- data/F24Lec_MD/lec03/3.0-CubicCostCurve.md +239 -0
- data/F24Lec_MD/lec03/3.1-Supply.md +274 -0
- data/F24Lec_MD/lec03/3.2-sympy.md +332 -0
- data/F24Lec_MD/lec03/3.3a-california-energy.md +120 -0
- data/F24Lec_MD/lec03/3.3b-a-really-hot-tuesday.md +121 -0
- data/F24Lec_MD/lec04/lec04-CSfromSurvey-closed.md +335 -0
- data/F24Lec_MD/lec04/lec04-CSfromSurvey.md +331 -0
- data/F24Lec_MD/lec04/lec04-Supply-Demand-closed.md +519 -0
- data/F24Lec_MD/lec04/lec04-Supply-Demand.md +514 -0
- data/F24Lec_MD/lec04/lec04-four-plot-24.md +34 -0
- data/F24Lec_MD/lec04/lec04-four-plot.md +34 -0
- data/F24Lec_MD/lec05/Lec5-Cobb-Douglas.md +131 -0
- data/F24Lec_MD/lec05/Lec5-CobbD-AER1928.md +283 -0
- data/F24Lec_MD/lec06/6.1-Sympy-Differentiation.md +253 -0
- data/F24Lec_MD/lec06/6.2-3D-utility.md +287 -0
- data/F24Lec_MD/lec06/6.3-QuantEcon-Optimization.md +399 -0
- data/F24Lec_MD/lec06/6.4-latex.md +138 -0
- data/F24Lec_MD/lec06/6.5-Edgeworth.md +269 -0
- data/F24Lec_MD/lec07/7.1-inequality.md +283 -0
- data/F24Lec_MD/lec07/7.2-historical-inequality.md +237 -0
- data/F24Lec_MD/lec08/macro-fred-api.md +313 -0
- data/F24Lec_MD/lec09/lecNB-prisoners-dilemma.md +88 -0
- data/F24Lec_MD/lec10/Lec10.2-waterguard.md +401 -0
- data/F24Lec_MD/lec10/lec10.1-mapping.md +199 -0
- data/F24Lec_MD/lec11/11.1-slr.md +305 -0
- data/F24Lec_MD/lec11/11.2-mlr.md +171 -0
- data/F24Lec_MD/lec12/Lec12-4-PersonalFinance.md +590 -0
- data/F24Lec_MD/lec12/lec12-1_Interest_Payments.md +267 -0
- data/F24Lec_MD/lec12/lec12-2-stocks-options.md +235 -0
- data/F24Lec_MD/lec13/Co2_ClimateChange.md +139 -0
- data/F24Lec_MD/lec13/ConstructingMAC.md +213 -0
- data/F24Lec_MD/lec13/EmissionsTracker.md +170 -0
- data/F24Lec_MD/lec13/KuznetsHypothesis.md +219 -0
- data/F24Lec_MD/lec13/RoslingPlots.md +217 -0
- data/F24Lec_MD/lec15/vibecession.md +485 -0
- data/F24Textbook_MD/00-intro/index.md +292 -0
- data/F24Textbook_MD/01-demand/01-demand.md +152 -0
- data/F24Textbook_MD/01-demand/02-example.md +131 -0
- data/F24Textbook_MD/01-demand/03-log-log.md +284 -0
- data/F24Textbook_MD/01-demand/04-elasticity.md +248 -0
- data/F24Textbook_MD/01-demand/index.md +15 -0
- data/F24Textbook_MD/02-supply/01-supply.md +203 -0
- data/F24Textbook_MD/02-supply/02-eep147-example.md +86 -0
- data/F24Textbook_MD/02-supply/03-sympy.md +138 -0
- data/F24Textbook_MD/02-supply/04-market-equilibria.md +204 -0
- data/F24Textbook_MD/02-supply/index.md +16 -0
- data/F24Textbook_MD/03-public/govt-intervention.md +73 -0
- data/F24Textbook_MD/03-public/index.md +10 -0
- data/F24Textbook_MD/03-public/surplus.md +351 -0
- data/F24Textbook_MD/03-public/taxes-subsidies.md +282 -0
- data/F24Textbook_MD/04-production/index.md +15 -0
- data/F24Textbook_MD/04-production/production.md +178 -0
- data/F24Textbook_MD/04-production/shifts.md +296 -0
- data/F24Textbook_MD/05-utility/budget-constraints.md +166 -0
- data/F24Textbook_MD/05-utility/index.md +15 -0
- data/F24Textbook_MD/05-utility/utility.md +136 -0
- data/F24Textbook_MD/06-inequality/historical-inequality.md +253 -0
- data/F24Textbook_MD/06-inequality/index.md +15 -0
- data/F24Textbook_MD/06-inequality/inequality.md +226 -0
- data/F24Textbook_MD/07-game-theory/bertrand.md +257 -0
- data/F24Textbook_MD/07-game-theory/cournot.md +333 -0
- data/F24Textbook_MD/07-game-theory/equilibria-oligopolies.md +96 -0
- data/F24Textbook_MD/07-game-theory/expected-utility.md +61 -0
- data/F24Textbook_MD/07-game-theory/index.md +19 -0
- data/F24Textbook_MD/07-game-theory/python-classes.md +340 -0
- data/F24Textbook_MD/08-development/index.md +35 -0
- data/F24Textbook_MD/09-macro/CentralBanks.md +101 -0
- data/F24Textbook_MD/09-macro/Indicators.md +77 -0
- data/F24Textbook_MD/09-macro/fiscal_policy.md +36 -0
- data/F24Textbook_MD/09-macro/index.md +14 -0
- data/F24Textbook_MD/09-macro/is_curve.md +76 -0
- data/F24Textbook_MD/09-macro/phillips_curve.md +70 -0
- data/F24Textbook_MD/10-finance/index.md +10 -0
- data/F24Textbook_MD/10-finance/options.md +178 -0
- data/F24Textbook_MD/10-finance/value-interest.md +60 -0
- data/F24Textbook_MD/11-econometrics/index.md +16 -0
- data/F24Textbook_MD/11-econometrics/multivariable.md +218 -0
- data/F24Textbook_MD/11-econometrics/reading-econ-papers.md +25 -0
- data/F24Textbook_MD/11-econometrics/single-variable.md +483 -0
- data/F24Textbook_MD/11-econometrics/statsmodels.md +58 -0
- data/F24Textbook_MD/12-environmental/KuznetsHypothesis-Copy1.md +187 -0
- data/F24Textbook_MD/12-environmental/KuznetsHypothesis.md +187 -0
- data/F24Textbook_MD/12-environmental/MAC.md +254 -0
- data/F24Textbook_MD/12-environmental/index.md +36 -0
- data/F24Textbook_MD/LICENSE.md +11 -0
- data/F24Textbook_MD/intro.md +26 -0
- data/F24Textbook_MD/references.md +25 -0
- data/F24Textbook_MD/summary.yaml +414 -0
- metadata +155 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
---
|
2
|
+
title: value-interest
|
3
|
+
type: textbook
|
4
|
+
source_path: content/10-finance/value-interest.ipynb
|
5
|
+
chapter: 10
|
6
|
+
---
|
7
|
+
|
8
|
+
# Present Value, Future Value, and Interest Rates
|
9
|
+
|
10
|
+
## The Time Value of Money
|
11
|
+
|
12
|
+
An important concept that is the basis for most of finance is the *time value of money*: money now is worth more than money in the future. This makes sense; you would rather have \$100 now than later. But what if I owed you money and I really wanted to postpone the payment? In order to compensate you for your bias toward having money as soon as possible, I would need to pay more than I owed. Otherwise, you might not tolerate a delayed payment. This idea of an extra payment to address time concerns is called *interest*. There is also a dimension of risk as well. If you had reason to doubt my ability to repay you in the future, you might charge me more interest to compensate for this risk.
|
13
|
+
|
14
|
+
```{admonition} Definition
|
15
|
+
**Interest** is payment at a particular rate for the use of money or for delaying the repayment of money. Interest is typically set at a specific rate and that rate fluctuates based on the amount of time between borrowing and repayment, the risk of default, and other factors determined by the lender.
|
16
|
+
```
|
17
|
+
|
18
|
+
## Interest
|
19
|
+
|
20
|
+
Interest is at the heart of loans, fixed income securities (think bonds), and financial economics in general. We are familiar with the bank account: you give a certain amount of money to a financial institution, and they compensate you for allowing them to use your money to invest in other assets. What they pay you for keeping your money is interest, and is normally quantified as a percentage of what you deposit with them - an interest rate. Thus, for each \$1 deposited at the bank, you will receive $r$ dollars in interest, where $r$ is the interest rate quoted by the bank. Note that $r$ takes the form of a decimal value: 0.05, for instance, and not 5%.
|
21
|
+
|
22
|
+
Interest can be paid out in different time intervals - usually monthly, quarterly, yearly or continuously. Also, if you earn some interest in one year, in the next year you will not only earn interest on the initial amount you deposited, but also on the amount you earned the year before. This reflects the idea of *compounding interest*. We are able to determine how much \$1 will be worth in $t$ years, when compounding $n$ times per year at an interest rate of $r$.
|
23
|
+
|
24
|
+
$$\begin{aligned}
|
25
|
+
\text{Value of 1 dollar in } t \text{ years} &= 1 \times \left(1 + \dfrac{r}{n} \right) \times \left(1 + \dfrac{r}{n} \right) \times \cdots \times \left(1 + \dfrac{r}{n} \right) \\
|
26
|
+
&= 1 \left(1 + \dfrac{r}{n} \right)^{nt}
|
27
|
+
\end{aligned}$$
|
28
|
+
|
29
|
+
Take a look at the table below for an example of the effects of compounding.
|
30
|
+
|
31
|
+
| | Bank 1: 5\% annual compounding | Bank 2: 5\% semi-annual compounding |
|
32
|
+
|------------------------|--------------------------------|-----------------------------------------------------------|
|
33
|
+
| January 2016 | \$100 | \$100 |
|
34
|
+
| July 2016 | | $100 \left(1 + \dfrac{0.05}{2} \right) =$ \$102.50 |
|
35
|
+
| January 2017 | $100 (1 + 0.05) =$ \$105 | $102.50 \left(1 + \dfrac{0.05}{2} \right) =$ \$105.0625 |
|
36
|
+
| July 2017 | | $105.0625 \left(1 + \dfrac{0.05}{2} \right) =$ \$107.69 |
|
37
|
+
| January 2018 | $105 (1 + 0.05) =$ \$110.25 | $107.69 \left(1 + \dfrac{0.05}{2} \right) =$ \$110.38 |
|
38
|
+
| Total Percent Change | 10.25% | 10.38% |
|
39
|
+
|
40
|
+
Notice that instead of a $5\% \cdot 2 = 10\%$ increase, you end up receiving a 10.25% or 10.38% increase depending on the rate of compounding. This is because the interest you received in the first compounding period (in bank 1’s case, a year, in bank 2’s case, half a year) is added onto your initial deposit, and this new deposit is used for calculating interest in the next period. Thus, even a small amount of money can grow quickly under interest rate compounding.
|
41
|
+
|
42
|
+
## Present Value, Future Value, and the Discount Factor
|
43
|
+
|
44
|
+
An important related concept is the idea of present and future value (which are effectively opposites). We have already discussed future value above. A \$100 deposit at bank 1 above has a future value of \$110.25 after 2 years. Conversely, an important question frequently asked in finance is the following:
|
45
|
+
|
46
|
+
> Given an amount of money in the future, what is its fair value today?
|
47
|
+
|
48
|
+
In this example, what is the present value of \$110.25 at bank 1 two years in the future? Well, from the table above, \$100! This idea of present value is essential to the pricing of assets. In general, an asset's price is the present value of all expected future payments.
|
49
|
+
|
50
|
+
$$\begin{aligned}
|
51
|
+
\text{FV of 1 dollar} &= 1 \times \left(1 + \dfrac{r}{n} \right)^{nt} \\
|
52
|
+
\text{PV of 1 dollar} &= \dfrac{1}{\left(1 + \dfrac{r}{n} \right)^{nt}}
|
53
|
+
\end{aligned}$$
|
54
|
+
|
55
|
+
We call $\dfrac{1}{(1 + \frac{r}{n})^{nt}}$ a *discount factor*. It discounts the value of \$1 from the future into today. This ties in with the time value of money. Since a dollar today is worth more than a dollar tomorrow, in order for you to be indifferent between receiving money today or tomorrow, the money you would receive tomorrow has to be discounted into the present by some amount that depends on the interest rate.
|
56
|
+
|
57
|
+
$$
|
58
|
+
\text{PV} = \text{DF} \cdot \text{FV}
|
59
|
+
$$
|
60
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
title: index
|
3
|
+
type: textbook
|
4
|
+
source_path: content/11-econometrics/index.md
|
5
|
+
chapter: 11
|
6
|
+
---
|
7
|
+
|
8
|
+
# Econometrics
|
9
|
+
|
10
|
+
One way to think about Econometrics is that it is the closest economists can usually get to doing experiments in the same way experiments are done in medicine and other fields involving people. The idealized experiment is one where people are randomly assigned to either the treatment or control group such that the participants *and* the researchers don't know which group each person is in.
|
11
|
+
|
12
|
+
By randomly assigning a large sample of participants to two different groups, we can be fairly confident that on average the two groups are identical in their attributes, apart from the treatment that only one group receives. By having a double-blind experiment, we can be confident that the participants and researchers aren't conciously or subconciously (placebo effect) affecting the results of the treatment group. Because of this setup, we can look at the difference in outcomes of the two groups and be fairly confident that any differences are due to the treatment and nothing else.
|
13
|
+
|
14
|
+
But it's usually impossible or unethical to perform an ideal experiment in economics. Imagine trying to examine the effect of years of schooling on future earnings. Can you force people into a treatment group with more years of schooling and a control group with less? Is it sufficient to just collect a sample of people and compare the earnings of people with high schooling to those with low schooling?
|
15
|
+
|
16
|
+
How can we answer the above question and others like it? Econometrics. Econometrics is a vast field and today we will just focus on the basics of something called regression.
|
@@ -0,0 +1,218 @@
|
|
1
|
+
---
|
2
|
+
title: multivariable
|
3
|
+
type: textbook
|
4
|
+
source_path: content/11-econometrics/multivariable.ipynb
|
5
|
+
chapter: 11
|
6
|
+
---
|
7
|
+
|
8
|
+
# Multivariable Regression and Bias
|
9
|
+
|
10
|
+
```python
|
11
|
+
import numpy as np
|
12
|
+
import pandas as pd
|
13
|
+
import matplotlib.pyplot as plt
|
14
|
+
import statsmodels.api as sm
|
15
|
+
import warnings
|
16
|
+
warnings.simplefilter("ignore")
|
17
|
+
from mpl_toolkits.mplot3d import Axes3D
|
18
|
+
from matplotlib import patches
|
19
|
+
from datascience import *
|
20
|
+
%matplotlib inline
|
21
|
+
from sklearn.metrics import mean_squared_error
|
22
|
+
from ipywidgets import interact, interactive, fixed
|
23
|
+
import ipywidgets as widgets
|
24
|
+
|
25
|
+
nlsy = Table.read_table('nlsy_cleaned_small.csv')
|
26
|
+
nlsy = nlsy.with_column("college", nlsy.column("college").astype(float))
|
27
|
+
nlsy = nlsy.with_column("AFQT", nlsy.column("AFQT").astype(float))
|
28
|
+
```
|
29
|
+
|
30
|
+
Our procedure earlier showed that we expect to see roughly a 70% increase in earnings in people who went to college vs. people who did not go to college. Does this imply that your decision to go to college was worthwhile, and now you can expect to have roughly 70% higher earnings compared to the version of you who did not go to college?
|
31
|
+
|
32
|
+
Let's go back to our discussion of experiments from earlier. In an ideal experiment, we would want a good sample of people who are about to graduate high school, and then randomly assign them to either a treatment group that gets sent to college, and a control group that does not. If you are in the treatment group you *must* go to college, and if you are in the control group you *cannot* go to college. Since the decision to go to college in this case is completely random, we can safely assume that the treatment and control groups are on average identical in attributes, apart from college attendance. We can therefore compare their log earnings in the future to see the effect of going to college.
|
33
|
+
|
34
|
+
Clearly this experiment is impossible to perform. We cannot randomly assign people to go to college. What's different between this ideal experiment and our regression from earlier? What's the issue with comparing the differences in log earnings for people in our sample who happened to go to college and those who did not?
|
35
|
+
|
36
|
+
In our sample, the treatment (went to college) and control (did not go to college) groups are not identical in every way except for college! People aren't randomly assigned college, they *choose* to go to college. The factors that cause someone to go to college are complex and lead to differences between people who chose to go to college and those who did not. When we perform regression on the variable `college`, since the groups in the sample are different, not only are we capturing the effect of going to college, but we are also capturing the effects of everything else that is different about the two groups that also affects earnings.
|
37
|
+
|
38
|
+
Imagine another variable that captures the wealth of your family. College can be very expensive, so it might be the case that the wealthier your family is, the more likely you are to go to college. Also, it's easy to imagine that the wealthier your family is, the wealthier you are likely to be in the future. This implies that the group of people in the sample who went to college will tend to be wealthier than the group that did not. Also, the group of people who went to college is expected to earn more not necessarily because they went to college, but simply because they are wealthier.
|
39
|
+
|
40
|
+
Therefore, when we do regression to measure the differences in earnings between people who went to college and those who did not, we also capture differences in earnings between people who grew up wealthier and those who did not. Because of this, we *over-estimate* the effect of going to college. $\hat{\beta}$ captures the average observed benefit of going to college *and* being wealthier, but we're only interested in college. This is called *omitted variable bias*. Family wealth is an omitted variable in this regression and it's causing our results to be biased.
|
41
|
+
|
42
|
+
Let's think of another example of omitted variable bias. In the NLSY dataset, there is a variable called `AFQT`. AFQT is a score on a particular standardized test that all people in the sample took. Let's use AFQT as a proxy measurement for the abstract idea of academic capability. While a standardized test is by no means the sole indication of someone's ability or intelligence, let's ignore that very complicated issue for now and assume that AFQT does an O.K. job at capturing this ability variable that is otherwise very difficult to measure.
|
43
|
+
|
44
|
+
Is there omitted variable bias from AFQT? Almost certainly. It seems fair to believe that people who choose to go to college are on average more academically-capable, and it also seems fair to say that on average we expect more capable people to earn more. Therefore, $\hat{\beta}$ above might be capturing the effects of being more capable, along with the effects of going to college.
|
45
|
+
|
46
|
+
How can we fix this issue? Multivariable regression.
|
47
|
+
|
48
|
+
## Multivariable Regression
|
49
|
+
|
50
|
+
So far we have only been regressing outcome variable $y$ onto one explanatory variable $x$. To find the regression line, we choose $\hat{\alpha}$ and $\hat{\beta}$ that minimize the mean squared error. But what if we believe that $y$ is actually determined by two variables, $x_1$ and $x_2$? Specifically, what if the "true" model is
|
51
|
+
|
52
|
+
$$
|
53
|
+
y = \alpha + \beta_1 x_{1} + \beta_2 x_{2} + \epsilon
|
54
|
+
$$
|
55
|
+
|
56
|
+
and we would like to estimate
|
57
|
+
|
58
|
+
$$
|
59
|
+
\hat{y} = \hat{\alpha} + \hat{\beta}_1 x_{1} + \hat{\beta}_2 x_{2}
|
60
|
+
$$
|
61
|
+
|
62
|
+
Now our challenge is choosing $\hat{\alpha}$, $\hat{\beta}_1$, *and* $\hat{\beta}_2$ that minimize the mean squared error. To this end, we will use the `minimize` function to minimize a function `to_minimize` that takes in model parameters and returns the model's RMSE.
|
63
|
+
|
64
|
+
```python
|
65
|
+
def rmse(target, pred):
|
66
|
+
return np.sqrt(mean_squared_error(target, pred))
|
67
|
+
|
68
|
+
def to_minimize(intercept, beta_1, beta_2):
|
69
|
+
predictions = intercept + beta_1 * nlsy.column('college') + beta_2 * nlsy.column("AFQT")
|
70
|
+
actual = nlsy.column('log_earn_1999')
|
71
|
+
return rmse(predictions, actual)
|
72
|
+
|
73
|
+
minimize(to_minimize)
|
74
|
+
```
|
75
|
+
|
76
|
+
We see that `minimize` return an $\hat{\alpha}$ of 9.956, a $\hat{\beta}_1$ of 0.430, and a $\hat{\beta}_2$ of 0.008. Let's perform the regression using `statsmodels` and see what we get.
|
77
|
+
|
78
|
+
```python
|
79
|
+
y = nlsy.select('log_earn_1999').values
|
80
|
+
X = nlsy.select('college', 'AFQT').values
|
81
|
+
|
82
|
+
model = sm.OLS(y, sm.add_constant(X)).fit()
|
83
|
+
model.summary()
|
84
|
+
```
|
85
|
+
|
86
|
+
Here $\hat{\beta}_1$ is 0.43, compared to 0.72 from the earlier biased (single variable) regression. That's huge! This implies that when we control for a person's ability (i.e. we get rid of that source of bias), we only see that on average going to college is associated with a 43% increase in earnings instead of 72%. Furthermore, looking at the 95% confidence interval for $\hat{\beta}_2$, we see that it does not contain 0, which would imply that AFQT score has a strong non-zero association with earnings.
|
87
|
+
|
88
|
+
These observations validate our claim that AFQT was probably an omitted variable causing $\hat{\beta}_1$ to be biased. When interpreting $\hat{\beta}$ coefficients, you should always be mindful of potential sources of bias that could make your coefficients misleading and not useful from an econometric context.
|
89
|
+
|
90
|
+
**Note:** A linear regression model makes predictions for $y$ which we've been calling $\hat{y}$. If you imagine that you are the model and are tasked with predicting people's earnings, you will almost certainly want more than just their years of schooling to make an accurate prediction. The more relevant variables you are given, the better predictions you are likely to make compared to just using one variable. The Variable needs to be relevant though; the day of the week a person was born on is probably not useful in predicting earnings. This is just another way of thinking about the usefulness of multivariable regression.
|
91
|
+
|
92
|
+
### Visualizing Multivariable Regression
|
93
|
+
|
94
|
+
The 3D plots below show us our variables of interest and the regression plane from two different angles.
|
95
|
+
|
96
|
+
```python
|
97
|
+
ax = plt.figure(figsize=(8,8)).add_subplot(111, projection='3d')
|
98
|
+
ax.scatter(nlsy.column("AFQT"),
|
99
|
+
nlsy.column("college"),
|
100
|
+
nlsy.column('log_earn_1999'))
|
101
|
+
plt.xlabel("AFQT", fontsize=14)
|
102
|
+
plt.ylabel("college", fontsize=14)
|
103
|
+
ax.set_zlabel("log_earn_1999", fontsize=14)
|
104
|
+
plt.title("Data Points", pad=30, size=20);
|
105
|
+
```
|
106
|
+
|
107
|
+
Scatter plot in 3D showing data points related to AFQT, college, and log_earn_1999.
|
108
|
+
|
109
|
+
```python
|
110
|
+
X,Y = np.meshgrid(np.arange(0,100,1), np.arange(0,1,0.01))
|
111
|
+
Z = 0.0084 * X + 0.4301 * Y + 9.9563
|
112
|
+
ax = plt.figure(figsize=(8,8)).add_subplot(111, projection='3d')
|
113
|
+
ax.scatter(nlsy.column("AFQT"),
|
114
|
+
nlsy.column("college"),
|
115
|
+
nlsy.column('log_earn_1999'))
|
116
|
+
ax.plot_surface(X, Y, Z, alpha=0.5)
|
117
|
+
plt.xlabel("AFQT", fontsize=14)
|
118
|
+
plt.ylabel("college", fontsize=14)
|
119
|
+
ax.set_zlabel("log_earn_1999", fontsize=14)
|
120
|
+
plt.title("Data Points + Regression Plane", pad=30, size=20);
|
121
|
+
```
|
122
|
+
|
123
|
+
Scatter plot in 3D with a visible regression plane. Data points are related to AFQT, college, and log_earn_1999. Regression plane represented by a surface.
|
124
|
+
|
125
|
+
```python
|
126
|
+
X,Y = np.meshgrid(np.arange(0,1,0.01), np.arange(0,100,1))
|
127
|
+
Z = 0.4301 * X + 0.0084 * Y + 9.9563
|
128
|
+
ax = plt.figure(figsize=(8,8)).add_subplot(111, projection='3d')
|
129
|
+
ax.scatter(nlsy.column("college"),
|
130
|
+
nlsy.column("AFQT"),
|
131
|
+
nlsy.column('log_earn_1999'))
|
132
|
+
ax.plot_surface(X, Y, Z, alpha=0.1)
|
133
|
+
plt.ylabel("AFQT", fontsize=14)
|
134
|
+
plt.xlabel("college", fontsize=14)
|
135
|
+
ax.set_zlabel("log_earn_1999", fontsize=14)
|
136
|
+
plt.title("Data Points + Regression Plane", pad=30, size=20);
|
137
|
+
```
|
138
|
+
|
139
|
+
Scatter plot in 3D with a rotated view of data points related to college, AFQT, and log_earn_1999. Regression plane represented by a semi-transparent surface.
|
140
|
+
|
141
|
+
The regression plane, instead of the regression line, represents the values for log earnings that the regression model would predict for any given college and AFQT input. It's a plane now because there are two possible inputs, as opposed to one.
|
142
|
+
|
143
|
+
## Colinearity and Dummy Variables
|
144
|
+
|
145
|
+
When we do regression onto the variable `college`, why don't we also include a variable that measures not going to college? In other words, why don't we regress on college and the opposite of college so that way we can get an estimate of the average earnings of college-goers and non-college-goers. Why do we do this roundabout way of using the intercept term and a difference in means?
|
146
|
+
|
147
|
+
Imagine we have a dataset with a variable for college, a variable for not going to college, and the intercept term. The issue with this is that there is now redundant information.
|
148
|
+
|
149
|
+
Let's look at just one element of the sample. Let's say this person went to college, so this person's features are the following:
|
150
|
+
* College = 1
|
151
|
+
* Not College = 0
|
152
|
+
* Intercept term = 1
|
153
|
+
|
154
|
+
Clearly there is a redundancy here; you can guess one of the variables from the others. More specifically, by redundancy we mean that *one variable can be written as a linear combination of the other variables*. In fact, there are three different combinations:
|
155
|
+
* Intercept = College + Not College
|
156
|
+
* Not College = Intercept - College
|
157
|
+
* College = Intercept - Not College
|
158
|
+
|
159
|
+
These equalities aren't just true for this one person; they actually hold true for any possible person in the sample. This is because of the way we defined "college" and "not college". You can't simultaneously be in both, and so adding them together you get 1, which is just the intercept term.
|
160
|
+
|
161
|
+
In general, we have redundancy whenever we have *mutually exclusive* and *exhaustive* dummy variables in combination with an intercept term.
|
162
|
+
* Mutually exclusive: You cannot be in more than one dummy variable.
|
163
|
+
* Exhaustive: You must be in at least one dummy variable.
|
164
|
+
|
165
|
+
You can see that "college" and "not college" satisfy these conditions. So why is this redundancy an issue? It becomes ambiguous what the values for $\hat{\alpha}$, $\hat{\beta}_1$, and $\hat{\beta}_2$ should be in the model where we include all three terms:
|
166
|
+
|
167
|
+
$$
|
168
|
+
\text{log earnings} = \hat{\alpha} + \hat{\beta}_1 \text{college} + \hat{\beta}_2 \text{not college}
|
169
|
+
$$
|
170
|
+
|
171
|
+
Consider a case where we expect people who went to college to have log earnings of 10 and those who did not go to college to have log earnings of 8. What values for $\hat{\beta}$ and $\hat{\alpha}$ make sense?
|
172
|
+
|
173
|
+
* $\hat{\beta}_1 = 10$
|
174
|
+
* $\hat{\beta}_2 = 8$
|
175
|
+
* $\hat{\alpha} = 0$
|
176
|
+
|
177
|
+
make sense. These are valid values for $\hat{\beta}$ and $\hat{\alpha}$ that satisfy the condition above. To see why, consider a person with college:
|
178
|
+
|
179
|
+
$$\begin{aligned}
|
180
|
+
\text{log earnings} &= \hat{\alpha} + \hat{\beta}_1 \cdot 1 + \hat{\beta}_2 \cdot 0 \\
|
181
|
+
\text{log earnings} &= \hat{\alpha} + \hat{\beta}_1 \\
|
182
|
+
\text{log earnings} &= 0 + 10 = 10
|
183
|
+
\end{aligned}$$
|
184
|
+
|
185
|
+
and a person without college:
|
186
|
+
|
187
|
+
$$\begin{aligned}
|
188
|
+
\text{log earnings} &= \hat{\alpha} + \hat{\beta}_1 \cdot 0 + \hat{\beta}_2 \cdot 1 \\
|
189
|
+
\text{log earnings} &= \hat{\alpha} + \hat{\beta}_2 \\
|
190
|
+
\text{log earnings} &= 0 + 8 = 8
|
191
|
+
\end{aligned}$$
|
192
|
+
|
193
|
+
* $\hat{\beta}_1 = 2$
|
194
|
+
* $\hat{\beta}_2 = 0$
|
195
|
+
* $\hat{\alpha} = 8$
|
196
|
+
|
197
|
+
also make sense. To see why, consider a person with college:
|
198
|
+
|
199
|
+
$$\begin{aligned}
|
200
|
+
\text{log earnings} &= \hat{\alpha} + \hat{\beta}_1 \cdot 1 + \hat{\beta}_2 \cdot 0 \\
|
201
|
+
\text{log earnings} &= \hat{\alpha} + \hat{\beta}_1 \\
|
202
|
+
\text{log earnings} &= 8 + 2 = 10
|
203
|
+
\end{aligned}$$
|
204
|
+
|
205
|
+
and a person without college:
|
206
|
+
|
207
|
+
$$\begin{aligned}
|
208
|
+
\text{log earnings} &= \hat{\alpha} + \hat{\beta}_1 \cdot 0 + \hat{\beta}_2 \cdot 1 \\
|
209
|
+
\text{log earnings} &= \hat{\alpha} + \hat{\beta}_2 \\
|
210
|
+
\text{log earnings} &= 8 + 0 = 8
|
211
|
+
\end{aligned}$$
|
212
|
+
|
213
|
+
It turns out, there are actually infinitely many solutions for $\hat{\beta}$ that satisfy the condition where people who went to college have mean log earnings of 10 and people who did not go to college have mean log earnings of 8. This holds true for all situations where you regress on a constant and a set of mutually exclusive and exhaustive dummies. There is no unique solution for $\hat{\beta}$, which is a problem for econometricians who want unique and interpretable coefficients.
|
214
|
+
|
215
|
+
In fact, there is mathematical justification for this as well. At some point in the math involved in performing regression, having redundant variables causes a division by 0. This is particularly upsetting for your computer, and it will complain.
|
216
|
+
|
217
|
+
So how do we avoid this problem? We deliberately exclude one of the variables. It can technically either be one of the dummy variables or the intercept term, but we usually really want to have an intercept term present in our regression for other reasons. So we usually get rid of one of the dummy variables. Notice that we implicitly did this earlier. We did not include "not college" in our first regression.
|
218
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
---
|
2
|
+
title: reading-econ-papers
|
3
|
+
type: textbook
|
4
|
+
source_path: content/11-econometrics/reading-econ-papers.ipynb
|
5
|
+
chapter: 11
|
6
|
+
---
|
7
|
+
|
8
|
+
# Reading Economics Papers
|
9
|
+
|
10
|
+
In upper division economics courses, you'll often read economics papers that utilize ordinary least squares to conduct regression. Now that we have familiarized ourselves with multi-variate regression, let's familiarize ourselves with reading the results of economics papers!
|
11
|
+
|
12
|
+
Let's consider an existing empirical study conducted by David Card {cite}`11reading-econ-papers`, a Nobel Prize winning professor at UC Berkeley, that regresses income on education:
|
13
|
+
|
14
|
+

|
15
|
+
|
16
|
+
Every column here is from a different regression: the first column predicts the log hourly earnings from years of education, the fifth column predicts the log annual earnings from years of education, and so on. For now, let's focus on the first column, which states the linear regression as follows:
|
17
|
+
|
18
|
+
$$
|
19
|
+
\ln{(\text{hourly earnings})_i} = \alpha + \beta \cdot (\text{years of schooling})_i + \varepsilon_i
|
20
|
+
$$
|
21
|
+
|
22
|
+
From the table, the education coefficient is 0.100, with a (0.001) underneath it. This means that our $\beta$ value is equal to 0.100. What does the (0.001) mean? It is the standard error, which is essentially a measure of our uncertainty. From Data 8, the standard error is most similar to the standard deviation of sample means, which is a measure of the spread in the population mean. Similarly, the the standard error here is a measure of the spread in the population coefficient. We can use the standard error to construct a confidence interval of the actual coefficient: a 95% confidence interval is between 2 standard errors above and below the reported value.
|
23
|
+
|
24
|
+
The effects of schooling on income is captured by the education coefficient term: 0.100. This means that an increase in 1 unit (year) of education is correlated with a log hourly earnings by 0.1. This approximately corresponds to a 10% increase in wages per year of schooling.
|
25
|
+
|