income=read.table("http://www.stat.umn.edu/alr/data/salary.txt",header=TRUE) attach(income) names(income) "Degree" "Rank" "Sex" "Year" "YSdeg" "Salary" regmodel=lm(Salary~Degree+factor(Rank)+Year+Degree+YSdeg) summary(regmodel) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 17373.45 1190.15 14.598 < 2e-16 *** Degree -1062.12 991.53 -1.071 0.290 factor(Rank)2 4713.92 1056.09 4.464 5.18e-05 *** factor(Rank)3 10509.62 1270.43 8.272 1.18e-10 *** Year 416.56 82.75 5.034 7.84e-06 *** YSdeg -81.22 69.87 -1.162 0.251 --- Residual standard error: 2414 on 46 degrees of freedom Multiple R-squared: 0.8499, Adjusted R-squared: 0.8336 F-statistic: 52.1 on 5 and 46 DF, p-value: < 2.2e-16 regmodel2=lm(Salary~Year+Degree+YSdeg+Sex+factor(Rank)) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 17134.66 1197.70 14.306 < 2e-16 *** Year 476.31 94.91 5.018 8.65e-06 *** Degree -1388.61 1018.75 -1.363 0.180 YSdeg -124.57 77.49 -1.608 0.115 Sex 1166.37 925.57 1.260 0.214 factor(Rank)2 5292.36 1145.40 4.621 3.22e-05 *** factor(Rank)3 11118.76 1351.77 8.225 1.62e-10 *** regmodel3=lm(Salary~Year+Degree+YSdeg+Sex*factor(Rank)) Estimate Std. Error t value Pr(>|t|) (Intercept) 17504.67 1284.95 13.623 < 2e-16 *** Year 522.14 105.53 4.948 1.20e-05 *** Degree -1501.51 1029.80 -1.458 0.1521 YSdeg -148.61 86.83 -1.711 0.0942 . Sex 444.30 1153.54 0.385 0.7020 factor(Rank)2 5119.00 1168.49 4.381 7.46e-05 *** factor(Rank)3 10539.36 1426.21 7.390 3.52e-09 *** Sex:factor(Rank)2 498.29 2449.00 0.203 0.8397 Sex:factor(Rank)3 2510.25 1925.98 1.303 0.1994 regmodel4=lm(Salary~Year+Degree+YSdeg+Sex) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 13884.22 1639.82 8.467 5.17e-11 *** Year 351.97 142.48 2.470 0.017185 * Degree 3299.35 1302.52 2.533 0.014704 * YSdeg 339.40 80.62 4.210 0.000114 *** Sex -1286.54 1313.09 -0.980 0.332209 mean(Salary[Sex==1])-mean(Salary[Sex==0]) -3339.647 table(Sex,Rank) Rank Sex 1 2 3 0 10 12 16 1 8 2 4 #### Now turn back to melanoma data for a second mel=read.table("http://www.stat.uiuc.edu/~jeffdoug/st425/Skin.txt",header=TRUE) attach(mel) mod1=lm(mortality~latitude+ocean) mod2=lm(mortality~latitude*ocean) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 355.6328 18.9405 18.776 < 2e-16 *** latitude -5.4083 0.4668 -11.586 5.90e-15 *** ocean 23.8640 4.4813 5.325 3.27e-06 *** --- Residual standard error: 14.94 on 44 degrees of freedom Multiple R-squared: 0.8126, Adjusted R-squared: 0.8041 F-statistic: 95.4 on 2 and 44 DF, p-value: < 2.2e-16 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 350.1125 28.2987 12.372 9.26e-16 *** latitude -5.2706 0.7019 -7.509 2.38e-09 *** ocean 33.7399 37.5582 0.898 0.374 latitude:ocean -0.2511 0.9481 -0.265 0.792 --- Residual standard error: 15.1 on 43 degrees of freedom Multiple R-squared: 0.8129, Adjusted R-squared: 0.7999 F-statistic: 62.28 on 3 and 43 DF, p-value: 1.078e-15