library(tidyverse)
library(scales)
Make sure to include the unit of the values whenever appropriate.
Hint: The variables are available in the CPS85 data set from the mosaicData package.
data(CPS85, package="mosaicData")
wages <- lm(wage ~ educ + exper + sex,
data = CPS85)
# View summary of model 1
summary(wages)
##
## Call:
## lm(formula = wage ~ educ + exper + sex, data = CPS85)
##
## Residuals:
## Min 1Q Median 3Q Max
## -9.571 -2.746 -0.653 1.893 37.724
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -6.50451 1.20985 -5.376 1.14e-07 ***
## educ 0.94051 0.07886 11.926 < 2e-16 ***
## exper 0.11330 0.01671 6.781 3.19e-11 ***
## sexM 2.33763 0.38806 6.024 3.19e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.454 on 530 degrees of freedom
## Multiple R-squared: 0.2532, Adjusted R-squared: 0.2489
## F-statistic: 59.88 on 3 and 530 DF, p-value: < 2.2e-16
```
The coefficient of education is significant at 5%
Hint: Discuss both its sign and magnitude.
There are three stars after the data meaning that there is a 99.9% chance that the coefficiant is true. Meaning education has an impact on wages.
Hint: Discuss all three aspects of the relevant predictor: 1) statistical significance, 2) sign, and 3) magnitude.
There is evidence that there is gender discrimination in determining wages because when looking at sex, the significance is 99.9% making the coefficiant true. The sign is positive meaning that there is evidence that there is gender discrimination in wages, and the magnitude of 2.33 means that males will make 2.33 times more then the avg wage
The wage for a woman who has 15 years of edjucation and 5 years of experience is $14.67
Hint: Provide a technical interpretation.
The intercept is -6.50451 which means that the wage would be $6.5 if all other variables were 0.
Hint: Discuss in terms of both residual standard error and reported adjusted R squared.
data(CPS85, package="mosaicData")
wages <- lm(wage ~ educ + exper + sex + union,
data = CPS85)
# View summary of model 1
summary(wages)
##
## Call:
## lm(formula = wage ~ educ + exper + sex + union, data = CPS85)
##
## Residuals:
## Min 1Q Median 3Q Max
## -9.496 -2.708 -0.712 1.909 37.784
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -6.48023 1.20159 -5.393 1.05e-07 ***
## educ 0.93495 0.07835 11.934 < 2e-16 ***
## exper 0.10692 0.01674 6.387 3.70e-10 ***
## sexM 2.14765 0.39097 5.493 6.14e-08 ***
## unionUnion 1.47111 0.50932 2.888 0.00403 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.423 on 529 degrees of freedom
## Multiple R-squared: 0.2648, Adjusted R-squared: 0.2592
## F-statistic: 47.62 on 4 and 529 DF, p-value: < 2.2e-16
In the new model the risidual error is 4.423 compared to the first model of 4.454. The second model is better becuase the 4.423 is closer to the actual wage price.
In the new model the reported adjusted r squared is 0.2592 and in the older model it was 0.2489. This means that there is a 26% of wage can be shown in the model, and in the first model only 25% can be shown in the model making the second model better.
The second model is better.
Hint: Use message, echo and results in the chunk options. Refer to the RMarkdown Reference Guide.