# Instrumental Variables example
library(sem)
## Warning: package 'sem' was built under R version 4.3.3
#If gets error, add code< install.packages("Hmisc",dependecies=T)> or download a new version R studio
wages<-read.csv('http://inta.gatech.s3.amazonaws.com/wage2.csv')
iv.results<-tsls(lwage ~ educ + age + married + black + exper, ~ feduc + age + married + black + exper, data=wages)
# Run an instrumental variables regression. Note that father's education is
# used for an instrument, and is not in the first set of variables. Age,
# marital, status, and race are assumed to be less related to underlying
# ability and so are controlled for in the "first stage" regression too.

ols.results<-lm(lwage ~ educ + age + married + black + exper, data=wages)
# Run the analogous OLS regression without father's education

print(summary(ols.results))
## 
## Call:
## lm(formula = lwage ~ educ + age + married + black + exper, data = wages)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.90467 -0.23071  0.03097  0.25675  1.28777 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  5.223088   0.158879  32.875  < 2e-16 ***
## educ         0.067974   0.006727  10.105  < 2e-16 ***
## age          0.010397   0.004819   2.158 0.031209 *  
## married      0.189200   0.040738   4.644 3.90e-06 ***
## black       -0.208938   0.037984  -5.501 4.89e-08 ***
## exper        0.013345   0.003838   3.477 0.000531 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3812 on 929 degrees of freedom
## Multiple R-squared:  0.1853, Adjusted R-squared:  0.1809 
## F-statistic: 42.26 on 5 and 929 DF,  p-value: < 2.2e-16
print(summary(iv.results))
## 
##  2SLS Estimates
## 
## Model Formula: lwage ~ educ + age + married + black + exper
## 
## Instruments: ~feduc + age + married + black + exper
## 
## Residuals:
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## -1.800804 -0.245057  0.008959  0.000000  0.260049  1.286707 
## 
##                 Estimate   Std. Error  t value   Pr(>|t|)    
## (Intercept)  4.552925199  0.280501872 16.23135 < 2.22e-16 ***
## educ         0.132581807  0.022703924  5.83960 7.8541e-09 ***
## age         -0.003706094  0.007482199 -0.49532   0.620521    
## married      0.186683907  0.046865683  3.98338 7.4703e-05 ***
## black       -0.108869556  0.054978411 -1.98022   0.048051 *  
## exper        0.035846909  0.008100919  4.42504 1.1103e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3991539 on 735 degrees of freedom
# Note that the point estimate for education has now gone up. This suggests
# that people who have higher education in a way that's correlated with
# their father having higher education, even holding fixed age, marital
# status, and race, receive ~13% higher wages for every year of education.
# Also note that the standard error on education is higher for the iv than
# ols results. The reason for this is that in IV, we're using only some of
# the variation in education: only the part related to father's education,
# so it's like there's less variation overall

