From Lesson 3 - Multiple Regression

WAGES <- readXL("WAGES.xls")
WAGES
str(WAGES)
'data.frame':   1289 obs. of  7 variables:
 $ obs      : num  1 2 3 4 5 6 7 8 9 10 ...
 $ wage     : num  11.6 5 12 7 21.1 ...
 $ female   : num  1 0 0 0 1 1 1 1 0 1 ...
 $ nonwhite : num  0 0 0 1 1 0 0 1 0 0 ...
 $ union    : num  0 0 0 1 0 0 0 0 0 0 ...
 $ education: num  12 9 16 14 16 12 12 12 18 18 ...
 $ exper    : num  20 9 15 38 19 4 14 32 7 5 ...
summary(WAGES)
      obs            wage           female          nonwhite          union         education         exper      
 Min.   :   1   Min.   : 0.84   Min.   :0.0000   Min.   :0.0000   Min.   :0.000   Min.   : 0.00   Min.   : 0.00  
 1st Qu.: 323   1st Qu.: 6.92   1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:0.000   1st Qu.:12.00   1st Qu.: 9.00  
 Median : 645   Median :10.08   Median :0.0000   Median :0.0000   Median :0.000   Median :12.00   Median :18.00  
 Mean   : 645   Mean   :12.37   Mean   :0.4973   Mean   :0.1528   Mean   :0.159   Mean   :13.15   Mean   :18.79  
 3rd Qu.: 967   3rd Qu.:15.63   3rd Qu.:1.0000   3rd Qu.:0.0000   3rd Qu.:0.000   3rd Qu.:16.00   3rd Qu.:27.00  
 Max.   :1289   Max.   :64.08   Max.   :1.0000   Max.   :1.0000   Max.   :1.000   Max.   :20.00   Max.   :56.00  
cor(WAGES)
                   obs        wage       female    nonwhite        union    education        exper
obs        1.000000000 -0.05843877  0.006296486 -0.02566251 -0.002907478  0.003806248 -0.006655294
wage      -0.058438769  1.00000000 -0.223301829 -0.12783381  0.102246655  0.456517979  0.173173303
female     0.006296486 -0.22330183  1.000000000  0.04327185 -0.088856935 -0.031439159 -0.022656813
nonwhite  -0.025662507 -0.12783381  0.043271852  1.00000000  0.080587911 -0.087061729 -0.039129103
union     -0.002907478  0.10224666 -0.088856935  0.08058791  1.000000000  0.003966952  0.154319024
education  0.003806248  0.45651798 -0.031439159 -0.08706173  0.003966952  1.000000000 -0.180103012
exper     -0.006655294  0.17317330 -0.022656813 -0.03912910  0.154319024 -0.180103012  1.000000000
WAGES.lm <- lm(wage~.,data=WAGES)
summary(WAGES.lm)

Call:
lm(formula = wage ~ ., data = WAGES)

Residuals:
    Min      1Q  Median      3Q     Max 
-20.622  -3.668  -1.001   2.609  50.493 

Coefficients:
              Estimate Std. Error t value      Pr(>|t|)    
(Intercept) -6.3673562  1.0617226  -5.997 0.00000000261 ***
obs         -0.0012550  0.0004863  -2.581       0.00997 ** 
female      -3.0679942  0.3638243  -8.433       < 2e-16 ***
nonwhite    -1.5994861  0.5082405  -3.147       0.00169 ** 
union        1.0973070  0.5049656   2.173       0.02996 *  
education    1.3703624  0.0657593  20.839       < 2e-16 ***
exper        0.1663016  0.0160127  10.386       < 2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 6.494 on 1282 degrees of freedom
Multiple R-squared:  0.3268,    Adjusted R-squared:  0.3237 
F-statistic: 103.7 on 6 and 1282 DF,  p-value: < 2.2e-16
WAGES.lm2 <- lm(wage~.-obs,data=WAGES)
summary(WAGES.lm2)

