Please read the instructions for completing homeworks.
Concepts
Question 1
In your own words, describe what the “dummy variable trap” means. What precisely is the problem, and what is the standard way to prevent it?
Theory Problems
For the following questions, please show all work and explain answers as necessary. You may lose points if you only write the correct answer. You may use R
to verify your answers, but you are expected to reach the answers in this section “manually.”
Question 5
Suppose data on many countries’ legal systems (Common Law or Civil Law) and their GDP per capita gives us the following summary statistics:
Legal System | Avg. GDP Growth Rate | Std. dev. | |
---|---|---|---|
Common Law | |||
Civil Law | |||
Difference |
Part A
Using the group means, write a regression equation for a regression of GDP Growth rate on Common Law. Define
Part B
How do we use the regression to find the average GDP Growth rate for common law countries? For civil law countries? For the difference?
Question 6
Suppose a real estate agent collects data on houses that have sold in a particular neighborhood over the past year, with the following variables:
Variable | Description |
---|---|
price of house (in thousands of $) | |
number of bedrooms in house | |
number of bathrooms in house | |
Part B
Write out two separate regression equations, one for houses with a nice view, and one for homes without a nice view. Explain each coefficient in each regression.
Part D
Find the expected price for:
- a house with no pool and no view
- a house with no pool and a view
- a house with a pool and without a view
- a house with a pool and with a view
Question 7
Suppose we want to examine the change in average global temperature over time. We have data on the deviation in temperature from pre-industrial times (in degrees Celcius) for each year .
Part A
Suppose we estimate the following simple model relating deviation in temperature to year:
Interpret the coefficient on Year (i.e.
Part C
Suppose we believe temperature deviations are increasing at an increasing rate, and introduce a quadratic term and estimate the following regression model:
What is the marginal effect on (deviation in) global temperature of one additional year elapsing?
Question 8
Suppose we want to examine the effect of cell phone use while driving on traffic fatalities. While we cannot measure the amount of cell phone activity while driving, we do have a good proxy variable, the number of cell phone subscriptions (in 1000s) in a state, along with traffic fatalities in that state.
Part A
Suppose we estimate the following simple regression:
Interpret the coefficient on cell plans (i.e.
Part B
Now suppose we estimate the regression using a linear-log model:
Interpret the coefficient on ln(cell plans) (i.e.
Part C
Now suppose we estimate the regression using a log-linear model:
Interpret the coefficient on cell plans (i.e.
Part D
Now suppose we estimate the regression using a log-log model:
Interpret the coefficient on cell plans (i.e.
Part E
Suppose we include several other variables into our regression and want to determine which variable(s) have the largest effects, a State’s cell plans, population, or amount of miles driven. Suppose we decide to standardize the data to compare units, and we get:
Interpret the coefficients on cell plans, population, and miles driven. Which has the largest effect on fatalities?
R Questions
Answer the following questions using R
. When necessary, please write answers in the same document (knitted Rmd
to html
or pdf
, typed .doc(x)
, or handwritten) as your answers to the above questions. Be sure to include (email or print an .R
file, or show in your knitted markdown
) your code and the outputs of your code with the rest of your answers.
Question 9
Lead is toxic, particularly for young children, and for this reason government regulations severely restrict the amount of lead in our environment. In the early part of the 20th century, the underground water pipes in many U.S. cities contained lead, and lead from these pipes leached into drinking water. This exercise will have you investigate the effect of these lead pipes on infant mortality. This dataset contains data on:
Variable | Description |
---|---|
infrate |
infant mortality rate (deaths per 100 in population) |
lead |
if city has lead water pipes, if did not have lead pipes |
pH |
water pH |
and several demographic variables for 172 U.S. cities in 1900.
Part A
Using R
to examine the data, find the average infant mortality rate for cities with lead pipes and for cities without lead pipes. Calculate the difference, and run a -test to determine if this difference is statistically significant.
Part B
Run a regression of infrate
on lead
, and write down the estimated regression equation. Use the regression coefficients to find:
- the average infant mortality rate for cities with lead pipes
- the average infant mortality rate for cities without lead pipes
- the difference between the averages for cities with or without lead pipes
Part C
Does the pH of the water matter? Include ph
in your regression from part B. Write down the estimated regression equation, and interpret each coefficient (note there is no interaction effect here). What happens to the estimate on lead
?
Part D
The amount of lead leached from lead pipes normally depends on the chemistry of the water running through the pipes: the more acidic the water (lower pH), the more lead is leached. Create an interaction term between lead and pH, and run a regression of infrate
on lead
, pH
, and your interaction term. Write down the estimated regression equation. Is this interaction significant?
Part E
What we actually have are two different regression lines. Visualize this with a scatterplot between infrate
and ph
color
ed by lead
[Hint: make sure lead
is a factor
variable].
Part F
Do the two regression lines have the same intercept? The same slope? Use the original regression in part D to test these possibilities.
Part G
Take your regression equation from part D and rewrite it as two separate regression equations (one for no lead and one for lead). Interpret the coefficients for each.
Question 10
Let’s look at economic freedom and GDP per capita using some data I sourced from Gapminder1, Freedom House2 and Fraser Institute Data3 and cleaned up for you, with the following variables:
Variable | Description |
---|---|
Country |
Name of country |
ISO |
Code of country (good for plotting) |
econ_freedom |
Economic Freedom Index score (2016) from 1 (least) to 10 (most free) |
pol_freedom |
Political freedom index score (2018) from 1 (least) top 10 (most free) |
gdp_pc |
GDP per capita (2018 USD) |
continent |
Continent of country |
Part A
Does economic freedom affect GDP per capita? Create a scatterplot of gdp_pc
(y
) against econ_freedom
(x
). Does the effect appear to be linear or nonlinear?
Part B
Run a simple regression of gdp_pc
on econ_freedom
. Write out the estimated regression equation. What is the marginal effect of econ_freedom
on gdp_pc
?
Part C
Let’s try a quadratic model. Run a quadratic regression of gdp_pc
on econ_freedom
. Write out the estimated regression equation.
Part F
As a quadratic model, this relationship should predict anecon_freedom
score where gdp_pc
is at a minimum. What is that minimum Economic Freedom score, and what is the associated GDP per capita?
Part G
Run a cubic model to see if we should keep going up in polynomials. Write out the estimated regression equation. Should we add a cubic term?
Part H
Another way we can test for non-linearity is to run an -test on all non-linear variables - i.e. the quadratic term and the cubic term and ) and test against the null hypothesis that:
Run this joint hypothesis test, and what can you conclude?
Part I
Instead of a polynomial model, try out a logarithmic model. It is hard to interpret percent changes on an index, but it is easy to understand percent changes in GDP per capita, so run a log-linear regression. Write out the estimated regression equation. What is the marginal effect of econ_freedom
?