# Stepwise regression
library(MASS)
start.model<-lm(wage ~ hours + IQ + KWW + educ + exper + tenure + age + married + black + south + urban + sibs, data=wages)
# Give an initial model, which will be the most coefficients we'd want to ever use
summary(start.model)
## 
## Call:
## lm(formula = wage ~ hours + IQ + KWW + educ + exper + tenure + 
##     age + married + black + south + urban + sibs, data = wages)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -849.76 -223.19  -40.18  172.09 2091.17 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -562.589    185.142  -3.039  0.00244 ** 
## hours         -3.485      1.621  -2.150  0.03182 *  
## IQ             2.828      1.004   2.817  0.00495 ** 
## KWW            5.261      1.981   2.656  0.00804 ** 
## educ          48.213      7.182   6.713 3.33e-11 ***
## exper          9.774      3.589   2.723  0.00658 ** 
## tenure         5.242      2.406   2.178  0.02963 *  
## age            5.046      4.930   1.024  0.30634    
## married      170.231     37.883   4.494 7.89e-06 ***
## black       -108.844     39.808  -2.734  0.00637 ** 
## south        -53.689     25.536  -2.102  0.03578 *  
## urban        160.652     26.200   6.132 1.29e-09 ***
## sibs          -1.068      5.455  -0.196  0.84488    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 352.6 on 922 degrees of freedom
## Multiple R-squared:  0.2493, Adjusted R-squared:  0.2395 
## F-statistic: 25.51 on 12 and 922 DF,  p-value: < 2.2e-16
stepwise.model<- step(start.model)
## Start:  AIC=10981.26
## wage ~ hours + IQ + KWW + educ + exper + tenure + age + married + 
##     black + south + urban + sibs
## 
##           Df Sum of Sq       RSS   AIC
## - sibs     1      4763 114655843 10979
## - age      1    130265 114781346 10980
## <none>                 114651080 10981
## - south    1    549683 115200763 10984
## - hours    1    574799 115225880 10984
## - tenure   1    590101 115241181 10984
## - KWW      1    877455 115528536 10986
## - exper    1    922291 115573372 10987
## - black    1    929659 115580739 10987
## - IQ       1    986880 115637960 10987
## - married  1   2510929 117162009 11000
## - urban    1   4675218 119326298 11017
## - educ     1   5603726 120254807 11024
## 
## Step:  AIC=10979.3
## wage ~ hours + IQ + KWW + educ + exper + tenure + age + married + 
##     black + south + urban
## 
##           Df Sum of Sq       RSS   AIC
## - age      1    128704 114784547 10978
## <none>                 114655843 10979
## - south    1    546953 115202796 10982
## - hours    1    575305 115231148 10982
## - tenure   1    590732 115246575 10982
## - KWW      1    911607 115567450 10985
## - exper    1    926789 115582632 10985
## - black    1   1000335 115656178 10985
## - IQ       1   1002450 115658294 10985
## - married  1   2508266 117164110 10998
## - urban    1   4686063 119341906 11015
## - educ     1   5673927 120329770 11022
## 
## Step:  AIC=10978.35
## wage ~ hours + IQ + KWW + educ + exper + tenure + married + black + 
##     south + urban
## 
##           Df Sum of Sq       RSS   AIC
## <none>                 114784547 10978
## - hours    1    562954 115347501 10981
## - south    1    565737 115350283 10981
## - tenure   1    680663 115465209 10982
## - IQ       1    907667 115692213 10984
## - black    1    980306 115764853 10984
## - KWW      1   1413125 116197671 10988
## - exper    1   1678662 116463208 10990
## - married  1   2538972 117323519 10997
## - urban    1   4639497 119424043 11013
## - educ     1   6097302 120881849 11025
# The command "step" adds and subtracts coefficients to maximize a measure of
# goodness of fit
summary(stepwise.model)
## 
## Call:
## lm(formula = wage ~ hours + IQ + KWW + educ + exper + tenure + 
##     married + black + south + urban, data = wages)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -872.52 -224.26  -41.71  171.08 2086.14 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -453.2969   141.0390  -3.214 0.001354 ** 
## hours         -3.4474     1.6194  -2.129 0.033536 *  
## IQ             2.6621     0.9848   2.703 0.006996 ** 
## KWW            6.0918     1.8062   3.373 0.000775 ***
## educ          49.4804     7.0627   7.006 4.73e-12 ***
## exper         11.5519     3.1425   3.676 0.000251 ***
## tenure         5.5777     2.3828   2.341 0.019455 *  
## married      171.1045    37.8476   4.521 6.96e-06 ***
## black       -109.2993    38.9083  -2.809 0.005072 ** 
## south        -54.4073    25.4951  -2.134 0.033103 *  
## urban        159.8942    26.1639   6.111 1.46e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 352.5 on 924 degrees of freedom
## Multiple R-squared:  0.2484, Adjusted R-squared:  0.2402 
## F-statistic: 30.53 on 10 and 924 DF,  p-value: < 2.2e-16
stepwise.model.interactions <- step(start.model, scope=wage~.^2)
## Start:  AIC=10981.26
## wage ~ hours + IQ + KWW + educ + exper + tenure + age + married + 
##     black + south + urban + sibs
## 
##                  Df Sum of Sq       RSS   AIC
## + KWW:educ        1   1911037 112740043 10968
## + educ:age        1   1282120 113368961 10973
## + KWW:black       1   1194791 113456289 10974
## + IQ:KWW          1   1066753 113584327 10974
## + black:sibs      1    806249 113844831 10977
## + hours:KWW       1    755386 113895694 10977
## + educ:urban      1    695416 113955664 10978
## + IQ:sibs         1    694361 113956719 10978
## + educ:exper      1    667627 113983453 10978
## + KWW:age         1    631767 114019314 10978
## + hours:south     1    625168 114025912 10978
## + married:sibs    1    574498 114076582 10979
## + south:urban     1    564654 114086426 10979
## + black:south     1    487564 114163516 10979
## - sibs            1      4763 114655843 10979
## + IQ:educ         1    449771 114201309 10980
## + educ:married    1    415461 114235619 10980
## + hours:age       1    411927 114239154 10980
## + tenure:black    1    409691 114241390 10980
## + KWW:married     1    391481 114259600 10980
## + hours:sibs      1    382852 114268228 10980
## - age             1    130265 114781346 10980
## + KWW:sibs        1    354299 114296782 10980
## + exper:age       1    348719 114302361 10980
## + educ:black      1    319990 114331091 10981
## <none>                        114651080 10981
## + hours:tenure    1    214599 114436481 10982
## + black:urban     1    200281 114450799 10982
## + tenure:south    1    187488 114463592 10982
## + educ:sibs       1    181656 114469425 10982
## + IQ:black        1    175403 114475677 10982
## + exper:south     1    163186 114487895 10982
## + hours:married   1    161641 114489439 10982
## + IQ:urban        1    155293 114495787 10982
## + IQ:age          1    139542 114511539 10982
## + age:sibs        1    139255 114511825 10982
## + tenure:urban    1    137750 114513330 10982
## + age:married     1    132430 114518650 10982
## + tenure:age      1    111540 114539540 10982
## + hours:exper     1    107393 114543688 10982
## + hours:educ      1     97692 114553388 10982
## + age:black       1     92171 114558909 10982
## + exper:urban     1     87171 114563909 10983
## + IQ:married      1     58427 114592653 10983
## + IQ:exper        1     46633 114604448 10983
## + educ:south      1     42024 114609056 10983
## + age:south       1     40889 114610192 10983
## + hours:IQ        1     26239 114624841 10983
## + exper:tenure    1     23621 114627460 10983
## + exper:black     1     22305 114628776 10983
## + tenure:sibs     1     22068 114629013 10983
## + educ:tenure     1     20822 114630258 10983
## + tenure:married  1     19810 114631271 10983
## + married:black   1     19545 114631536 10983
## + married:south   1     18028 114633052 10983
## + IQ:south        1     14743 114636338 10983
## + exper:sibs      1     13695 114637385 10983
## + age:urban       1     12597 114638483 10983
## + married:urban   1     10511 114640569 10983
## + IQ:tenure       1      8883 114642197 10983
## + KWW:south       1      7896 114643185 10983
## + hours:black     1      5003 114646077 10983
## + KWW:urban       1      4334 114646746 10983
## + hours:urban     1      2445 114648636 10983
## + south:sibs      1      2348 114648733 10983
## + KWW:exper       1      2189 114648891 10983
## + exper:married   1      1749 114649331 10983
## + KWW:tenure      1      1325 114649756 10983
## + urban:sibs      1      1141 114649939 10983
## - south           1    549683 115200763 10984
## - hours           1    574799 115225880 10984
## - tenure          1    590101 115241181 10984
## - KWW             1    877455 115528536 10986
## - exper           1    922291 115573372 10987
## - black           1    929659 115580739 10987
## - IQ              1    986880 115637960 10987
## - married         1   2510929 117162009 11000
## - urban           1   4675218 119326298 11017
## - educ            1   5603726 120254807 11024
## 
## Step:  AIC=10967.55
## wage ~ hours + IQ + KWW + educ + exper + tenure + age + married + 
##     black + south + urban + sibs + KWW:educ
## 
##                  Df Sum of Sq       RSS   AIC
## + hours:south     1    817073 111922970 10963
## + educ:exper      1    719870 112020173 10964
## + KWW:black       1    710103 112029939 10964
## + married:sibs    1    587553 112152490 10965
## + KWW:age         1    580504 112159539 10965
## + black:sibs      1    561664 112178379 10965
## - sibs            1      9692 112749735 10966
## + educ:urban      1    463226 112276817 10966
## + south:urban     1    462838 112277205 10966
## - age             1     33893 112773936 10966
## + black:south     1    434569 112305474 10966
## + hours:KWW       1    434379 112305664 10966
## + hours:age       1    419380 112320663 10966
## + educ:age        1    416833 112323210 10966
## + tenure:black    1    399466 112340577 10966
## + KWW:exper       1    352312 112387731 10967
## + educ:married    1    338394 112401649 10967
## + KWW:married     1    337930 112402113 10967
## + IQ:sibs         1    327205 112412838 10967
## + hours:sibs      1    304679 112435364 10967
## + hours:tenure    1    263415 112476627 10967
## <none>                        112740043 10968
## + black:urban     1    237466 112502577 10968
## + educ:south      1    191103 112548940 10968
## + age:sibs        1    188318 112551725 10968
## + hours:married   1    181409 112558634 10968
## + tenure:south    1    170538 112569505 10968
## + hours:exper     1    148645 112591398 10968
## + exper:age       1    136044 112603999 10968
## + IQ:black        1    123781 112616262 10968
## + age:married     1    105507 112634536 10969
## + age:black       1     96147 112643896 10969
## + tenure:urban    1     89523 112650520 10969
## + IQ:urban        1     88532 112651511 10969
## + exper:south     1     85995 112654048 10969
## + tenure:age      1     75240 112664803 10969
## + IQ:KWW          1     72108 112667935 10969
## + KWW:sibs        1     61009 112679034 10969
## + educ:black      1     51332 112688711 10969
## + exper:urban     1     46837 112693206 10969
## + IQ:married      1     45561 112694482 10969
## + IQ:south        1     27547 112712496 10969
## + IQ:tenure       1     24162 112715881 10969
## + hours:educ      1     23840 112716203 10969
## + married:black   1     21600 112718443 10969
## + age:south       1     17543 112722500 10969
## + KWW:south       1     17328 112722715 10969
## + south:sibs      1     16832 112723210 10969
## + IQ:age          1     15833 112724210 10969
## + KWW:urban       1     12939 112727104 10969
## + urban:sibs      1     12901 112727141 10969
## + IQ:exper        1     10976 112729067 10970
## + tenure:sibs     1     10849 112729193 10970
## + married:urban   1     10462 112729581 10970
## + hours:urban     1      9378 112730665 10970
## + IQ:educ         1      8591 112731452 10970
## + hours:IQ        1      8113 112731930 10970
## + educ:tenure     1      7158 112732885 10970
## + tenure:married  1      6599 112733444 10970
## + exper:tenure    1      6552 112733491 10970
## + age:urban       1      2718 112737325 10970
## + married:south   1      2300 112737743 10970
## + exper:married   1      1983 112738060 10970
## + educ:sibs       1       292 112739751 10970
## + hours:black     1       171 112739872 10970
## + exper:black     1       158 112739885 10970
## + KWW:tenure      1         6 112740037 10970
## + exper:sibs      1         0 112740042 10970
## - south           1    527821 113267864 10970
## - tenure          1    566619 113306661 10970
## - hours           1    570019 113310062 10970
## - exper           1    917406 113657449 10973
## - IQ              1   1095767 113835810 10975
## - black           1   1105170 113845212 10975
## - KWW:educ        1   1911037 114651080 10981
## - married         1   2750422 115490465 10988
## - urban           1   4874564 117614607 11005
## 
## Step:  AIC=10962.74
## wage ~ hours + IQ + KWW + educ + exper + tenure + age + married + 
##     black + south + urban + sibs + KWW:educ + hours:south
## 
##                  Df Sum of Sq       RSS   AIC
## + educ:exper      1    714377 111208593 10959
## + hours:age       1    660933 111262037 10959
## + KWW:black       1    641840 111281130 10959
## + married:sibs    1    543455 111379515 10960
## + black:sibs      1    543307 111379663 10960
## + KWW:age         1    528609 111394361 10960
## + hours:KWW       1    500513 111422457 10961
## + south:urban     1    481332 111441638 10961
## + educ:urban      1    479930 111443040 10961
## - sibs            1      1402 111924372 10961
## + educ:age        1    442742 111480227 10961
## - age             1     58057 111981027 10961
## + tenure:black    1    357266 111565704 10962
## + IQ:sibs         1    313593 111609377 10962
## + black:south     1    310588 111612382 10962
## + KWW:exper       1    309651 111613319 10962
## + educ:married    1    307083 111615887 10962
## + KWW:married     1    290622 111632348 10962
## + black:urban     1    254038 111668932 10963
## <none>                        111922970 10963
## + tenure:south    1    226508 111696462 10963
## + hours:sibs      1    203816 111719154 10963
## + hours:exper     1    190664 111732306 10963
## + age:sibs        1    186799 111736171 10963
## + exper:age       1    170085 111752885 10963
## + exper:south     1    136770 111786200 10964
## + educ:south      1    135744 111787226 10964
## + tenure:age      1    134542 111788428 10964
## + tenure:urban    1    125728 111797242 10964
## + hours:tenure    1    116715 111806255 10964
## + hours:married   1    114291 111808679 10964
## + age:married     1    101965 111821005 10964
## + IQ:urban        1    100857 111822113 10964
## + IQ:black        1     99401 111823569 10964
## + age:black       1     85715 111837255 10964
## + IQ:KWW          1     73083 111849887 10964
## + educ:black      1     62829 111860141 10964
## + hours:educ      1     56285 111866685 10964
## + KWW:sibs        1     53792 111869178 10964
## + exper:urban     1     51192 111871778 10964
## + hours:IQ        1     47289 111875681 10964
## + hours:black     1     44304 111878666 10964
## + IQ:married      1     40532 111882438 10964
## + urban:sibs      1     29585 111893385 10964
## + IQ:tenure       1     24936 111898034 10964
## + married:black   1     21653 111901317 10965
## + IQ:age          1     18975 111903995 10965
## + IQ:exper        1     18638 111904332 10965
## + exper:tenure    1     18376 111904594 10965
## + tenure:sibs     1     16849 111906121 10965
## + IQ:educ         1     13790 111909180 10965
## + age:south       1     11702 111911268 10965
## + IQ:south        1      9392 111913578 10965
## + educ:tenure     1      9268 111913702 10965
## + married:urban   1      8848 111914122 10965
## + south:sibs      1      3758 111919212 10965
## + KWW:urban       1      3149 111919821 10965
## + tenure:married  1      2451 111920519 10965
## + exper:black     1      2145 111920825 10965
## + exper:married   1      1927 111921043 10965
## + age:urban       1      1891 111921079 10965
## + KWW:south       1      1390 111921580 10965
## + married:south   1       800 111922170 10965
## + hours:urban     1       751 111922219 10965
## + KWW:tenure      1       421 111922549 10965
## + educ:sibs       1        95 111922875 10965
## + exper:sibs      1         1 111922969 10965
## - tenure          1    554537 112477507 10965
## - hours:south     1    817073 112740043 10968
## - exper           1    930661 112853631 10968
## - black           1   1089791 113012761 10970
## - IQ              1   1107439 113030409 10970
## - KWW:educ        1   2102942 114025912 10978
## - married         1   2538323 114461293 10982
## - urban           1   4874022 116796992 11001
## 
## Step:  AIC=10958.76
## wage ~ hours + IQ + KWW + educ + exper + tenure + age + married + 
##     black + south + urban + sibs + KWW:educ + hours:south + educ:exper
## 
##                  Df Sum of Sq       RSS   AIC
## + hours:age       1    660743 110547850 10955
## + KWW:black       1    600325 110608267 10956
## + hours:KWW       1    525220 110683373 10956
## + educ:urban      1    484388 110724205 10957
## + married:sibs    1    483882 110724711 10957
## + black:sibs      1    480063 110728530 10957
## - sibs            1        34 111208627 10957
## + south:urban     1    463078 110745515 10957
## + IQ:exper        1    406361 110802232 10957
## + tenure:black    1    399586 110809007 10957
## - age             1    124398 111332991 10958
## + IQ:sibs         1    302204 110906389 10958
## + black:south     1    291432 110917161 10958
## + age:sibs        1    286905 110921688 10958
## + KWW:age         1    276216 110932377 10958
## + black:urban     1    241347 110967246 10959
## <none>                        111208593 10959
## + exper:south     1    218073 110990520 10959
## + KWW:married     1    211555 110997038 10959
## + educ:married    1    210413 110998180 10959
## + tenure:south    1    209489 110999104 10959
## + hours:sibs      1    189802 111018791 10959
## + tenure:age      1    156068 111052525 10959
## + hours:exper     1    150329 111058264 10960
## + educ:black      1    125655 111082938 10960
## + tenure:urban    1    122549 111086043 10960
## + educ:south      1    115964 111092629 10960
## + hours:tenure    1    112868 111095725 10960
## + IQ:urban        1    107678 111100915 10960
## + age:married     1     96706 111111887 10960
## + educ:age        1     93696 111114896 10960
## + hours:married   1     93678 111114915 10960
## + IQ:black        1     90928 111117665 10960
## + hours:educ      1     87490 111121103 10960
## + IQ:educ         1     81206 111127386 10960
## + exper:age       1     73850 111134743 10960
## + KWW:exper       1     63640 111144953 10960
## + exper:urban     1     59434 111149159 10960
## + hours:IQ        1     59199 111149394 10960
## + hours:black     1     54469 111154124 10960
## + age:black       1     44306 111164287 10960
## + IQ:tenure       1     41461 111167132 10960
## + IQ:KWW          1     39868 111168725 10960
## + married:black   1     39356 111169237 10960
## + exper:black     1     37781 111170812 10960
## + urban:sibs      1     35462 111173131 10960
## + KWW:sibs        1     35391 111173202 10960
## + educ:tenure     1     29338 111179255 10960
## + IQ:married      1     21904 111186689 10961
## + exper:tenure    1     16953 111191640 10961
## + exper:sibs      1     16457 111192136 10961
## + tenure:sibs     1     11858 111196735 10961
## + KWW:tenure      1     11629 111196964 10961
## + tenure:married  1     11391 111197202 10961
## + married:urban   1     10102 111198491 10961
## + exper:married   1      9490 111199103 10961
## + IQ:south        1      8879 111199714 10961
## + south:sibs      1      6916 111201677 10961
## + IQ:age          1      5590 111203003 10961
## + hours:urban     1      3569 111205024 10961
## + age:south       1      1556 111207037 10961
## + married:south   1      1381 111207212 10961
## + KWW:urban       1       987 111207606 10961
## + KWW:south       1       651 111207942 10961
## + age:urban       1       265 111208328 10961
## + educ:sibs       1        99 111208494 10961
## - tenure          1    625711 111834304 10962
## - educ:exper      1    714377 111922970 10963
## - hours:south     1    811580 112020173 10964
## - IQ              1   1096866 112305459 10966
## - black           1   1103148 112311741 10966
## - KWW:educ        1   2156607 113365200 10975
## - married         1   2563689 113772282 10978
## - urban           1   4871756 116080349 10997
## 
## Step:  AIC=10955.19
## wage ~ hours + IQ + KWW + educ + exper + tenure + age + married + 
##     black + south + urban + sibs + KWW:educ + hours:south + educ:exper + 
##     hours:age
## 
##                  Df Sum of Sq       RSS   AIC
## + KWW:black       1    595742 109952108 10952
## + black:sibs      1    493258 110054592 10953
## + married:sibs    1    479687 110068163 10953
## - sibs            1       383 110548233 10953
## + south:urban     1    467160 110080689 10953
## + educ:urban      1    455769 110092081 10953
## + IQ:exper        1    435120 110112729 10954
## + tenure:black    1    409685 110138164 10954
## + age:sibs        1    338231 110209619 10954
## + IQ:sibs         1    317741 110230108 10954
## + hours:sibs      1    266360 110281489 10955
## + black:south     1    263143 110284706 10955
## + black:urban     1    243458 110304392 10955
## <none>                        110547850 10955
## + KWW:married     1    212695 110335154 10955
## + exper:south     1    208634 110339216 10955
## + hours:tenure    1    189084 110358765 10956
## + educ:married    1    181201 110366649 10956
## + KWW:age         1    177889 110369961 10956
## + hours:KWW       1    171760 110376090 10956
## + tenure:south    1    156310 110391539 10956
## + educ:black      1    151475 110396374 10956
## + tenure:age      1    131900 110415949 10956
## + educ:south      1    129305 110418544 10956
## + IQ:urban        1    114289 110433561 10956
## + IQ:educ         1     97607 110450242 10956
## + tenure:urban    1     96942 110450907 10956
## + IQ:black        1     89715 110458135 10956
## + age:married     1     81771 110466079 10956
## + exper:black     1     75974 110471876 10956
## + hours:married   1     71498 110476351 10957
## + hours:black     1     62424 110485425 10957
## + educ:age        1     62318 110485531 10957
## + exper:age       1     54545 110493305 10957
## + married:black   1     51560 110496290 10957
## + exper:urban     1     49432 110498418 10957
## + IQ:KWW          1     46118 110501732 10957
## + hours:educ      1     45908 110501942 10957
## + KWW:exper       1     41964 110505885 10957
## + IQ:tenure       1     40064 110507785 10957
## + educ:tenure     1     34325 110513525 10957
## + hours:IQ        1     33455 110514394 10957
## + urban:sibs      1     28521 110519329 10957
## + KWW:sibs        1     27308 110520541 10957
## + IQ:married      1     22101 110525748 10957
## + IQ:age          1     17949 110529901 10957
## + KWW:tenure      1     16701 110531149 10957
## + exper:tenure    1     16371 110531478 10957
## + exper:sibs      1     13302 110534548 10957
## + tenure:married  1     12583 110535266 10957
## + IQ:south        1     12007 110535843 10957
## + age:black       1     10266 110537584 10957
## + south:sibs      1      7088 110540761 10957
## + tenure:sibs     1      5061 110542788 10957
## + hours:urban     1      4108 110543742 10957
## + exper:married   1      3968 110543882 10957
## + age:urban       1      2041 110545809 10957
## + married:urban   1      1795 110546055 10957
## + married:south   1      1081 110546769 10957
## + educ:sibs       1       980 110546870 10957
## + KWW:urban       1       593 110547256 10957
## + hours:exper     1       438 110547411 10957
## + age:south       1       197 110547652 10957
## + KWW:south       1        53 110547797 10957
## - hours:age       1    660743 111208593 10959
## - tenure          1    681596 111229446 10959
## - educ:exper      1    714187 111262037 10959
## - IQ              1   1000072 111547921 10962
## - hours:south     1   1052421 111600271 10962
## - black           1   1101064 111648913 10962
## - KWW:educ        1   2199037 112746887 10972
## - married         1   2599903 113147753 10975
## - urban           1   4709989 115257838 10992
## 
## Step:  AIC=10952.13
## wage ~ hours + IQ + KWW + educ + exper + tenure + age + married + 
##     black + south + urban + sibs + KWW:educ + hours:south + educ:exper + 
##     hours:age + KWW:black
## 
##                  Df Sum of Sq       RSS   AIC
## + educ:urban      1    554648 109397460 10949
## + IQ:exper        1    506033 109446074 10950
## - sibs            1     19457 109971565 10950
## + south:urban     1    419655 109532453 10951
## + married:sibs    1    386146 109565962 10951
## + age:sibs        1    369456 109582652 10951
## + tenure:black    1    339277 109612831 10951
## + black:south     1    279647 109672461 10952
## <none>                        109952108 10952
## + hours:sibs      1    230458 109721650 10952
## + IQ:sibs         1    215984 109736123 10952
## + hours:tenure    1    211883 109740225 10952
## + exper:south     1    204404 109747704 10952
## + black:sibs      1    195739 109756369 10952
## + KWW:age         1    186375 109765733 10952
## + educ:married    1    156799 109795309 10953
## + tenure:age      1    143678 109808430 10953
## + black:urban     1    143529 109808579 10953
## + KWW:married     1    140712 109811396 10953
## + educ:south      1    134442 109817666 10953
## + IQ:urban        1    130450 109821658 10953
## + tenure:urban    1    118316 109833792 10953
## + tenure:south    1    118258 109833850 10953
## + hours:KWW       1    108321 109843787 10953
## + IQ:educ         1    102260 109849848 10953
## + educ:age        1     82409 109869699 10953
## + hours:married   1     75462 109876646 10954
## + exper:black     1     71424 109880684 10954
## + married:black   1     66723 109885385 10954
## + age:married     1     65114 109886994 10954
## + exper:urban     1     64681 109887427 10954
## + KWW:tenure      1     47457 109904651 10954
## + exper:age       1     41165 109910943 10954
## + hours:educ      1     40651 109911457 10954
## + IQ:tenure       1     40129 109911979 10954
## + hours:black     1     36389 109915719 10954
## + educ:tenure     1     36031 109916076 10954
## + KWW:exper       1     34017 109918091 10954
## + IQ:age          1     33417 109918691 10954
## + urban:sibs      1     26306 109925802 10954
## + educ:black      1     25930 109926178 10954
## + IQ:south        1     24050 109928058 10954
## + hours:IQ        1     19444 109932664 10954
## + south:sibs      1     18240 109933868 10954
## + tenure:married  1     16072 109936035 10954
## + exper:sibs      1     13792 109938316 10954
## + married:south   1     12694 109939413 10954
## + exper:tenure    1     12137 109939971 10954
## + KWW:south       1     10535 109941573 10954
## + IQ:married      1      9760 109942348 10954
## + hours:urban     1      6628 109945479 10954
## + KWW:urban       1      6229 109945878 10954
## + educ:sibs       1      6210 109945898 10954
## + tenure:sibs     1      5613 109946495 10954
## + KWW:sibs        1      3771 109948337 10954
## + married:urban   1      3308 109948800 10954
## + exper:married   1      2740 109949368 10954
## + age:urban       1      2032 109950076 10954
## + age:black       1      1703 109950405 10954
## + IQ:KWW          1       200 109951908 10954
## + IQ:black        1       147 109951960 10954
## + age:south       1       104 109952004 10954
## + hours:exper     1       102 109952006 10954
## - tenure          1    582305 110534412 10955
## - KWW:black       1    595742 110547850 10955
## - hours:age       1    656160 110608267 10956
## - educ:exper      1    672833 110624940 10956
## - hours:south     1    977443 110929551 10958
## - IQ              1   1028420 110980528 10959
## - KWW:educ        1   1696292 111648400 10964
## - married         1   2560152 112512260 10972
## - urban           1   4679040 114631147 10989
## 
## Step:  AIC=10949.4
## wage ~ hours + IQ + KWW + educ + exper + tenure + age + married + 
##     black + south + urban + sibs + KWW:educ + hours:south + educ:exper + 
##     hours:age + KWW:black + educ:urban
## 
##                  Df Sum of Sq       RSS   AIC
## + IQ:exper        1    505093 108892366 10947
## - sibs            1     19527 109416987 10948
## + married:sibs    1    378315 109019144 10948
## + age:sibs        1    338296 109059163 10948
## + tenure:black    1    313688 109083772 10949
## + south:urban     1    293618 109103841 10949
## + black:south     1    293270 109104190 10949
## + hours:sibs      1    238947 109158513 10949
## <none>                        109397460 10949
## + IQ:sibs         1    220113 109177347 10950
## + black:sibs      1    199314 109198146 10950
## + exper:south     1    199030 109198430 10950
## + KWW:age         1    193304 109204156 10950
## + educ:married    1    182244 109215215 10950
## + educ:south      1    178084 109219375 10950
## + hours:tenure    1    158154 109239306 10950
## + KWW:married     1    148352 109249108 10950
## + tenure:south    1    130815 109266644 10950
## + tenure:age      1    127071 109270389 10950
## + educ:age        1    123308 109274152 10950
## + IQ:educ         1    117014 109280445 10950
## + hours:KWW       1     94403 109303056 10951
## + tenure:urban    1     93411 109304049 10951
## + exper:black     1     89539 109307920 10951
## + hours:married   1     88851 109308609 10951
## + age:married     1     87240 109310219 10951
## + married:black   1     72449 109325010 10951
## + black:urban     1     68142 109329318 10951
## + educ:black      1     50821 109346638 10951
## + KWW:urban       1     50451 109347009 10951
## + hours:black     1     48628 109348832 10951
## + exper:age       1     45809 109351650 10951
## + KWW:exper       1     45394 109352065 10951
## + IQ:south        1     38425 109359035 10951
## + hours:educ      1     31954 109365506 10951
## + IQ:tenure       1     31626 109365833 10951
## + educ:tenure     1     29212 109368248 10951
## + KWW:tenure      1     28064 109369396 10951
## + KWW:south       1     24944 109372515 10951
## + south:sibs      1     24515 109372945 10951
## + IQ:age          1     24436 109373024 10951
## + hours:IQ        1     20075 109377384 10951
## + hours:urban     1     16748 109380711 10951
## + IQ:married      1     14435 109383025 10951
## + exper:urban     1     10859 109386600 10951
## + educ:sibs       1     10799 109386661 10951
## + married:south   1      9637 109387823 10951
## + tenure:sibs     1      9364 109388096 10951
## + exper:tenure    1      8763 109388697 10951
## + exper:sibs      1      7290 109390170 10951
## + tenure:married  1      5634 109391825 10951
## + age:south       1      3993 109393467 10951
## + IQ:urban        1      2829 109394631 10951
## + age:black       1      2448 109395011 10951
## + age:urban       1      2123 109395337 10951
## + exper:married   1      1264 109396196 10951
## + IQ:black        1       405 109397055 10951
## + KWW:sibs        1       305 109397154 10951
## + IQ:KWW          1       196 109397264 10951
## + married:urban   1        93 109397367 10951
## + urban:sibs      1        34 109397425 10951
## + hours:exper     1         1 109397459 10951
## - tenure          1    528788 109926247 10952
## - educ:urban      1    554648 109952108 10952
## - hours:age       1    624279 110021739 10953
## - educ:exper      1    674128 110071587 10953
## - KWW:black       1    694621 110092081 10953
## - hours:south     1    984400 110381860 10956
## - IQ              1   1127889 110525349 10957
## - KWW:educ        1   1431244 110828704 10960
## - married         1   2474614 111872074 10968
## 
## Step:  AIC=10947.08
## wage ~ hours + IQ + KWW + educ + exper + tenure + age + married + 
##     black + south + urban + sibs + KWW:educ + hours:south + educ:exper + 
##     hours:age + KWW:black + educ:urban + IQ:exper
## 
##                  Df Sum of Sq       RSS   AIC
## - sibs            1     18534 108910900 10945
## + married:sibs    1    381996 108510370 10946
## + black:south     1    301685 108590681 10946
## + tenure:black    1    299788 108592578 10946
## + south:urban     1    288156 108604210 10947
## + KWW:age         1    283894 108608473 10947
## + age:sibs        1    263436 108628931 10947
## <none>                        108892366 10947
## + educ:south      1    222612 108669755 10947
## + hours:sibs      1    193761 108698606 10947
## + KWW:married     1    185026 108707340 10948
## + educ:married    1    174946 108717420 10948
## + hours:tenure    1    170092 108722274 10948
## + KWW:exper       1    149029 108743337 10948
## + black:sibs      1    147544 108744822 10948
## + IQ:sibs         1    143621 108748745 10948
## + educ:age        1    142317 108750049 10948
## + tenure:south    1    139591 108752776 10948
## + tenure:age      1    107018 108785348 10948
## + exper:south     1    101277 108791089 10948
## + hours:married   1    100270 108792097 10948
## + tenure:urban    1     96412 108795954 10948
## + hours:KWW       1     95520 108796846 10948
## + age:married     1     82831 108809535 10948
## + married:black   1     63333 108829033 10948
## + black:urban     1     57468 108834898 10949
## + exper:age       1     55400 108836966 10949
## + IQ:married      1     54015 108838352 10949
## + IQ:age          1     52745 108839621 10949
## + IQ:south        1     48254 108844112 10949
## + hours:black     1     41513 108850854 10949
## + KWW:urban       1     37534 108854832 10949
## + educ:tenure     1     36106 108856260 10949
## + educ:sibs       1     31021 108861346 10949
## + hours:educ      1     30199 108862168 10949
## + south:sibs      1     29936 108862430 10949
## + hours:urban     1     24537 108867829 10949
## + KWW:south       1     19811 108872555 10949
## + hours:IQ        1     18599 108873767 10949
## + educ:black      1     18088 108874278 10949
## + KWW:tenure      1     15302 108877064 10949
## + exper:urban     1     13400 108878966 10949
## + IQ:educ         1     11675 108880691 10949
## + IQ:urban        1     11339 108881027 10949
## + tenure:sibs     1     10475 108881892 10949
## + married:south   1      8622 108883744 10949
## + IQ:black        1      8353 108884013 10949
## + age:black       1      6525 108885841 10949
## + tenure:married  1      5066 108887300 10949
## + IQ:tenure       1      4622 108887744 10949
## + age:urban       1      4113 108888253 10949
## + exper:black     1      1999 108890367 10949
## + exper:sibs      1      1514 108890852 10949
## + exper:married   1      1389 108890977 10949
## + IQ:KWW          1      1053 108891314 10949
## + KWW:sibs        1      1032 108891334 10949
## + urban:sibs      1       449 108891918 10949
## + hours:exper     1       398 108891968 10949
## + exper:tenure    1       297 108892069 10949
## + married:urban   1        35 108892331 10949
## + age:south       1        19 108892347 10949
## - IQ:exper        1    505093 109397460 10949
## - educ:urban      1    553708 109446074 10950
## - tenure          1    565987 109458354 10950
## - hours:age       1    654297 109546664 10951
## - KWW:black       1    770361 109662728 10952
## - hours:south     1   1039019 109931385 10954
## - educ:exper      1   1133904 110026270 10955
## - KWW:educ        1   1277132 110169498 10956
## - married         1   2510032 111402398 10966
## 
## Step:  AIC=10945.24
## wage ~ hours + IQ + KWW + educ + exper + tenure + age + married + 
##     black + south + urban + KWW:educ + hours:south + educ:exper + 
##     hours:age + KWW:black + educ:urban + IQ:exper
## 
##                  Df Sum of Sq       RSS   AIC
## + black:south     1    305279 108605621 10945
## + tenure:black    1    294360 108616540 10945
## + south:urban     1    288402 108622498 10945
## + KWW:age         1    280039 108630861 10945
## <none>                        108910900 10945
## + educ:south      1    225691 108685209 10945
## + KWW:married     1    188755 108722145 10946
## + educ:married    1    175523 108735377 10946
## + hours:tenure    1    164254 108746646 10946
## + KWW:exper       1    149097 108761803 10946
## + tenure:south    1    142289 108768611 10946
## + educ:age        1    141465 108769435 10946
## + tenure:age      1    107022 108803878 10946
## + exper:south     1    106247 108804653 10946
## + hours:KWW       1     98065 108812835 10946
## + hours:married   1     97440 108813460 10946
## + tenure:urban    1     96307 108814593 10946
## + age:married     1     79810 108831090 10947
## + married:black   1     63145 108847755 10947
## + exper:age       1     58854 108852046 10947
## + IQ:married      1     55207 108855693 10947
## + black:urban     1     52060 108858840 10947
## + IQ:south        1     50889 108860011 10947
## + IQ:age          1     49940 108860960 10947
## + hours:black     1     41036 108869864 10947
## + KWW:urban       1     36317 108874583 10947
## + educ:tenure     1     36177 108874723 10947
## + hours:educ      1     32017 108878883 10947
## + hours:urban     1     22860 108888040 10947
## + KWW:south       1     20173 108890727 10947
## + hours:IQ        1     19612 108891288 10947
## + sibs            1     18534 108892366 10947
## + educ:black      1     16763 108894137 10947
## + exper:urban     1     14733 108896167 10947
## + KWW:tenure      1     14096 108896804 10947
## + IQ:urban        1     12768 108898132 10947
## + IQ:educ         1      9628 108901272 10947
## + IQ:black        1      8341 108902559 10947
## + married:south   1      7190 108903710 10947
## + age:black       1      6480 108904420 10947
## + age:urban       1      4931 108905969 10947
## + IQ:tenure       1      4225 108906675 10947
## + tenure:married  1      4015 108906885 10947
## + exper:black     1      2096 108908804 10947
## + exper:married   1      1468 108909432 10947
## + IQ:KWW          1      1453 108909447 10947
## + hours:exper     1       382 108910518 10947
## + exper:tenure    1       365 108910535 10947
## + age:south       1        62 108910838 10947
## + married:urban   1        28 108910872 10947
## - IQ:exper        1    506087 109416987 10948
## - educ:urban      1    553639 109464539 10948
## - tenure          1    570102 109481002 10948
## - hours:age       1    648272 109559172 10949
## - KWW:black       1    751828 109662728 10950
## - hours:south     1   1062585 109973485 10952
## - educ:exper      1   1151590 110062490 10953
## - KWW:educ        1   1282127 110193027 10954
## - married         1   2503295 111414195 10964
## 
## Step:  AIC=10944.61
## wage ~ hours + IQ + KWW + educ + exper + tenure + age + married + 
##     black + south + urban + KWW:educ + hours:south + educ:exper + 
##     hours:age + KWW:black + educ:urban + IQ:exper + black:south
## 
##                  Df Sum of Sq       RSS   AIC
## + KWW:age         1    298327 108307295 10944
## + tenure:black    1    265921 108339701 10944
## <none>                        108605621 10945
## + south:urban     1    231570 108374052 10945
## + black:urban     1    176159 108429462 10945
## - black:south     1    305279 108910900 10945
## + educ:married    1    158943 108446679 10945
## + educ:south      1    154547 108451075 10945
## + KWW:exper       1    153713 108451908 10945
## + hours:tenure    1    145989 108459632 10945
## + educ:age        1    144489 108461132 10945
## + KWW:married     1    134822 108470800 10946
## + married:black   1    126803 108478818 10946
## + exper:south     1    123592 108482029 10946
## + tenure:age      1    117629 108487992 10946
## + tenure:south    1    113252 108492369 10946
## + hours:married   1    109572 108496049 10946
## + hours:KWW       1     92515 108513107 10946
## + tenure:urban    1     84909 108520712 10946
## + age:married     1     77821 108527800 10946
## + exper:age       1     61400 108544221 10946
## + IQ:age          1     52401 108553221 10946
## + hours:black     1     35522 108570100 10946
## + hours:educ      1     34496 108571125 10946
## + IQ:married      1     30322 108575299 10946
## + educ:tenure     1     26621 108579000 10946
## + hours:urban     1     21085 108584536 10946
## + age:black       1     20581 108585040 10946
## + KWW:urban       1     19983 108585638 10946
## + KWW:tenure      1     15772 108589850 10946
## + sibs            1     14940 108590681 10946
## + exper:urban     1     14449 108591173 10946
## + hours:IQ        1     12691 108592930 10946
## + married:south   1     11541 108594081 10946
## + tenure:married  1      8064 108597557 10946
## + IQ:educ         1      7581 108598040 10946
## + educ:black      1      7044 108598577 10947
## + age:urban       1      4554 108601068 10947
## + IQ:black        1      2551 108603070 10947
## + IQ:tenure       1      2095 108603526 10947
## + IQ:urban        1      2028 108603593 10947
## + exper:married   1      1309 108604312 10947
## + IQ:south        1       995 108604627 10947
## + exper:tenure    1       797 108604824 10947
## + married:urban   1       608 108605013 10947
## + IQ:KWW          1       605 108605016 10947
## + exper:black     1       355 108605267 10947
## + age:south       1       101 108605521 10947
## + hours:exper     1        52 108605569 10947
## + KWW:south       1        50 108605572 10947
## - IQ:exper        1    514459 109120080 10947
## - educ:urban      1    567525 109173147 10948
## - tenure          1    573785 109179407 10948
## - hours:age       1    618667 109224288 10948
## - KWW:black       1    777029 109382650 10949
## - hours:south     1    912034 109517656 10950
## - educ:exper      1   1134103 109739725 10952
## - KWW:educ        1   1223607 109829229 10953
## - married         1   2642563 111248184 10965
## 
## Step:  AIC=10944.04
## wage ~ hours + IQ + KWW + educ + exper + tenure + age + married + 
##     black + south + urban + KWW:educ + hours:south + educ:exper + 
##     hours:age + KWW:black + educ:urban + IQ:exper + black:south + 
##     KWW:age
## 
##                  Df Sum of Sq       RSS   AIC
## + tenure:black    1    314372 107992923 10943
## <none>                        108307295 10944
## + south:urban     1    219869 108087425 10944
## + educ:south      1    181442 108125853 10944
## + hours:tenure    1    172071 108135224 10945
## - KWW:age         1    298327 108605621 10945
## + black:urban     1    163759 108143536 10945
## - black:south     1    323567 108630861 10945
## + married:black   1    136031 108171263 10945
## + educ:married    1    136030 108171264 10945
## + tenure:age      1    127289 108180006 10945
## + tenure:south    1    123367 108183927 10945
## + hours:married   1    122822 108184473 10945
## + hours:KWW       1    119425 108187870 10945
## + exper:south     1    103727 108203567 10945
## + tenure:urban    1    100713 108206581 10945
## + KWW:married     1     87961 108219334 10945
## + exper:age       1     69598 108237696 10945
## + age:married     1     58226 108249069 10946
## + KWW:tenure      1     56214 108251081 10946
## + educ:age        1     53586 108253709 10946
## + hours:black     1     39243 108268052 10946
## + hours:educ      1     39216 108268079 10946
## + educ:tenure     1     37122 108270173 10946
## + KWW:urban       1     25920 108281375 10946
## + married:south   1     24550 108282744 10946
## + IQ:married      1     19593 108287702 10946
## + sibs            1     18425 108288870 10946
## + hours:IQ        1     17420 108289874 10946
## + hours:urban     1     16063 108291232 10946
## + KWW:exper       1     14868 108292427 10946
## + IQ:urban        1      8415 108298879 10946
## + tenure:married  1      7947 108299348 10946
## + educ:black      1      7860 108299434 10946
## + IQ:tenure       1      7749 108299546 10946
## + IQ:age          1      6286 108301009 10946
## + exper:urban     1      5623 108301672 10946
## + IQ:black        1      4501 108302793 10946
## + IQ:educ         1      3686 108303608 10946
## + IQ:south        1      2691 108304603 10946
## + married:urban   1      2686 108304608 10946
## + exper:black     1      1047 108306247 10946
## + age:black       1       826 108306468 10946
## + age:south       1       702 108306592 10946
## + exper:tenure    1       485 108306809 10946
## + exper:married   1       259 108307036 10946
## + IQ:KWW          1       214 108307081 10946
## + KWW:south       1       108 108307187 10946
## + age:urban       1        38 108307256 10946
## + hours:exper     1         1 108307294 10946
## - hours:age       1    500706 108808000 10946
## - tenure          1    526154 108833448 10947
## - educ:urban      1    576645 108883939 10947
## - IQ:exper        1    608701 108915996 10947
## - KWW:black       1    795200 109102495 10949
## - hours:south     1    847708 109155003 10949
## - educ:exper      1    911431 109218726 10950
## - KWW:educ        1   1158970 109466265 10952
## - married         1   2523426 110830721 10964
## 
## Step:  AIC=10943.32
## wage ~ hours + IQ + KWW + educ + exper + tenure + age + married + 
##     black + south + urban + KWW:educ + hours:south + educ:exper + 
##     hours:age + KWW:black + educ:urban + IQ:exper + black:south + 
##     KWW:age + tenure:black
## 
##                  Df Sum of Sq       RSS   AIC
## <none>                        107992923 10943
## + south:urban     1    226760 107766163 10943
## + educ:south      1    172188 107820735 10944
## - black:south     1    293261 108286184 10944
## + educ:married    1    152773 107840150 10944
## - tenure:black    1    314372 108307295 10944
## + black:urban     1    140382 107852540 10944
## + hours:tenure    1    131307 107861615 10944
## + tenure:urban    1    129164 107863758 10944
## + exper:south     1    127949 107864973 10944
## + hours:married   1    119348 107873574 10944
## + hours:KWW       1    116235 107876688 10944
## - KWW:age         1    346778 108339701 10944
## + KWW:married     1    104562 107888361 10944
## + tenure:age      1     96982 107895941 10944
## + exper:age       1     80304 107912619 10945
## + tenure:south    1     77999 107914923 10945
## + married:black   1     69989 107922933 10945
## + educ:age        1     58344 107934579 10945
## + hours:educ      1     40395 107952527 10945
## + age:married     1     36308 107956614 10945
## + IQ:married      1     34472 107958451 10945
## + KWW:urban       1     25931 107966991 10945
## + married:south   1     25172 107967751 10945
## + sibs            1     24630 107968293 10945
## + hours:black     1     22216 107970706 10945
## + hours:urban     1     19490 107973432 10945
## + age:black       1     18419 107974504 10945
## + educ:tenure     1     13074 107979849 10945
## + hours:IQ        1     12379 107980543 10945
## + IQ:age          1     12336 107980586 10945
## + KWW:exper       1     12234 107980689 10945
## + IQ:urban        1     11707 107981216 10945
## + IQ:tenure       1      9040 107983883 10945
## + educ:black      1      6092 107986830 10945
## + exper:black     1      5723 107987200 10945
## + KWW:tenure      1      5494 107987429 10945
## + tenure:married  1      5167 107987756 10945
## + IQ:educ         1      4939 107987984 10945
## + IQ:black        1      3222 107989700 10945
## + IQ:south        1      2497 107990426 10945
## + exper:urban     1      1973 107990950 10945
## + age:south       1      1677 107991246 10945
## + KWW:south       1      1673 107991250 10945
## + married:urban   1       973 107991950 10945
## + exper:tenure    1       694 107992228 10945
## + IQ:KWW          1       355 107992568 10945
## + exper:married   1       343 107992579 10945
## + hours:exper     1       205 107992717 10945
## + age:urban       1        75 107992847 10945
## - hours:age       1    501050 108493973 10946
## - educ:urban      1    550444 108543367 10946
## - IQ:exper        1    601609 108594531 10946
## - KWW:black       1    705363 108698286 10947
## - hours:south     1    816354 108809277 10948
## - educ:exper      1    929219 108922142 10949
## - KWW:educ        1   1172742 109165664 10951
## - married         1   2364942 110357865 10962
# The command "step" adds and subtracts coefficients to maximize a measure of
# goodness of fit. 
summary(stepwise.model.interactions)
## 
## Call:
## lm(formula = wage ~ hours + IQ + KWW + educ + exper + tenure + 
##     age + married + black + south + urban + KWW:educ + hours:south + 
##     educ:exper + hours:age + KWW:black + educ:urban + IQ:exper + 
##     black:south + KWW:age + tenure:black, data = wages)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -840.95 -217.56  -36.92  175.98 1972.19 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  3557.21923  993.37267   3.581  0.00036 ***
## hours         -40.59382   16.84503  -2.410  0.01616 *  
## IQ              8.60609    2.62919   3.273  0.00110 ** 
## KWW           -52.96021   19.81093  -2.673  0.00765 ** 
## educ         -105.91470   32.69827  -3.239  0.00124 ** 
## exper          -0.07971   22.30843  -0.004  0.99715    
## tenure          3.69311    2.49869   1.478  0.13975    
## age           -73.93581   27.83318  -2.656  0.00804 ** 
## married       167.53913   37.46867   4.471 8.75e-06 ***
## black         237.42907  168.52142   1.409  0.15921    
## south        -416.46084  149.65943  -2.783  0.00550 ** 
## urban        -178.50960  159.21454  -1.121  0.26250    
## KWW:educ        2.25091    0.71486   3.149  0.00169 ** 
## hours:south     8.75759    3.33355   2.627  0.00876 ** 
## educ:exper      4.47284    1.59583   2.803  0.00517 ** 
## hours:age       1.02681    0.49890   2.058  0.03986 *  
## KWW:black     -11.40575    4.67067  -2.442  0.01480 *  
## educ:urban     25.36348   11.75748   2.157  0.03125 *  
## IQ:exper       -0.48403    0.21463  -2.255  0.02435 *  
## black:south  -112.74961   71.60609  -1.575  0.11570    
## KWW:age         0.92317    0.53916   1.712  0.08719 .  
## tenure:black   11.87634    7.28489   1.630  0.10339    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 343.9 on 913 degrees of freedom
## Multiple R-squared:  0.2929, Adjusted R-squared:  0.2766 
## F-statistic:    18 on 21 and 913 DF,  p-value: < 2.2e-16
###########################################################################
# CHANGE DESCRIPTION