Call:
lm(formula = wage ~ . - obs, data = WAGES)

Residuals:
    Min      1Q  Median      3Q     Max 
-20.781  -3.760  -1.044   2.418  50.414 

Coefficients:
            Estimate Std. Error t value         Pr(>|t|)    
(Intercept) -7.18334    1.01579  -7.072 0.00000000000251 ***
female      -3.07488    0.36462  -8.433          < 2e-16 ***
nonwhite    -1.56531    0.50919  -3.074          0.00216 ** 
union        1.09598    0.50608   2.166          0.03052 *  
education    1.37030    0.06590  20.792          < 2e-16 ***
exper        0.16661    0.01605  10.382          < 2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 6.508 on 1283 degrees of freedom
Multiple R-squared:  0.3233,    Adjusted R-squared:  0.3207 
F-statistic: 122.6 on 5 and 1283 DF,  p-value: < 2.2e-16

\[ wage = -7.18 -3.07female - 1.57nonwhite + 1.10union + 1.37education + 0.17exper + \epsilon\ \]

library(carData)
Prestige
PRESTIGE <- Prestige
PRESTIGE.lm <- lm(income~.,data=PRESTIGE)
summary(PRESTIGE.lm)

Call:
lm(formula = income ~ ., data = PRESTIGE)

Residuals:
    Min      1Q  Median      3Q     Max 
-7752.4  -954.6  -331.2   742.6 14301.3 

Coefficients:
              Estimate Std. Error t value    Pr(>|t|)    
(Intercept)    7.32053 3037.27048   0.002     0.99808    
education    131.18372  288.74961   0.454     0.65068    
women        -53.23480    9.83107  -5.415 0.000000496 ***
prestige     139.20912   36.40239   3.824     0.00024 ***
census         0.04209    0.23568   0.179     0.85865    
typeprof     509.15150 1798.87914   0.283     0.77779    
typewc       347.99010 1173.89384   0.296     0.76757    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 2633 on 91 degrees of freedom
  (4 observations deleted due to missingness)
Multiple R-squared:  0.6363,    Adjusted R-squared:  0.6123 
F-statistic: 26.54 on 6 and 91 DF,  p-value: < 2.2e-16

\[ income = +7.32 + 131.18education - 53.23women + 139.21prestige + 0.04census + 509.15typeprof + 347.99typewc \]

From Lesson 4 - Regression Diagnostics

source("scripts/r4abep-01.R")
library(RcmdrMisc)
options(scipen = 10)
library(esquisse)
WOMEN <- women
WOMEN
str(WOMEN)
'data.frame':   15 obs. of  2 variables:
 $ height: num  58 59 60 61 62 63 64 65 66 67 ...
 $ weight: num  115 117 120 123 126 129 132 135 139 142 ...
WOMEN.lm <- lm(height~weight,data=WOMEN)
summary(WOMEN.lm)

Call:
lm(formula = height ~ weight, data = WOMEN)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.83233 -0.26249  0.08314  0.34353  0.49790 

Coefficients:
             Estimate Std. Error t value           Pr(>|t|)    
(Intercept) 25.723456   1.043746   24.64 0.0000000000026848 ***
weight       0.287249   0.007588   37.85 0.0000000000000109 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.44 on 13 degrees of freedom
Multiple R-squared:  0.991, Adjusted R-squared:  0.9903 
F-statistic:  1433 on 1 and 13 DF,  p-value: 0.00000000000001091
r4abep.plotlm(WOMEN.lm)

WOMEN.lm2 <- lm(height~weight+I(weight^2),data=WOMEN)
summary(WOMEN.lm2)

Call:
lm(formula = height ~ weight + I(weight^2), data = WOMEN)

Residuals:
      Min        1Q    Median        3Q       Max 
-0.105338 -0.035764 -0.004898  0.049430  0.141593 

