Wooldridge - Computer Exercises, Chapter 3, C3, C9, C12
Wooldridge - Computer Exercises, Chapter 3, C3, C9, C12
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
#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
#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
#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
___________________________________________
#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
__________________________________________
#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.
______________________________________
#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
______________________________________
#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.