#problem 1
load("ECON8010F18CEOSAL2.RData")
data$log_salary <- log(data$salary)
data$log_sales <- log(data$sales)
data$log_mktval <- log(data$mktval)
data$ceoten_sq <- data$ceoten^2
ols_model <- lm(log_salary ~ log_sales + log_mktval + ceoten + ceoten_sq, data = data)
summary(ols_model)
##
## Call:
## lm(formula = log_salary ~ log_sales + log_mktval + ceoten + ceoten_sq,
## data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.41976 -0.28791 0.00253 0.28615 1.74966
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.3685502 0.2587397 16.884 < 2e-16 ***
## log_sales 0.1646331 0.0386393 4.261 3.35e-05 ***
## log_mktval 0.1085285 0.0488257 2.223 0.02753 *
## ceoten 0.0451169 0.0141169 3.196 0.00166 **
## ceoten_sq -0.0012102 0.0004747 -2.549 0.01167 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4969 on 172 degrees of freedom
## Multiple R-squared: 0.343, Adjusted R-squared: 0.3277
## F-statistic: 22.45 on 4 and 172 DF, p-value: 6.257e-15
#(2)The coefficient of log_sales is 0.1646, meaning that firm sales changed by 1% as CEO salary changes by 0.1646%.
#(3)At the 1% level (p < 0.01):log_sales is significant (p-value = 3.35e-05) ceoten is significant (p-value = 0.00166).At the 5% level (p < 0.05):log_mktval is significant (p-value = 0.02753)ceoten_sq is significant (p-value = 0.01167). The variables are significant based on their P value.
#(4) I would, because The quadratic term for ceoten_sq is significant (p-value = 0.01167), suggesting that CEO tenure has a non-linear (quadratic) relationship with salary. The negative coefficient of ceoten_sq (-0.00121) indicates a diminishing return on salary as tenure increases.
#(5)
beta3 <- coef(ols_model)["ceoten"]
beta4 <- coef(ols_model)["ceoten_sq"]
turning_point <- -beta3 / (2 * beta4)
turning_point
## ceoten
## 18.64042
#(6)Null Hypothesis
#H0:𝛽1=0.2 𝐻1:𝛽1≠0.2.
beta1_hypothesis <- 0.2
beta1_estimate <- coef(ols_model)["log_sales"]
se_beta1 <- summary(ols_model)$coefficients["log_sales", "Std. Error"]
t_stat <- (beta1_estimate - beta1_hypothesis) / se_beta1
p_value <- 2 * pt(-abs(t_stat), df = nrow(data) - length(coef(ols_model)))
t_stat
## log_sales
## -0.9153076
p_value
## log_sales
## 0.3613116
#(7)
P0<-lm(data$log_sales ~ data$log_mktval + data$ceoten + data$ceoten_sq)
summary(P0)
##
## Call:
## lm(formula = data$log_sales ~ data$log_mktval + data$ceoten +
## data$ceoten_sq)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.9600 -0.5014 0.1573 0.5653 2.2642
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.3867694 0.5082589 0.761 0.448
## data$log_mktval 0.9293646 0.0650937 14.277 <2e-16 ***
## data$ceoten -0.0072679 0.0277716 -0.262 0.794
## data$ceoten_sq 0.0002219 0.0009340 0.238 0.813
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.9778 on 173 degrees of freedom
## Multiple R-squared: 0.5418, Adjusted R-squared: 0.5338
## F-statistic: 68.18 on 3 and 173 DF, p-value: < 2.2e-16
data$log_sales_res<-P0$resid
P1<-lm(data$log_salary ~ data$log_sales_res)
summary(P1)
##
## Call:
## lm(formula = data$log_salary ~ data$log_sales_res)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.81044 -0.41434 -0.00697 0.39680 1.88430
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.58285 0.04407 149.367 < 2e-16 ***
## data$log_sales_res 0.16463 0.04559 3.611 0.000398 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5863 on 175 degrees of freedom
## Multiple R-squared: 0.06935, Adjusted R-squared: 0.06403
## F-statistic: 13.04 on 1 and 175 DF, p-value: 0.000398
R1<-lm(data$log_salary ~ data$log_sales + data$log_mktval + data$ceoten + data$ceoten_sq)
summary(R1)
##
## Call:
## lm(formula = data$log_salary ~ data$log_sales + data$log_mktval +
## data$ceoten + data$ceoten_sq)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.41976 -0.28791 0.00253 0.28615 1.74966
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.3685502 0.2587397 16.884 < 2e-16 ***
## data$log_sales 0.1646331 0.0386393 4.261 3.35e-05 ***
## data$log_mktval 0.1085285 0.0488257 2.223 0.02753 *
## data$ceoten 0.0451169 0.0141169 3.196 0.00166 **
## data$ceoten_sq -0.0012102 0.0004747 -2.549 0.01167 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4969 on 172 degrees of freedom
## Multiple R-squared: 0.343, Adjusted R-squared: 0.3277
## F-statistic: 22.45 on 4 and 172 DF, p-value: 6.257e-15
R1$coeff[2]
## data$log_sales
## 0.1646331
P1$coeff[2]
## data$log_sales_res
## 0.1646331
#2
#(1)
ols_model2 <- lm(log(salary) ~ sales + profits + profmarg, data = data)
summary(ols_model2)
##
## Call:
## lm(formula = log(salary) ~ sales + profits + profmarg, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.99799 -0.35372 0.01989 0.38691 2.04390
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.451e+00 5.029e-02 128.258 <2e-16 ***
## sales 2.287e-05 1.155e-05 1.981 0.0492 *
## profits 3.352e-04 1.752e-04 1.913 0.0574 .
## profmarg -2.828e-03 2.390e-03 -1.183 0.2383
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5509 on 173 degrees of freedom
## Multiple R-squared: 0.1879, Adjusted R-squared: 0.1738
## F-statistic: 13.34 on 3 and 173 DF, p-value: 7.128e-08
# A 1-unit increase in firm sales (in $1,000,000) is associated with 0.00002287% increase in CEO salary
#(2)
ols1<-lm(log(salary) ~ sales + profits + profmarg, data = data)
ols2<-lm(log(salary) ~ sales + profits , data = data)
summary(ols1)
##
## Call:
## lm(formula = log(salary) ~ sales + profits + profmarg, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.99799 -0.35372 0.01989 0.38691 2.04390
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.451e+00 5.029e-02 128.258 <2e-16 ***
## sales 2.287e-05 1.155e-05 1.981 0.0492 *
## profits 3.352e-04 1.752e-04 1.913 0.0574 .
## profmarg -2.828e-03 2.390e-03 -1.183 0.2383
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5509 on 173 degrees of freedom
## Multiple R-squared: 0.1879, Adjusted R-squared: 0.1738
## F-statistic: 13.34 on 3 and 173 DF, p-value: 7.128e-08
summary(ols2)
##
## Call:
## lm(formula = log(salary) ~ sales + profits, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.00995 -0.35343 0.02414 0.38979 2.04681
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.433e+00 4.808e-02 133.796 <2e-16 ***
## sales 2.556e-05 1.134e-05 2.255 0.0254 *
## profits 2.872e-04 1.707e-04 1.683 0.0942 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5515 on 174 degrees of freedom
## Multiple R-squared: 0.1813, Adjusted R-squared: 0.1719
## F-statistic: 19.26 on 2 and 174 DF, p-value: 2.769e-08
# No evidence showed that there is collinearity problem, so I used a more direct method about vif, and vif<5, meaning that multicollinearity is not a significant concern.
options(repos = c(CRAN = "https://cloud.r-project.org/"))
library(car)
## 载入需要的程序包:carData
vif(ols1)
## sales profits profmarg
## 2.867752 2.912750 1.056882
#3
#Increasing the sample size can improve the statistical significance of estimates because larger sample sizes could provide more reliable estimates of the true parameters. As the sample size increases, the standard errors of the estimated coefficients decrease, leading to larger t-statistics and smaller p-values. In this context, increasing the sample size solely for the purpose of achieving significance can be considered a form of p-hacking.
#4
#H0: The patient is not pregnant. Type I Error (False Positive): This occurs when reject the null hypothesis when it is actually true. so the Type I error leads to the false conclusion that the person is pregnant when he is a guy.Type II Error (False Negative): This occurs when fail to reject the null hypothesis when it is false. so the Type II error leads to the false conclusion that the person is not pregnant but acctully she got pregnant.