Coefficients:
                Estimate   Std. Error t value          Pr(>|t|)    
(Intercept) -11.74693860   1.71998084   -6.83 0.000018241147800 ***
weight        0.83434066   0.02502062   33.35 0.000000000000336 ***
I(weight^2)  -0.00197330   0.00009014  -21.89 0.000000000048424 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.07158 on 12 degrees of freedom
Multiple R-squared:  0.9998,    Adjusted R-squared:  0.9997 
F-statistic: 2.732e+04 on 2 and 12 DF,  p-value: < 2.2e-16
r4abep.plotlm(WOMEN.lm2)

WAGES01 <- readXL("WAGES01.xls")
WAGES01
str(WAGES01)
'data.frame':   1289 obs. of  8 variables:
 $ obs      : num  1 2 3 4 5 6 7 8 9 10 ...
 $ wage     : num  11.6 5 12 7 21.1 ...
 $ female   : num  1 0 0 0 1 1 1 1 0 1 ...
 $ nonwhite : num  0 0 0 1 1 0 0 1 0 0 ...
 $ union    : num  0 0 0 1 0 0 0 0 0 0 ...
 $ education: num  12 9 16 14 16 12 12 12 18 18 ...
 $ exper    : num  20 9 15 38 19 4 14 32 7 5 ...
 $ age      : num  38 24 37 58 41 22 32 50 31 29 ...
WAGES01.lm <- lm(wage~.,data=WAGES01)
summary(WAGES01.lm)

Call:
lm(formula = wage ~ ., data = WAGES01)

Residuals:
    Min      1Q  Median      3Q     Max 
-20.622  -3.668  -1.001   2.609  50.493 

Coefficients: (1 not defined because of singularities)
              Estimate Std. Error t value      Pr(>|t|)    
(Intercept) -6.3673562  1.0617226  -5.997 0.00000000261 ***
obs         -0.0012550  0.0004863  -2.581       0.00997 ** 
female      -3.0679942  0.3638243  -8.433       < 2e-16 ***
nonwhite    -1.5994861  0.5082405  -3.147       0.00169 ** 
union        1.0973070  0.5049656   2.173       0.02996 *  
education    1.3703624  0.0657593  20.839       < 2e-16 ***
exper        0.1663016  0.0160127  10.386       < 2e-16 ***
age                 NA         NA      NA            NA    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 6.494 on 1282 degrees of freedom
Multiple R-squared:  0.3268,    Adjusted R-squared:  0.3237 
F-statistic: 103.7 on 6 and 1282 DF,  p-value: < 2.2e-16
r4abep.cor(WAGES01)

r4abep.corgram(WAGES01)

WAGES01.lm2 <- lm(wage~.-exper,data=WAGES01)
summary(WAGES01.lm2)

Call:
lm(formula = wage ~ . - exper, data = WAGES01)

Residuals:
    Min      1Q  Median      3Q     Max 
-20.622  -3.668  -1.001   2.609  50.493 

Coefficients:
              Estimate Std. Error t value       Pr(>|t|)    
