> ###a simple start > setwd("C:/Documents and Settings/hz68/Desktop") > vapor=read.table("vapor.txt") > names(vapor)=c("tanktemp", "gastemp", "tankpress", "gaspress", "pollutant") > attach(vapor) > pairs(vapor) > reg1=lm(pollutant~tanktemp+gastemp+tankpress+gaspress) > summary(reg1) Call: lm(formula = pollutant ~ tanktemp + gastemp + tankpress + gaspress) Residuals: Min 1Q Median 3Q Max -6.54248 -1.29378 0.04947 1.22594 7.04125 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.15391 1.03489 0.149 0.8820 tanktemp -0.08269 0.04857 -1.703 0.0912 . gastemp 0.18971 0.04118 4.606 1.03e-05 *** tankpress -4.05962 1.58000 -2.569 0.0114 * gaspress 9.85744 1.62515 6.066 1.57e-08 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2.758 on 120 degrees of freedom Multiple R-Squared: 0.8933, Adjusted R-squared: 0.8897 F-statistic: 251.1 on 4 and 120 DF, p-value: < 2.2e-16 > reg1=lm(pollutant~tanktemp+gastemp+gaspress) > summary(reg1) Call: lm(formula = pollutant ~ tanktemp + gastemp + gaspress) Residuals: Min 1Q Median 3Q Max -7.3888 -1.3634 0.1658 1.2764 7.5541 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.18201 1.05009 -0.173 0.863 tanktemp -0.16038 0.03888 -4.125 6.83e-05 *** gastemp 0.25718 0.03245 7.926 1.26e-12 *** gaspress 5.97632 0.61322 9.746 < 2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2.821 on 121 degrees of freedom Multiple R-Squared: 0.8874, Adjusted R-squared: 0.8846 F-statistic: 317.9 on 3 and 121 DF, p-value: < 2.2e-16 > FPE=sqrt(129/125)*2.821 > FPE [1] 2.865781 > sqrtFPE=sqrt(129/125)*2.821 > sqrtFPE [1] 2.865781 > r1=reg1$residuals > plot(tanktemp,r1) > ##logrithmic transformation > lvapor=log(vapor) > names(lvapor)=c("ltanktemp", "lgastemp", "ltankpress", "lgaspress", "lpollutant") > attach(lvapor) > pairs(lvapor) > reg1=lm(lpollutant~ltanktemp+lgastemp+ltankpress+lgaspress) > summary(reg1) Call: lm(formula = lpollutant ~ ltanktemp + lgastemp + ltankpress + lgaspress) Residuals: Min 1Q Median 3Q Max -0.22071 -0.04742 0.00748 0.04673 0.21115 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.39741 0.19529 7.155 7.18e-11 *** ltanktemp -0.08865 0.07234 -1.225 0.2228 lgastemp 0.32558 0.06747 4.826 4.15e-06 *** ltankpress -0.39754 0.21340 -1.863 0.0649 . lgaspress 1.13672 0.21575 5.269 6.14e-07 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.08884 on 120 degrees of freedom Multiple R-Squared: 0.8851, Adjusted R-squared: 0.8813 F-statistic: 231.1 on 4 and 120 DF, p-value: < 2.2e-16 > r2=reg1$residuals > plot(ltanktemp,r2) > pairs(lvapor) > label=0*tanktemp > high=0*tanktemp > mid=0*tanktemp > label[tanktemp>80]=16 > label[(50 plot(ltanktemp,lpollutant,pch=label) > pairs(lvapor,pch=label) > high=0*lgaspress > high[tanktemp>80]=1 > mid=0*lgaspress > mid[(50 reg2=lm(lpollutant~ltanktemp+lgastemp+ltankpress+lgaspress+high:lgaspress+high+mid+mid:lgaspress) > summary(reg2) Call: lm(formula = lpollutant ~ ltanktemp + lgastemp + ltankpress + lgaspress + high:lgaspress + high + mid + mid:lgaspress) Residuals: Min 1Q Median 3Q Max -0.222420 -0.045219 0.003946 0.037396 0.215480 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.72664 0.60750 1.196 0.234085 ltanktemp 0.04384 0.16669 0.263 0.793025 lgastemp 0.32776 0.06226 5.265 6.53e-07 *** ltankpress -0.07471 0.22102 -0.338 0.735952 lgaspress 0.98594 0.25624 3.848 0.000195 *** high -2.53022 0.50970 -4.964 2.39e-06 *** mid -0.02458 0.24908 -0.099 0.921547 lgaspress:high 1.16107 0.29215 3.974 0.000123 *** lgaspress:mid -0.06824 0.19824 -0.344 0.731294 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.08024 on 116 degrees of freedom Multiple R-Squared: 0.9094, Adjusted R-squared: 0.9031 F-statistic: 145.5 on 8 and 116 DF, p-value: < 2.2e-16 > reg2=lm(lpollutant~ltanktemp+lgastemp+ltankpress+lgaspress+high:lgaspress+high+mid:lgaspress) > summary(reg2) Call: lm(formula = lpollutant ~ ltanktemp + lgastemp + ltankpress + lgaspress + high:lgaspress + high + mid:lgaspress) Residuals: Min 1Q Median 3Q Max -0.222323 -0.044298 0.003768 0.037867 0.215154 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.72324 0.60395 1.198 0.234 ltanktemp 0.04244 0.16538 0.257 0.798 lgastemp 0.32787 0.06198 5.290 5.79e-07 *** ltankpress -0.07595 0.21972 -0.346 0.730 lgaspress 0.99426 0.24096 4.126 6.93e-05 *** high -2.51963 0.49618 -5.078 1.46e-06 *** lgaspress:high 1.15333 0.28023 4.116 7.22e-05 *** lgaspress:mid -0.08635 0.07477 -1.155 0.251 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.0799 on 117 degrees of freedom Multiple R-Squared: 0.9094, Adjusted R-squared: 0.9039 F-statistic: 167.7 on 7 and 117 DF, p-value: < 2.2e-16 > reg2=lm(lpollutant~lgastemp+ltankpress+lgaspress+high:lgaspress+high+mid:lgaspress) > summary(reg2) Call: lm(formula = lpollutant ~ lgastemp + ltankpress + lgaspress + high:lgaspress + high + mid:lgaspress) Residuals: Min 1Q Median 3Q Max -0.226013 -0.043830 0.004068 0.037046 0.215887 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.86675 0.22710 3.817 0.000217 *** lgastemp 0.33249 0.05908 5.628 1.25e-07 *** ltankpress -0.04787 0.18977 -0.252 0.801270 lgaspress 0.95677 0.19084 5.014 1.90e-06 *** high -2.51618 0.49403 -5.093 1.35e-06 *** lgaspress:high 1.17485 0.26634 4.411 2.28e-05 *** lgaspress:mid -0.06904 0.03212 -2.149 0.033663 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.07959 on 118 degrees of freedom Multiple R-Squared: 0.9093, Adjusted R-squared: 0.9047 F-statistic: 197.2 on 6 and 118 DF, p-value: < 2.2e-16 > reg2=lm(lpollutant~lgastemp+lgaspress+high:lgaspress+high+mid:lgaspress) > summary(reg2) Call: lm(formula = lpollutant ~ lgastemp + lgaspress + high:lgaspress + high + mid:lgaspress) Residuals: Min 1Q Median 3Q Max -0.229110 -0.043133 0.002790 0.035557 0.217092 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.83115 0.17726 4.689 7.38e-06 *** lgastemp 0.33903 0.05287 6.412 3.02e-09 *** lgaspress 0.91932 0.11948 7.694 4.59e-12 *** high -2.54562 0.47815 -5.324 4.86e-07 *** lgaspress:high 1.18236 0.26362 4.485 1.69e-05 *** lgaspress:mid -0.07342 0.02691 -2.729 0.00732 ** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.07927 on 119 degrees of freedom Multiple R-Squared: 0.9093, Adjusted R-squared: 0.9055 F-statistic: 238.5 on 5 and 119 DF, p-value: < 2.2e-16 > reg2=lm(pollutant~lgastemp+lgaspress+high:lgaspress+high+mid:lgaspress) > summary(reg2) Call: lm(formula = pollutant ~ lgastemp + lgaspress + high:lgaspress + high + mid:lgaspress) Residuals: Min 1Q Median 3Q Max -5.74099 -1.59660 0.03072 1.34228 6.98891 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -38.9300 5.4780 -7.107 9.48e-11 *** lgastemp 10.5771 1.6340 6.473 2.24e-09 *** lgaspress 20.1699 3.6925 5.462 2.61e-07 *** high -142.5039 14.7766 -9.644 < 2e-16 *** lgaspress:high 74.0100 8.1469 9.084 2.75e-15 *** lgaspress:mid -1.4496 0.8315 -1.743 0.0839 . --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2.45 on 119 degrees of freedom Multiple R-Squared: 0.9165, Adjusted R-squared: 0.913 F-statistic: 261.1 on 5 and 119 DF, p-value: < 2.2e-16 > sqrtFPE=sqrt(131/125)*2.45 > sqrtFPE [1] 2.508111