library(Sleuth3)
library(ggplot2)
`?`(ex0923)
head(ex0923)
##   Subject Gender   AFQT Educ Income2005
## 1       2 female  6.841   12       5500
## 2       6   male 99.393   16      65000
## 3       7   male 47.412   12      19000
## 4       8 female 44.022   14      36000
## 5       9   male 59.683   14      65000
## 6      13   male 72.313   16       8000
str(ex0923)
## 'data.frame':    2584 obs. of  5 variables:
##  $ Subject   : int  2 6 7 8 9 13 16 17 18 20 ...
##  $ Gender    : Factor w/ 2 levels "female","male": 1 2 2 1 2 2 1 2 2 1 ...
##  $ AFQT      : num  6.84 99.39 47.41 44.02 59.68 ...
##  $ Educ      : int  12 16 12 14 14 16 13 13 13 17 ...
##  $ Income2005: int  5500 65000 19000 36000 65000 8000 71000 43000 120000 64000 ...
qplot(AFQT, Income2005, data = ex0923)

plot of chunk unnamed-chunk-1

qplot(AFQT, log(Income2005), data = ex0923)

plot of chunk unnamed-chunk-1

qplot(Educ, Income2005, data = ex0923)

plot of chunk unnamed-chunk-1

qplot(Educ, log(Income2005), data = ex0923)

plot of chunk unnamed-chunk-1

qplot(Educ, AFQT, data = ex0923)

plot of chunk unnamed-chunk-1

fit0923 <- lm(log(Income2005) ~ Gender + AFQT + Educ, data = ex0923)
summary(fit0923)
## 
## Call:
## lm(formula = log(Income2005) ~ Gender + AFQT + Educ, data = ex0923)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -7.091 -0.330  0.140  0.509  2.545 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 8.731212   0.102629   85.08  < 2e-16 ***
## Gendermale  0.624509   0.034175   18.27  < 2e-16 ***
## AFQT        0.005914   0.000766    7.72  1.6e-14 ***
## Educ        0.076951   0.008489    9.06  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.866 on 2580 degrees of freedom
## Multiple R-squared:  0.21,   Adjusted R-squared:  0.209 
## F-statistic:  229 on 3 and 2580 DF,  p-value: <2e-16
confint(fit0923)
##                2.5 %   97.5 %
## (Intercept) 8.529969 8.932454
## Gendermale  0.557496 0.691522
## AFQT        0.004413 0.007415
## Educ        0.060305 0.093596