(Intercept) -7.3651657  1.1068167  -6.654 0.000000000042 ***
obs         -0.0012550  0.0004863  -2.581        0.00997 ** 
female      -3.0679942  0.3638243  -8.433        < 2e-16 ***
nonwhite    -1.5994861  0.5082405  -3.147        0.00169 ** 
union        1.0973070  0.5049656   2.173        0.02996 *  
education    1.2040609  0.0646781  18.616        < 2e-16 ***
age          0.1663016  0.0160127  10.386        < 2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 6.494 on 1282 degrees of freedom
Multiple R-squared:  0.3268,    Adjusted R-squared:  0.3237 
F-statistic: 103.7 on 6 and 1282 DF,  p-value: < 2.2e-16
WWORK <- readXL("WWORK.xls")
WWORK
str(WWORK)
'data.frame':   753 obs. of  25 variables:
 $ taxableinc  : num  12200 18000 24000 16400 10000 ...
 $ federaltax  : num  1494 2615 3957 2279 1063 ...
 $ hsiblings   : num  1 8 4 6 3 8 0 2 6 5 ...
 $ hfathereduc : num  14 7 7 7 7 7 7 7 7 7 ...
 $ hmothereduc : num  16 3 10 12 7 7 10 7 7 7 ...
 $ siblings    : num  4 0 2 5 7 4 8 7 7 0 ...
 $ lfp         : num  1 1 1 1 1 1 1 1 1 1 ...
 $ hours       : num  1610 1656 1980 456 1568 ...
 $ kidsl6      : num  1 0 1 0 1 0 0 0 0 0 ...
 $ kids618     : num  0 2 3 3 2 0 2 0 2 2 ...
 $ age         : num  32 30 35 34 31 54 37 54 48 39 ...
 $ educ        : num  12 12 12 12 14 12 16 12 12 12 ...
 $ wage        : num  3.35 1.39 4.55 1.1 4.59 ...
 $ wage76      : num  2.65 2.65 4.04 3.25 3.6 ...
 $ hhours      : num  2708 2310 3072 1920 2000 ...
 $ hage        : num  34 30 40 53 32 57 37 53 52 43 ...
 $ heduc       : num  12 9 12 10 12 11 12 8 4 12 ...
 $ hwage       : num  4.03 8.44 3.58 3.54 10 ...
 $ faminc      : num  16310 21800 21040 7300 27300 ...
 $ mtr         : num  0.721 0.661 0.692 0.781 0.622 ...
 $ mothereduc  : num  12 7 12 7 12 14 14 3 7 7 ...
 $ fathereduc  : num  7 7 7 7 14 7 7 3 7 7 ...
 $ unemployment: num  5 11 5 5 9.5 7.5 5 5 3 5 ...
 $ largecity   : num  0 1 0 0 1 1 0 0 0 0 ...
 $ exper       : num  14 5 15 6 7 33 11 35 24 21 ...
WWORK.lm <- lm(hours~.,data=WWORK)
summary(WWORK.lm)

Call:
lm(formula = hours ~ ., data = WWORK)

Residuals:
    Min      1Q  Median      3Q     Max 
-1796.4  -256.0    20.2   242.0  3301.6 

Coefficients:
                 Estimate   Std. Error t value           Pr(>|t|)    
(Intercept)   3073.596550   546.055531   5.629 0.0000000259188942 ***
taxableinc      -0.004201     0.006432  -0.653           0.513867    
federaltax       0.017394     0.021555   0.807           0.419945    
hsiblings        0.826868     8.324151   0.099           0.920901    
hfathereduc     13.421522     6.676375   2.010           0.044768 *  
hmothereduc     -3.553929     6.490500  -0.548           0.584163    
siblings       -19.884246     8.384105  -2.372           0.017968 *  
lfp           1047.764693    56.560129  18.525            < 2e-16 ***
kidsl6        -109.730258    41.785588  -2.626           0.008820 ** 
kids618        -26.444051    16.443507  -1.608           0.108230    
age             -8.651555     5.299301  -1.633           0.102989    
educ           -14.854387    11.668634  -1.273           0.203418    
wage           -61.453206     8.377708  -7.335 0.0000000000005912 ***
wage76          84.292944    11.414349   7.385 0.0000000000004187 ***
hhours          -0.190040     0.039520  -4.809 0.0000018464411482 ***
hage            -2.747531     5.091228  -0.540           0.589597    
heduc           -8.532048     8.436929  -1.011           0.312221    
hwage          -67.284656     8.623613  -7.802 0.0000000000000211 ***
faminc           0.013336     0.003550   3.757           0.000186 ***
mtr          -2287.788894   553.299716  -4.135 0.0000396638887059 ***
mothereduc       6.374116     7.013803   0.909           0.363759    
fathereduc      -6.989771     6.674763  -1.047           0.295358    
unemployment    -5.834074     6.135897  -0.951           0.342016    
largecity      -14.959321    42.065584  -0.356           0.722229    
exper           14.926883     2.780136   5.369 0.0000001065061420 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 502.6 on 728 degrees of freedom
Multiple R-squared:  0.6779,    Adjusted R-squared:  0.6673 
F-statistic: 63.84 on 24 and 728 DF,  p-value: < 2.2e-16
r4abep.vif(WWORK.lm)