######################### CODE CHANGE STARTS ############################
summary(wages)
##       wage            hours             IQ             KWW       
##  Min.   : 115.0   Min.   :20.00   Min.   : 50.0   Min.   :12.00  
##  1st Qu.: 669.0   1st Qu.:40.00   1st Qu.: 92.0   1st Qu.:31.00  
##  Median : 905.0   Median :40.00   Median :102.0   Median :37.00  
##  Mean   : 957.9   Mean   :43.93   Mean   :101.3   Mean   :35.74  
##  3rd Qu.:1160.0   3rd Qu.:48.00   3rd Qu.:112.0   3rd Qu.:41.00  
##  Max.   :3078.0   Max.   :80.00   Max.   :145.0   Max.   :56.00  
##                                                                  
##       educ           exper           tenure            age       
##  Min.   : 9.00   Min.   : 1.00   Min.   : 0.000   Min.   :28.00  
##  1st Qu.:12.00   1st Qu.: 8.00   1st Qu.: 3.000   1st Qu.:30.00  
##  Median :12.00   Median :11.00   Median : 7.000   Median :33.00  
##  Mean   :13.47   Mean   :11.56   Mean   : 7.234   Mean   :33.08  
##  3rd Qu.:16.00   3rd Qu.:15.00   3rd Qu.:11.000   3rd Qu.:36.00  
##  Max.   :18.00   Max.   :23.00   Max.   :22.000   Max.   :38.00  
##                                                                  
##     married          black            south            urban       
##  Min.   :0.000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
##  1st Qu.:1.000   1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:0.0000  
##  Median :1.000   Median :0.0000   Median :0.0000   Median :1.0000  
##  Mean   :0.893   Mean   :0.1283   Mean   :0.3412   Mean   :0.7176  
##  3rd Qu.:1.000   3rd Qu.:0.0000   3rd Qu.:1.0000   3rd Qu.:1.0000  
##  Max.   :1.000   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
##                                                                    
##       sibs           brthord           meduc           feduc      
##  Min.   : 0.000   Min.   : 1.000   Min.   : 0.00   Min.   : 0.00  
##  1st Qu.: 1.000   1st Qu.: 1.000   1st Qu.: 8.00   1st Qu.: 8.00  
##  Median : 2.000   Median : 2.000   Median :12.00   Median :10.00  
##  Mean   : 2.941   Mean   : 2.277   Mean   :10.68   Mean   :10.22  
##  3rd Qu.: 4.000   3rd Qu.: 3.000   3rd Qu.:12.00   3rd Qu.:12.00  
##  Max.   :14.000   Max.   :10.000   Max.   :18.00   Max.   :18.00  
##                   NA's   :83       NA's   :78      NA's   :194    
##      lwage      
##  Min.   :4.745  
##  1st Qu.:6.506  
##  Median :6.808  
##  Mean   :6.779  
##  3rd Qu.:7.056  
##  Max.   :8.032  
## 
includemothers.results <- tsls(lwage ~ educ + IQ + exper + age, ~ meduc + IQ + exper + age, data = wages)

