Uploaded by Nick Brown


Problem set 1
Jason Parker
In this problem set, the data sets are available as tables in the wooldridge2.db file. You can find out how to connect
to databases in chapter 2 section of my book. I have also uploaded a wpull function in my startup_script.R
code which can be used to pull particular tables from the database (if you are in the right working directory–hint).
Your solution should have the code you used in a .txt file with the answers as comments. Please format your code
neatly in some way similar to the example that I have posted in box.
Question 1
Use the data in the wage1 table for this exercise.
1. Find the average education level in the sample. What are the lowest and highest years of education?
wage1 <- wpull('wage1')
#Average is 12.56
#Lowest is 0
#Highest is 18
2. Find the average hourly wage in the sample. Does it seem high or low?
#Average is 5.91, which seems low
3. The wage data are reported in 1976 dollars. Using the Economic Report of the President (2011 or later),
obtain and report the Consumer Price Index (CPI) for the years 1976 and 2010
#CPI for 1976 was 56.9
#CPI for 2010 was 218.1
4. Use the CPI values from above to find the average hourly wage in 2010 dollars. Now does the average hourly
wage seem reasonable?
#22.65 per hour, which seems reasonable
5. How many women are in the sample? How many men?
#252 female, 274 male
Question 2
The data in meap01 table are for the state of Michigan in the year 2001. Use these data to answer the following
1. Find the largest and smallest values of math4. Does the range make sense? Explain.
meap01 <- wpull('meap01')
#Largest 100
#Smallest 0
#Makes sense because it indicates the maximum and minimum possible scores
2. How many schools have a perfect pass rate on the math test? What percentage is this of the total sample?
# 38 schools scored perfectly, which is ~2% of the sample size
3. How many schools have math pass rates of exactly 50%?
# 17
4. Compare the average pass rates for the math and reading scores. Which test is harder to pass?
#Math 71.9 vs Reading 60.1. Reading seems to be harder.
5. Find the correlation between math4 and read4. What do you conclude?
#.84, which a high correlation
6. The variable exppp is expenditure per pupil. Find the average of exppp along with its standard deviation.
Would you say there is wide variation in per pupil spending?
#Average is $5,194, with a stdev of $1,092. Seems like a reasonable variation.
7. Suppose School A spends $6000 per student and School B spends $5500 per student. By what percentage
does School A’s spending exceed School B’s? Compare this to 100 ∗ [ln(6000) − ln(5500)], which is the
approximation percentage difference based on the difference in the natural logs.
#Actual 9.1% vs Log 8.7%, .4% difference
Question 3
The data in 401k are a subset of data analyzed by Papke (1995) to study the relationship between participation in a
401(k) pension plan and the generosity of the plan. The variable prate is the percentage of eligible workers with an
active account; this is the variable we would like to explain. The measure of generosity is the plan match rate, mrate.
This variable gives the average amount the firm contributes to each worker’s plan for each $1 contribution by the
worker. For example, if mrate = 0.50, then a $1 contribution by the worker is matched by a 50? contribution by the
1. Find the average participation rate and the average match rate in the sample of plans.
k401<- wpull('401k')
#Average prate 87.4%
#Average mrate 73.2%
2. Now, estimate the simple regression equation:
prateˆ = β 0 + β 1mrate,
and report the results along with the sample size and R-squared.
model <- lm(prate~mrate,data=k401)
#Estimated prate=83.1+5.86mrate
#Sample size=1,532, R^2=.075
3. Interpret the intercept in your equation. Interpret the coefficient on mrate.
The intercept implies that if the mrate=0, then the predicted prate is 83.1%. The coefficient of mrate shows
that for every 1% increase in mrate, the prate increases by 5.86%.
4. Find the predicted prate when mrate = 3.5. Is this a reasonable prediction? Explain what is happening here.
This predicts a prate of 103.59%. Obviously this doesn’t work because the max can only be 100%. Because
this is a simple regression model, extreme values can give unrealistic predictions.
5. How much of the variation in prate is explained by mrate?
#The R^2 is only 7.5%, which means the mrate has very low influence on the model. There's likely other
factors that better explain prate.
Question 4
The data set in ceosal2 contains information on chief executive officers for U.S. corporations. The variable salary is
annual compensation, in thousands of dollars, and ceoten is prior number of years as company CEO.
1. Find the average salary and the average tenure in the sample.
ceosal2 <- wpull('ceosal2')
#Average salary is $865,900. Average tenure is 7.955 years.
2. How many CEOs are in their first year as CEO (that is, ceoten = 0)? What is the longest tenure as a CEO?
#5 CEOs in the first year. Longest tenure is 37 years.
3. Estimate the simple regression model
ln[salary] = β0 + β1ceoten + u
and report your results in the usual form. What is the (approximate) predicted percentage increase in salary
given one more year as a CEO?
#6.505498+.009724(ceoten). 1 year of CEO tenure is associated with .97% increase in pay.
Question 5
Use the data in wage2 to estimate a simple regression explaining monthly salary (wage) in terms of IQ score
1. Find the average salary and average IQ in the sample. What is the sample standard deviation of IQ? (IQ scores
are standardized so that the average in the population is 100 with a standard deviation equal to 15.)
wage2<- wpull('wage2')
#Average salary $957.95. Average IQ 101. Stdev 15.05.
2. Estimate a simple regression model where a one-point increase in IQ changes wage by a constant dollar
amount. Use this model to find the predicted increase in wage for an increase in IQ of 15 points. Does IQ
explain most of the variation in wage?
#15 point increase in IQ is associated with $124.50 increase in salary. The R^2 is only .0955, which means
IQ isn't a very good predictor of salary.
3. Now, estimate a model where each one-point increase in IQ has the same percentage effect on wage. If IQ
increases by 15 points, what is the approximate percentage increase in predicted wage?
#13.2% increase per 15 IQ points
Question 6
Using the meap93 data, we want to explore the relationship between the math pass rate (math10) and spending
per student (expend).
1. Do you think each additional dollar spent has the same effect on the pass rate, or does a diminishing effect
seem more appropriate? Explain.
#Diminishing effect makes more sense. As you get closer to 100% pass rates, it becomes more difficult to see
the same incremental improvements.
2. In the population model, math10 = β0 + β1 ln[expend] + u argue that β1/10 is the percentage point change in
math10 given a 10% increase in expend.
#In this model, b1=11.164. Because logs are in percentages, b1/10 can also be notated as b1*10%. Hence b1/10
is associated with a 10% increase in expend.
3. Estimate this model. Report the estimated equation in the usual way, including the sample size and Rsquared.
#math10=-69.341+11.164*log(expend). Sample size is 408, and the R^2 is .02966.
4. How big is the estimated spending effect? Namely, if spending increases by 10%, what is the estimated
percentage point increase in math10?
#There is a 1.12% increase in math10.
5. One might worry that regression analysis can produce fitted values for math10 that are greater than 100.
Why is this not much of a worry in this data set?
#The max math10 in the dataset is 66.7, which means it's highly unlikely that 100+ scores would occur.
Question 7
Use the data in hprice1 to estimate the model
price = β0 + β1sqrft + β2bdrms + u,
where price is the house price measured in thousands of dollars.
1. Write out the results in equation form.
hprice1 <- wpull('hprice1')
What is the estimated increase in price for a house with one more bedroom, holding square footage
#One more bedroom is associated with an increase of 15.2%
What is the estimated increase in price for a house with an additional bedroom that is 140 square feet in
size? Compare this to your answer from above.
(140*.12844) +15.19819
#One more bedroom and 140 additional sq ft is associated with an increase of 33.18.
What percentage of the variation in price is explained by square footage and number of bedrooms?
#The R^2 is .6319, so 63.2% of price variation is associated with bedrooms and square feet.
The first house in the sample has sqrft = 2438 and bdrms = 4. Find the predicted selling price for this house
from the OLS regression line.
#The associated price is $354,614.50
The actual selling price of the first house in the sample was $300000 (so price = 300). Find the residual for this
house. Does it suggest that the buyer underpaid or overpaid for the house?
#The residual was $54,614.50, which means the buyer underpaid.
Question 8
The file ceosal2 contains data on 177 chief executive officers and can be used to examine the effects of firm
performance on CEO salary.
1. Estimate a model relating annual salary to firm sales and market value. Make the model of the constant
elasticity variety for both independent variables. Write the results out in equation form.
ceosal2 <- wpull('ceosal2')
Log(salary) = 4.62092 + 0.1621log(sales) + 0.1067log(mktval)
2. Add profits to the model. Why can this variable not be included in logarithmic form? Would you say that
these firm performance variables explain most of the variation in CEO salaries?
#Profits can be negative, so they won't work in log form. R^2 is .2993, so there is another ~70% associated
with other factors.
3. Now also add the variable ceoten to the model. What is the estimated percentage return for another year of
CEO tenure, holding other factors fixed?
#One year increase in CEO tenure is associated with 1.17% in pay.
4. Find the sample correlation coefficient between the variables log(mktval) and profits. Are these variables
highly correlated? What does this say about the OLS estimators?
#They are 77.7% correlated to each other, which is a high correlation. Since they are highly correlated, there's
a risk of multi-collinearity. It could be difficult to understand their independent effects.
Question 9
Use the data in attend for this exercise. Create the variable atndrte which is attend/32 because there were 32
1. Obtain the minimum, maximum, and average values for the variables atndrte, priGPA, and ACT.
attend <- wpull('attend')
attend$atndrte <- attend$attend/32
#atndrte- Min .0625, Max 1.0, Avg .8171
#priGPA- Min .857, Max 3.93, Avg 2.587
#ACT- Min 13, Max 32, Avg 22.51
2. Estimate the model
atndrte = β0 + β1GPA + β2ACT + u
and write the results in equation form. Interpret the intercept. Does it have a useful meaning?
#.757 + .17261 priGPA – .01717 ACT
#If priGPA and ACT is 0, attendance is associated with 75.7%, which wouldn’t make sense.
3. Discuss the estimated slope coefficients. Are there any surprises?
#The attendance shows to go down by 1.7% for every point increase in ACT scores, which is surprising.
4. What is the predicted atndrte if priGPA = 3.65 and ACT = 20? What do you make of this result? Are there any
students in the sample with these values of the explanatory variables?
0.7570 + (0.1726*3.65)- (0.0172*20)
#Predicted value is 104.3%. This is greater than 100%, which isn't possible.
nrow(attend[priGPA==3.65 & ACT==20])
#There's one student with these values.
5. If Student A has priGPA = 3.1 and ACT = 21 and Student B has priGPA = 2.1 and ACT = 26, what is the
predicted difference in their attendance rates?
0.7570 + (0.1726*3.1) - (0.0172*21)
0.7570 + (0.1726*2.1) - (0.0172*26)
#Student A is predicted at .93086 and Student B is .67226
#The predicted difference is .2586
Question 10
Use the data in htv to answer this question. The data set includes information on wages, education, parents’
education, and several other variables for 1,230 working men in 1991.
1. What is the range of the educ variable in the sample? What percentage of men completed 12th grade but no
higher grade? Do the men or their parents have, on average, higher levels of education?
htv <- wpull('htv')
#Min is 6 and Max is 20
#41.6% completed 12th grade.
#On average, men have higher eduction than their parents.
2. Estimate the regression model
educ = β0 + β1motheduc + β2fatheduc + u
by OLS and report the results in the usual form. How much sample variation in educ is explained by parents’
education? Interpret the coefficient on motheduc.
#6.96435 + 0.30420motheduc + 0.19029fatheduc
#24.93% is explained by mother and father's education
#Motheduc's coefficient is .30420, which means that every year of mother's education the men's
education is associated with a 30.4% increase.
3. Add the variable abil (a measure of cognitive ability) to the regression above, and report the results in
equation form. Does ability help to explain variations in education, even after controlling for parents’
education? Explain.
#8.44869 + 0.18913 motheduc + 0.11109 fatheduc + 0.50248 abil
#R^2 is .4275, which is much higher than the previous model. This implies that cognitive is a significant
factor, even with the parents' education being factored in.
4. Now estimate an equation where abil appears in quadratic form:
educ = β0 + β1motheduc + β2fatheduc + β3abil + β4abil2 + u.
With the estimated coefficients on ability, use calculus to find the value of abil where educ is minimized.
(The other coefficients and values of parents’ education variables have no effect; we are holding parents’
education fixed.) Notice that abil is measured so that negative values are permissible. You might also verify
that the second derivative is positive so that you do indeed have a minimum.
#b0 +b1 motheduc +b2 fatheduc +b3 abil +b4abil^2 +u
#d educ/ d abil = b3 + 2b4abil
#0.4015 + 2*0.0506abil = 0
#abil = - 3.9674
5. Argue that only a small fraction of men in the sample have ability less than the value calculated above. Why is
this important?
#1.2% of men have an ability less than -3.97. We do not have enough data points for this ability level.
6. Use the estimates above to plot the relationship between the predicted education and abil. Let motheduc
and fatheduc have their average values in the sample, 12.18 and 12.45, respectively.
scale_x_continuous('Cognitive Ability')+
scale_y_continuous('Years of Education')