VIF          
---------- 
  taxableinc   federaltax    hsiblings  hfathereduc  hmothereduc     siblings          lfp       kidsl6      kids618 
   17.415361    16.727126     1.195571     1.373546     1.411905     1.119400     2.339501     1.427039     1.402303 
         age         educ         wage       wage76       hhours         hage        heduc        hwage       faminc 
    5.448154     2.107616     2.195931     2.271331     1.649221     5.011564     1.933758     3.962434     5.573780 
         mtr   mothereduc   fathereduc unemployment    largecity        exper 
    6.353831     1.660743     1.692596     1.087531     1.211230     1.498213 

sqrt(VIF) 
---------- 
  taxableinc   federaltax    hsiblings  hfathereduc  hmothereduc     siblings          lfp       kidsl6      kids618 
    4.173172     4.089881     1.093422     1.171984     1.188236     1.058017     1.529543     1.194587     1.184189 
         age         educ         wage       wage76       hhours         hage        heduc        hwage       faminc 
    2.334128     1.451763     1.481867     1.507094     1.284220     2.238652     1.390596     1.990586     2.360885 
         mtr   mothereduc   fathereduc unemployment    largecity        exper 
    2.520681     1.288698     1.300998     1.042848     1.100559     1.224015 
r4abep.cor(WWORK)

WWORK.lm2 <- lm(hours~.-federaltax-mtr-hage,data=WWORK)
summary(WWORK.lm2)

Call:
lm(formula = hours ~ . - federaltax - mtr - hage, data = WWORK)

Residuals:
    Min      1Q  Median      3Q     Max 
-1647.3  -258.5    33.2   247.8  3300.5 

Coefficients:
                 Estimate   Std. Error t value          Pr(>|t|)    
(Intercept)   979.0047031  235.9604277   4.149 0.000037316929218 ***
taxableinc      0.0007106    0.0016886   0.421          0.674017    
hsiblings       0.6821181    8.3728001   0.081          0.935092    
hfathereduc    14.3764575    6.7304325   2.136          0.033008 *  
hmothereduc    -4.1091283    6.5460816  -0.628          0.530381    
siblings      -20.1553148    8.4314758  -2.390          0.017078 *  
lfp          1074.2273986   56.2631759  19.093           < 2e-16 ***
kidsl6       -121.5513603   41.6330034  -2.920          0.003613 ** 
kids618       -46.2842866   15.8819067  -2.914          0.003674 ** 
age           -11.4168114    3.0922474  -3.692          0.000239 ***
educ          -14.0343383   11.7754944  -1.192          0.233716    
wage          -60.2581574    8.4578382  -7.125 0.000000000002507 ***
wage76         86.5249106   11.4407838   7.563 0.000000000000119 ***
hhours         -0.1455273    0.0384263  -3.787          0.000165 ***
heduc          -3.9710037    8.4261375  -0.471          0.637587    
hwage         -55.0234051    8.1559868  -6.746 0.000000000030839 ***
faminc          0.0230408    0.0027065   8.513           < 2e-16 ***
mothereduc      7.5093287    7.0723474   1.062          0.288683    
fathereduc     -7.1984887    6.7124572  -1.072          0.283891    
unemployment   -6.1673995    6.1876121  -0.997          0.319224    
largecity     -15.6636225   42.3743650  -0.370          0.711751    
exper          15.4177309    2.8024640   5.501 0.000000052117188 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 507.8 on 731 degrees of freedom
Multiple R-squared:  0.6699,    Adjusted R-squared:  0.6604 
F-statistic: 70.64 on 21 and 731 DF,  p-value: < 2.2e-16
r4abep.vif(WWORK.lm2)

