cps <- read.csv("cps22_64.csv")
rega <- lm(ahe ~ female + age + yrseduc, data=cps)
summary(rega)
##
## Call:
## lm(formula = ahe ~ female + age + yrseduc, data = cps)
##
## Residuals:
## Min 1Q Median 3Q Max
## -43.376 -9.002 -2.686 5.626 185.374
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -23.523894 0.423406 -55.56 <2e-16 ***
## female -6.523817 0.127736 -51.07 <2e-16 ***
## age 0.243959 0.005671 43.02 <2e-16 ***
## yrseduc 2.935852 0.024427 120.19 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 14.93 on 55864 degrees of freedom
## Multiple R-squared: 0.2438, Adjusted R-squared: 0.2438
## F-statistic: 6004 on 3 and 55864 DF, p-value: < 2.2e-16
Since this is a non-linear regression, the average hourly earnings would increase by $0.24 for both age increases
cps <- read.csv("cps22_64.csv")
lnahe <- log(cps$ahe)
rega2 <- lm(lnahe ~ female + age + yrseduc, data=cps)
summary(rega2)
##
## Call:
## lm(formula = lnahe ~ female + age + yrseduc, data = cps)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.97389 -0.32225 0.00576 0.34056 2.51563
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.1709429 0.0149247 78.46 <2e-16 ***
## female -0.2433026 0.0045026 -54.04 <2e-16 ***
## age 0.0097323 0.0001999 48.68 <2e-16 ***
## yrseduc 0.1110353 0.0008610 128.95 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5264 on 55864 degrees of freedom
## Multiple R-squared: 0.2724, Adjusted R-squared: 0.2723
## F-statistic: 6971 on 3 and 55864 DF, p-value: < 2.2e-16
Answers in a and b would differ since the regression is now explained in terms of percentages. I personally prefer the specification of the regression in model a over b since I prefer having actual dollar amount increases and decreases as opposed to proportional changes.
pexp <- cps$age - (cps$yrseduc + 6)
pexp2 <- pexp^2
rega3 <- lm(lnahe ~ cps$female + cps$yrseduc + pexp + pexp2)
summary(rega3)
##
## Call:
## lm(formula = lnahe ~ cps$female + cps$yrseduc + pexp + pexp2)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.00539 -0.31983 0.00655 0.33964 2.48443
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.083e+00 1.536e-02 70.55 <2e-16 ***
## cps$female -2.394e-01 4.480e-03 -53.43 <2e-16 ***
## cps$yrseduc 1.192e-01 8.798e-04 135.52 <2e-16 ***
## pexp 2.929e-02 8.056e-04 36.36 <2e-16 ***
## pexp2 -4.305e-04 1.718e-05 -25.05 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5234 on 55863 degrees of freedom
## Multiple R-squared: 0.2805, Adjusted R-squared: 0.2804
## F-statistic: 5444 on 4 and 55863 DF, p-value: < 2.2e-16
Age should not be included in the regression because pexp captures the effect of age indirectly, so if age was included it would be an issue of multicolinearity
t.test(pexp2)
##
## One Sample t-test
##
## data: pexp2
## t = 274.73, df = 55867, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
## 619.1975 628.0960
## sample estimates:
## mean of x
## 623.6468
result = (0.0292/(2*0.0004))
result
## [1] 36.5
0 is outside of the confidence interval for the coefficient therefore the coefficient of the quadratic variable is statistically significant. The coefficient for pexp is 0.0292 means that there is a small increase in the rate of return for each additional year of potential work experience
Taking the partial derivative with respect to pexp and setting income equal to 0 and solving for pexp results in the maximizing potential work experience level of 36.25 years
The coefficient on Female means that there is a 23.9% decrease in expected hourly wage, controlling for all other variables, for Females compared to male expected hourly wage.
The coefficient on Yrseduc means that there is a 11.92% increase per each additional year of education, controller for all other variables.
rega4 <- lm(cps$ahe ~ cps$female+cps$yrseduc+pexp+pexp2+cps$yrseduc:cps$female)
summary(rega4)
##
## Call:
## lm(formula = cps$ahe ~ cps$female + cps$yrseduc + pexp + pexp2 +
## cps$yrseduc:cps$female)
##
## Residuals:
## Min 1Q Median 3Q Max
## -45.295 -8.901 -2.592 5.571 183.375
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2.837e+01 5.168e-01 -54.891 <2e-16 ***
## cps$female -4.209e-01 7.109e-01 -0.592 0.554
## cps$yrseduc 3.314e+00 3.224e-02 102.793 <2e-16 ***
## pexp 7.670e-01 2.285e-02 33.563 <2e-16 ***
## pexp2 -1.156e-02 4.875e-04 -23.723 <2e-16 ***
## cps$female:cps$yrseduc -4.226e-01 4.928e-02 -8.575 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 14.85 on 55862 degrees of freedom
## Multiple R-squared: 0.2523, Adjusted R-squared: 0.2523
## F-statistic: 3771 on 5 and 55862 DF, p-value: < 2.2e-16
The estimated rate is 3.314 for each additional year of education for men since Female = 0. For women, the estimated rate of return is slightly less, 2.8914.
library(car)
## Warning: package 'car' was built under R version 4.3.3
## Loading required package: carData
## Warning: package 'carData' was built under R version 4.3.3
linearHypothesis(rega4, c("cps$yrseduc","cps$female:cps$yrseduc=0"))
##
## Linear hypothesis test:
## cps$yrseduc = 0
## cps$female:cps$yrseduc = 0
##
## Model 1: restricted model
## Model 2: cps$ahe ~ cps$female + cps$yrseduc + pexp + pexp2 + cps$yrseduc:cps$female
##
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 55864 15819014
## 2 55862 12316102 2 3502912 7944.1 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The difference in rate of return on education is statistically different between men and women
For men: lnahe=B0+B2Yrseduc For females: (since Female = 1) lnahe=(B0+B1)+(B2+B3)Yrseduc
The difference between the two intercepts would be B2. Since the p-value is 0.55 which is greater than 0.05, the difference between the two intercepts is not statistically significant.
load("~/School/Fall 2024/Econometrics/Fed_2012.RData")
fed <- dta
rega5 = lm(fed$FEDFUNDS ~fed$election+fed$democrat+fed$election*fed$democrat)
summary(rega5)
##
## Call:
## lm(formula = fed$FEDFUNDS ~ fed$election + fed$democrat + fed$election *
## fed$democrat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.5060 -1.9970 -0.3652 1.6608 10.3394
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.77030 0.52736 14.734 < 2e-16 ***
## fed$election -0.26487 0.05879 -4.505 1.07e-05 ***
## fed$democrat -4.90324 0.81534 -6.014 7.39e-09 ***
## fed$election:fed$democrat 0.55819 0.09393 5.943 1.08e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.158 on 222 degrees of freedom
## (6 observations deleted due to missingness)
## Multiple R-squared: 0.151, Adjusted R-squared: 0.1395
## F-statistic: 13.16 on 3 and 222 DF, p-value: 6.083e-08
The federal funds rate will decrease by 0.26 for each increase in election variable when there is a republican president, controlling for all other variables. The federal funds rate will increase by 0.293 (which is the difference due to the interaction variable) for each increase in electrion variable when there is a democratic president, controlling for all other variables.
linearHypothesis(rega5, c("fed$election=0", "fed$election:fed$democrat=0"))
##
## Linear hypothesis test:
## fed$election = 0
## fed$election:fed$democrat = 0
##
## Model 1: restricted model
## Model 2: fed$FEDFUNDS ~ fed$election + fed$democrat + fed$election * fed$democrat
##
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 224 2576.6
## 2 222 2214.2 2 362.36 18.165 4.94e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The f-test checks if all values are significantly different from zero. Since the p-value is well below 0.05 there is statistical evidence that the effect of election is statistically significant for republicans. Thje lines have the same intercept but different slopes.