\(~\) \(~\)

(e) Determine the values of P from the results in Lecture 2.1.

data <- read.table("./Week 2 - Exercise 1.txt", header = TRUE)
Reg <- lm(LogWage~Female, data = data)
Res <- Reg$residuals
Age <- data$Age
Edu <- data$Educ
Job <- data$Parttime
one <- lm(Res~Age)
two <- lm(Res~Edu)
three <- lm(Res~Job)
summary(Reg)
## 
## Call:
## lm(formula = LogWage ~ Female, data = data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.09562 -0.30262 -0.03683  0.30338  1.41397 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  4.73362    0.02434 194.453  < 2e-16 ***
## Female      -0.25060    0.04013  -6.245  9.1e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4327 on 498 degrees of freedom
## Multiple R-squared:  0.07262,    Adjusted R-squared:  0.07076 
## F-statistic:    39 on 1 and 498 DF,  p-value: 9.101e-10
summary(one)
## 
## Call:
## lm(formula = Res ~ Age)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.00015 -0.26233 -0.02237  0.23252  1.02256 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.867051   0.062228  -13.93   <2e-16 ***
## Age          0.021671   0.001501   14.43   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3634 on 498 degrees of freedom
## Multiple R-squared:  0.295,  Adjusted R-squared:  0.2936 
## F-statistic: 208.4 on 1 and 498 DF,  p-value: < 2.2e-16
summary(two)
## 
## Call:
## lm(formula = Res ~ Edu)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.07863 -0.28052 -0.01422  0.25178  1.21315 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.45262    0.03614  -12.52   <2e-16 ***
## Edu          0.21782    0.01550   14.05   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3662 on 498 degrees of freedom
## Multiple R-squared:  0.2839, Adjusted R-squared:  0.2824 
## F-statistic: 197.4 on 1 and 498 DF,  p-value: < 2.2e-16
summary(three)
## 
## Call:
## lm(formula = Res ~ Job)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.08732 -0.30532 -0.02769  0.30686  1.44241 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## (Intercept) -0.02843    0.02281  -1.246   0.2132  
## Job          0.09873    0.04251   2.323   0.0206 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4304 on 498 degrees of freedom
## Multiple R-squared:  0.01072,    Adjusted R-squared:  0.008729 
## F-statistic: 5.394 on 1 and 498 DF,  p-value: 0.0206

\(~\)

(f) Check the numerical validity of the result in part (c). Note: This equation will not hold exactly because thecoefficients have been rounded to two or three decimals; preciser results would have been obtained for higherprecision coefficients.

df <- data.frame("Age" = one$coefficients, "Education" = two$coefficients, "Parttime" = three$coefficients)
row.names(df)[2] <- "Female"
print(df)
##                     Age  Education    Parttime
## (Intercept) -0.86705119 -0.4526212 -0.02843292
## Female       0.02167086  0.2178158  0.09872542

\(~\) \(~\) \(~\)