VIF          
---------- 
  taxableinc    hsiblings  hfathereduc  hmothereduc     siblings          lfp       kidsl6      kids618          age 
    1.176082     1.185098     1.367618     1.407113     1.109165     2.268130     1.387955     1.281667     1.817514 
        educ         wage       wage76       hhours        heduc        hwage       faminc   mothereduc   fathereduc 
    2.102940     2.192826     2.235665     1.527646     1.889763     3.472591     3.175060     1.654396     1.677110 
unemployment    largecity        exper 
    1.083550     1.204194     1.491553 

sqrt(VIF) 
---------- 
  taxableinc    hsiblings  hfathereduc  hmothereduc     siblings          lfp       kidsl6      kids618          age 
    1.084473     1.088622     1.169452     1.186218     1.053169     1.506031     1.178115     1.132107     1.348152 
        educ         wage       wage76       hhours        heduc        hwage       faminc   mothereduc   fathereduc 
    1.450152     1.480819     1.495214     1.235980     1.374687     1.863489     1.781870     1.286233     1.295033 
unemployment    largecity        exper 
    1.040937     1.097358     1.221291 
WWORK.lm3 <- lm(hours~hfathereduc+siblings+lfp+kidsl6+kids618+age+wage+wage76+hhours+hwage+faminc+exper,data=WWORK)
summary(WWORK.lm3)

Call:
lm(formula = hours ~ hfathereduc + siblings + lfp + kidsl6 + 
    kids618 + age + wage + wage76 + hhours + hwage + faminc + 
    exper, data = WWORK)

Residuals:
    Min      1Q  Median      3Q     Max 
-1601.7  -276.4    23.8   250.5  3309.9 

Coefficients:
               Estimate  Std. Error t value          Pr(>|t|)    
(Intercept)  750.282079  190.823943   3.932 0.000092228000441 ***
hfathereduc   13.030009    5.875155   2.218          0.026870 *  
siblings     -20.196460    8.170389  -2.472          0.013663 *  
lfp         1074.146421   55.503429  19.353           < 2e-16 ***
kidsl6      -130.131720   41.192157  -3.159          0.001647 ** 
kids618      -43.578325   15.665493  -2.782          0.005543 ** 
age          -11.249071    2.995039  -3.756          0.000186 ***
wage         -62.726300    8.279287  -7.576 0.000000000000106 ***
wage76        84.176015   11.301802   7.448 0.000000000000264 ***
hhours        -0.154220    0.037320  -4.132 0.000040012161607 ***
hwage        -59.137627    7.681320  -7.699 0.000000000000044 ***
faminc         0.022742    0.002684   8.472           < 2e-16 ***
exper         15.360228    2.774562   5.536 0.000000042973445 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 507.3 on 740 degrees of freedom
Multiple R-squared:  0.6664,    Adjusted R-squared:  0.661 
F-statistic: 123.2 on 12 and 740 DF,  p-value: < 2.2e-16
r4abep.vif(WWORK.lm3)

VIF          
---------- 
hfathereduc    siblings         lfp      kidsl6     kids618         age        wage      wage76      hhours 
   1.043866    1.043282    2.210987    1.360993    1.249066    1.707895    2.104740    2.185333    1.443380 
      hwage      faminc       exper 
   3.085314    3.128623    1.464450 

sqrt(VIF) 
---------- 
hfathereduc    siblings         lfp      kidsl6     kids618         age        wage      wage76      hhours 
   1.021697    1.021412    1.486939    1.166616    1.117616    1.306865    1.450772    1.478287    1.201408 
      hwage      faminc       exper 
   1.756506    1.768791    1.210145 