includefathers.results <- tsls(lwage ~ educ + IQ + exper + age, ~ feduc + IQ + exper + age, data = wages)

children_pursuing_higher_education <- lm(lwage ~ educ + IQ + exper + age, data = wages)

print(summary(children_pursuing_higher_education))
## 
## Call:
## lm(formula = lwage ~ educ + IQ + exper + age, data = wages)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.90656 -0.21238  0.02434  0.25464  1.30919 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 4.8582877  0.1664242  29.192  < 2e-16 ***
## educ        0.0509697  0.0076026   6.704 3.51e-11 ***
## IQ          0.0059629  0.0009774   6.101 1.55e-09 ***
## exper       0.0131736  0.0038725   3.402 0.000698 ***
## age         0.0144485  0.0048571   2.975 0.003008 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3845 on 930 degrees of freedom
## Multiple R-squared:  0.1701, Adjusted R-squared:  0.1666 
## F-statistic: 47.67 on 4 and 930 DF,  p-value: < 2.2e-16
print(summary(includemothers.results))
## 
##  2SLS Estimates
## 
## Model Formula: lwage ~ educ + IQ + exper + age
## 
## Instruments: ~meduc + IQ + exper + age
## 
## Residuals:
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -1.73330 -0.24829  0.02359  0.00000  0.27781  1.37097 
## 
##                 Estimate   Std. Error  t value   Pr(>|t|)    
## (Intercept)  4.446498418  0.246121855 18.06625 < 2.22e-16 ***
## educ         0.150511015  0.041818095  3.59918 0.00033764 ***
## IQ           0.000123685  0.002705175  0.04572 0.96354284    
## exper        0.040804729  0.011355499  3.59339 0.00034513 ***
## age         -0.005344725  0.009633759 -0.55479 0.57918304    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4117258 on 852 degrees of freedom
print(summary(includefathers.results))
## 
##  2SLS Estimates
## 
## Model Formula: lwage ~ educ + IQ + exper + age
## 
## Instruments: ~feduc + IQ + exper + age
## 
## Residuals:
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -1.74150 -0.25702  0.01801  0.00000  0.28013  1.35028 
## 
##                  Estimate    Std. Error  t value   Pr(>|t|)    
## (Intercept)  4.5406150827  0.2298240892 19.75692 < 2.22e-16 ***
## educ         0.1434522479  0.0359274615  3.99283 7.1839e-05 ***
## IQ          -0.0002450379  0.0025959395 -0.09439    0.92482    
## exper        0.0395401035  0.0099648587  3.96795 7.9588e-05 ***
## age         -0.0036208557  0.0089080709 -0.40647    0.68452    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4112482 on 736 degrees of freedom
######################## CODE CHANGE ENDS ###############################

# For this change, I wanted to see if parents obtaining higher education
# would influence their child to also pursue higher education.

# To do this, I ran an instrumental variable regression 
# using "meduc" and "feduc" as instruments.

# Variables used that are assumed to be less related: IQ, exper, age

# My findings included:
# children_pursuing_higher_education "educ" Estimate is 0.05.

# With "feduc" (includefathers), the point estimate (PE) for "educ"
# increases to 0.14 (approximately 14% higher wages), meaning there's a 
# positive correlation between children pursuing higher education 
# and their father having higher education.

# With "meduc" (includemothers), the PE for "educ"
# increases to 0.15 (approximately 15% higher wages) meaning there's a 
# positive correlation between children pursuing higher 
# education and their mother having higher education.

# Summary: From the results, we can see that if parents have higher
# education, it may influence their child to also pursue higher 
# education, resulting in an increase in higher wages. 

# END OF CHANGE DESCRIPTION
#######################################################################