0% found this document useful (0 votes)
925 views4 pages

Wooldridge - Computer Exercises, Chapter 3, C3, C9, C12

The document contains analysis of data from various datasets to understand relationships between variables. For a dataset of CEO salaries, adding variables like company profits and CEO tenure explained slightly more variation in salaries. For a charity donation dataset, adding variables like past donations and response rate explained more variation in donations than a single variable model. For a student exam scores dataset, a model using GPA, ACT math and English scores explained around 40% of the variation in exam scores, with ACT math having a larger effect than ACT English.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
925 views4 pages

Wooldridge - Computer Exercises, Chapter 3, C3, C9, C12

The document contains analysis of data from various datasets to understand relationships between variables. For a dataset of CEO salaries, adding variables like company profits and CEO tenure explained slightly more variation in salaries. For a charity donation dataset, adding variables like past donations and response rate explained more variation in donations than a single variable model. For a student exam scores dataset, a model using GPA, ACT math and English scores explained around 40% of the variation in exam scores, with ACT math having a larger effect than ACT English.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

library(wooldridge)

data("ceosal2")

#C3

#Task1
model <- lm(log(salary) ~ log(sales) + log(mktval), data = ceosal2)
# (Intercept) log(sales) log(mktval)
# 4.6209174 0.1621283 0.1067080

#log(salary)_prediction = 4.6209174 + 0.1621283*log(sales) +


0.1067080*log(mktval)
r_squared <- summary(model)$r.squared
print(r_squared)
#r_squared = 0.299
__________________________________________________________________

#Task2
model2 <- lm(log(salary) ~ log(sales) + log(mktval) + profits, data =
ceosal2)
#(Intercept) log(sales) log(mktval) profits
#4.686924 0.1613683 0.09752858 0.000036

#log(salary)_prediction = 4.686924 + 0.1613683*log(sales) +


0.09752858*log(mktval) + 0.000036*profits
r_squared <- summary(model2)$r.squared
print(r_squared)
#r_squared = 0.299

#profits may not be included because there are 9 negative values in this
sample.
#we can see that profits coefficient is 0.000036 (very small), so we
measure profits in millions and doesn't have a huge affect on
log(salary)_prediction.
#and all these variables explain about 30% of the sample variation, it's
less of the variation.
__________________________________________________________________

#Task3
model3 <- lm(log(salary) ~ log(sales) + log(mktval) + profits + ceoten,
data = ceosal2)
#(Intercept) log(sales) log(mktval) profits ceoten
#4.557780 0.1622339 0.1017598 0.000029 0.1168467

#log(salary)_prediction = 4.557780 + 0.1622339*log(sales) +


0.1017598*log(mktval) + 0.000029*profits + 0.1168467*ceoten
r_squared <- summary(model3)$r.squared
print(r_squared)
#r_squared = 0.3182988

#here CEO increases log(salary)_prediction by 1,2%


__________________________________________________________________

#Task4
cor(log(ceosal2$mktval),ceosal2$profits)
#the sample correlation coefficient between the variables log(mktval) and
profits = 0.7768976
#Yes, they are highly positively correlated at 0.7769. This means that
there is an OLS variance because there is a linear relationship among the
independent variables.

#C9

library(wooldridge)
data("charity")

#Task1
model9.1 <- lm(gift ~ mailsyear + giftlast + propresp, data = charity)
#(Intercept) mailsyear giftlast propresp
#-4.551518496 2.166259248 0.005926546 15.358605277

#gift_prediction = -4.55 + 2.17*mailsyear + 0.0059*giftlast +


15.36*propresp
r_squared <- summary(model9.1)$r.squared
print(r_squared)
#r_squared = 0.0834
#n = 4268

model9.12 <- lm(gift ~ mailsyear, data = charity)


#(Intercept) mailsyear
#2.014080 2.649546

#gift_prediction = 2.01 + 2.65*mailsyear

r_squared <- summary(model9.12)$r.squared


print(r_squared)
#r_squared2 = 0.0136

# r_squared = 0.0834 is higher than r_squared2 = 0.0136, so the variables


giftlast and propresp help to explain more variation in gifts in the
sample.

___________________________________________

#Task2
#If giftlast and propresp are fixed, one mail per year increases gifts by
2.17 guilders.
#It is bigger than the corresponding simple regression coefficient,
because the multiple regression estimate is 2.17 and the simple
regression estimate is 2.65.

___________________________________________

#Task3
#Because propresp is a proportion, there is no point in increasing it by
1
#There is a sense to do it only if propresp is from 0 to 1.

__________________________________________
#Task4
model9.4 <- lm(gift ~ mailsyear + giftlast + propresp + avggift, data =
charity)
#(Intercept) mailsyear giftlast propresp avggift
#-7.3277630 1.2011684 -0.2608573 16.2046425 0.5269471

#gift_prediction = -7.33 + 1.201*mailsyear - 0.261*giftlast +


0.527*propresp
r_squared <- summary(model9.4)$r.squared
print(r_squared)
#r_squared = 0.2005345
#n = 4268

#now the estimated effect of mailsyear is lower = 1.201

__________________________________________

#Task5
#after adding the variable avggift to the equation, the current gift
amount is negatively related to the most recent gift.
#it may happen when people donate big amounts of money first and after
that go smaller amounts of money.

#C12

library(wooldridge)
data("econmath")

#Task1

print(length(econmath$score[econmath$score==100]))
# 0 students received a perfect score for the course.

mean(econmath$score, na.rm = TRUE)


# The average of score is 72.59981

mean(econmath$actmth, na.rm = TRUE)


sd(econmath$actmth, na.rm = TRUE)
#The mean of actmth is 23.2113
#and standard deviation of actmth is 3.773354

mean(econmath$acteng, na.rm = TRUE)


sd(econmath$acteng, na.rm = TRUE)
#The mean of acteng is 22.59459
#and standard deviation of acteng is 3.788735

______________________________________

#Task2
model12.2 <- lm(score ~ colgpa + actmth + acteng, data = econmath)
#(Intercept) colgpa actmth acteng
#16.17401826 12.36620079 0.88335188 0.05176405
r_squared <- summary(model12.2)$r.squared
print(r_squared)
#r_squared = 0.3972348
#n = 814

#score_prediction = 16.17 + 12.37*colgpa + 0.88*actmth + 0.052*acteng

______________________________________

#Task2
#The coefficient of actmth is 0.88 and it's higher than the coefficient
of acteng 0.052, so it means that students with higher ACT maths will be
scored more and they are more valuable.

______________________________________

#Task3
#r_squared = 0.3972348
#about 40% of the variation in score is explained by colgpa, actmth,
acteng.

You might also like