ABORT <- readXL("ABORT.xls")
ABORT
str(ABORT)
'data.frame':   50 obs. of  9 variables:
 $ state   : Factor w/ 50 levels "ALABAMA","ALASKA",..: 24 31 44 48 4 18 40 26 36 1 ...
 $ abortion: num  12.4 17.7 9.3 7.7 13.5 ...
 $ religion: num  38 44.7 76.7 9.8 30 ...
 $ price   : num  256 332 298 251 248 228 292 329 281 272 ...
 $ laws    : num  0 0 1 0 1 1 1 0 0 1 ...
 $ funds   : num  0 0 0 1 0 0 0 0 0 0 ...
 $ educ    : num  64.3 75.1 85.1 66 66.3 ...
 $ income  : num  14082 15458 15573 15598 15635 ...
 $ picket  : num  100 20 0 50 33 60 57 50 75 89 ...
ABORT.lm <- lm(abortion~educ+funds+income+laws+picket+price+religion,data=ABORT)
summary(ABORT.lm)

Call:
lm(formula = abortion ~ educ + funds + income + laws + picket + 
    price + religion, data = ABORT)

Residuals:
     Min       1Q   Median       3Q      Max 
-11.6110  -4.6493  -0.6696   4.5253  15.9514 

Coefficients:
              Estimate Std. Error t value   Pr(>|t|)    
(Intercept) 14.2839573 15.0776294   0.947     0.3489    
educ        -0.2872551  0.1995545  -1.439     0.1574    
funds        2.8200030  2.7834747   1.013     0.3168    
income       0.0024007  0.0004552   5.274 0.00000435 ***
laws        -0.8731018  2.3765662  -0.367     0.7152    
picket      -0.1168712  0.0421799  -2.771     0.0083 ** 
price       -0.0423631  0.0222232  -1.906     0.0635 .  
religion     0.0200709  0.0863805   0.232     0.8174    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 7.063 on 42 degrees of freedom
Multiple R-squared:  0.5774,    Adjusted R-squared:  0.507 
F-statistic: 8.199 on 7 and 42 DF,  p-value: 0.000002847
r4abep.plotlm(ABORT.lm)

r4abep.vif(ABORT.lm)

VIF          
---------- 
    educ    funds   income     laws   picket    price religion 
1.380153 1.416584 1.606933 1.304444 1.214623 1.153023 1.175216 

sqrt(VIF) 
---------- 
    educ    funds   income     laws   picket    price religion 
1.174799 1.190204 1.267649 1.142122 1.102099 1.073789 1.084074 
r4abep.bp(ABORT.lm)

    studentized Breusch-Pagan test

data:  model
BP = 16.001, df = 7, p-value = 0.02511
ABORT.lm2 <- lm(log(abortion)~educ+funds+income+laws+picket+price+religion,data=ABORT)
summary(ABORT.lm2)

Call:
lm(formula = log(abortion) ~ educ + funds + income + laws + picket + 
    price + religion, data = ABORT)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.79388 -0.23582  0.01907  0.27809  0.56150 

Coefficients:
              Estimate Std. Error t value   Pr(>|t|)    
(Intercept)  2.8332642  0.7552629   3.751   0.000533 ***
educ        -0.0144884  0.0099960  -1.449   0.154648    
funds        0.0876877  0.1394288   0.629   0.532816    
income       0.0001265  0.0000228   5.547 0.00000178 ***
laws        -0.0128839  0.1190461  -0.108   0.914332    
picket      -0.0065153  0.0021129  -3.084   0.003607 ** 
price       -0.0031121  0.0011132  -2.796   0.007777 ** 
religion     0.0004575  0.0043269   0.106   0.916290    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.3538 on 42 degrees of freedom
Multiple R-squared:  0.5892,    Adjusted R-squared:  0.5207 
F-statistic: 8.605 on 7 and 42 DF,  p-value: 0.000001649
r4abep.plotlm(ABORT.lm2)

r4abep.vif(ABORT.lm2)

VIF          
---------- 
    educ    funds   income     laws   picket    price religion 
1.380153 1.416584 1.606933 1.304444 1.214623 1.153023 1.175216 

sqrt(VIF) 
---------- 
    educ    funds   income     laws   picket    price religion 
1.174799 1.190204 1.267649 1.142122 1.102099 1.073789 1.084074 
r4abep.bp(ABORT.lm2)

    studentized Breusch-Pagan test

data:  model
BP = 7.95, df = 7, p-value = 0.337
r4abep.ptxform(ABORT.lm)
non-list contrasts argument ignored
Estimated transformation parameter 
      Y1 
0.301365 
r4abep.comparelm(ABORT.lm,ABORT.lm2)
length of NULL cannot be changedlength of NULL cannot be changedlength of NULL cannot be changedlength of NULL cannot be changedlength of NULL cannot be changed

============================================================
                                   Dependent variable:      
                              ------------------------------
                                 abortion     log(abortion) 
                                    (1)            (2)      
------------------------------------------------------------
educ                              -0.287          -0.014    
                                  (0.200)        (0.010)    
                                                            
funds                              2.820          0.088     
                                  (2.783)        (0.139)    
                                                            
income                           0.002***       0.0001***   
                                 (0.0005)       (0.00002)   
                                                            
laws                              -0.873          -0.013    
                                  (2.377)        (0.119)    
                                                            
picket                           -0.117**        -0.007**   
                                  (0.042)        (0.002)    
                                                            
price                             -0.042         -0.003**   
                                  (0.022)        (0.001)    
                                                            
religion                           0.020          0.0005    
                                  (0.086)        (0.004)    
                                                            
Constant                          14.284         2.833***   
                                 (15.078)        (0.755)    
                                                            
------------------------------------------------------------
Observations                        50              50      
R2                                 0.577          0.589     
Adjusted R2                        0.507          0.521     
Residual Std. Error (df = 42)      7.063          0.354     
F Statistic (df = 7; 42)         8.199***        8.605***   
============================================================
Note:                          *p<0.05; **p<0.01; ***p<0.001
mean(ABORT.lm2$residuals)
[1] -2.77881e-18
r4abep.biasint(ABORT.lm2)
[1] -2.77881e-18
LS0tDQp0aXRsZTogIkhvbWV3b3JrIDMiDQphdXRob3I6ICJDaHJpc3RpYW4gUGF1bG8gQWlhbiBHdWFuem9uIg0KZGF0ZTogIk1hcmNoIDI3LCAyMDIwIg0Kb3V0cHV0OiBodG1sX25vdGVib29rDQotLS0NCg0KIyMjIEZyb20gTGVzc29uIDMgLSBNdWx0aXBsZSBSZWdyZXNzaW9uDQoNCmBgYHtyfQ0KV0FHRVMgPC0gcmVhZFhMKCJXQUdFUy54bHMiKQ0KV0FHRVMNCnN0cihXQUdFUykNCnN1bW1hcnkoV0FHRVMpDQpgYGANCg0KYGBge3J9DQpjb3IoV0FHRVMpDQpgYGANCg0KYGBge3J9DQpXQUdFUy5sbSA8LSBsbSh3YWdlfi4sZGF0YT1XQUdFUykNCnN1bW1hcnkoV0FHRVMubG0pDQpgYGANCg0KYGBge3J9DQpXQUdFUy5sbTIgPC0gbG0od2FnZX4uLW9icyxkYXRhPVdBR0VTKQ0Kc3VtbWFyeShXQUdFUy5sbTIpDQpgYGANCg0KJCQgd2FnZSA9IC03LjE4IC0zLjA3ZmVtYWxlIC0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