library(“readxl”)

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this: setwd(“C:/Users/Owner/Desktop/Lenin Files/Data Sciences”) # copy and load home sales data

##setwd("C:/Users/Owner/Desktop/Lenin Files/Data Sciences")
homesales<- read.csv(file = "C:/Users/Owner/Desktop/Lenin Files/Data Sciences/week-6-housing.csv", header=TRUE)

check data

summary(homesales)
##       Sale.Date       Sale.Price       sale_reason    sale_instrument 
##  7/1/2008  :   41   Min.   :    698   Min.   : 0.00   Min.   : 0.000  
##  10/1/2008 :   38   1st Qu.: 460000   1st Qu.: 1.00   1st Qu.: 3.000  
##  11/17/2011:   33   Median : 593000   Median : 1.00   Median : 3.000  
##  10/2/2012 :   22   Mean   : 660738   Mean   : 1.55   Mean   : 3.678  
##  5/17/2010 :   17   3rd Qu.: 750000   3rd Qu.: 1.00   3rd Qu.: 3.000  
##  9/13/2011 :   16   Max.   :4400000   Max.   :19.00   Max.   :27.000  
##  (Other)   :12698                                                     
##   sale_warning   sitetype                   addr_full          zip5      
##         :10568   A1:    8   22340 NE 65TH PL     :    6   Min.   :98052  
##  45     :  257   C1:    3   23566 NE 111TH ST    :    6   1st Qu.:98052  
##  54     :  202   DV:    6   9102 172ND AVE NE    :    6   Median :98052  
##  40     :  177   R1:12456   10920 167TH AVE NE   :    5   Mean   :98053  
##  41     :  175   R2:  377   11093 ELLISTON WAY NE:    5   3rd Qu.:98053  
##  15     :  149   R3:   14   15604 NE 112TH ST    :    5   Max.   :98074  
##  (Other): 1337   R4:    1   (Other)              :12832                  
##       ctyname       postalctyn         lon              lat       
##           :6078   REDMOND:12865   Min.   :-122.2   Min.   :47.46  
##  REDMOND  :6721                   1st Qu.:-122.1   1st Qu.:47.67  
##  SAMMAMISH:  66                   Median :-122.1   Median :47.69  
##                                   Mean   :-122.1   Mean   :47.68  
##                                   3rd Qu.:-122.0   3rd Qu.:47.70  
##                                   Max.   :-121.9   Max.   :47.73  
##                                                                   
##  building_grade  square_feet_total_living    bedrooms     
##  Min.   : 2.00   Min.   :  240            Min.   : 0.000  
##  1st Qu.: 8.00   1st Qu.: 1820            1st Qu.: 3.000  
##  Median : 8.00   Median : 2420            Median : 4.000  
##  Mean   : 8.24   Mean   : 2540            Mean   : 3.479  
##  3rd Qu.: 9.00   3rd Qu.: 3110            3rd Qu.: 4.000  
##  Max.   :13.00   Max.   :13540            Max.   :11.000  
##                                                           
##  bath_full_count  bath_half_count  bath_3qtr_count   year_built  
##  Min.   : 0.000   Min.   :0.0000   Min.   :0.000   Min.   :1900  
##  1st Qu.: 1.000   1st Qu.:0.0000   1st Qu.:0.000   1st Qu.:1979  
##  Median : 2.000   Median :1.0000   Median :0.000   Median :1998  
##  Mean   : 1.798   Mean   :0.6134   Mean   :0.494   Mean   :1993  
##  3rd Qu.: 2.000   3rd Qu.:1.0000   3rd Qu.:1.000   3rd Qu.:2007  
##  Max.   :23.000   Max.   :8.0000   Max.   :8.000   Max.   :2016  
##                                                                  
##  year_renovated    current_zoning   sq_ft_lot       prop_type
##  Min.   :   0.00   URPSO  :3215   Min.   :    785   R:12865  
##  1st Qu.:   0.00   R4     :2893   1st Qu.:   5355            
##  Median :   0.00   RA5    :1974   Median :   7965            
##  Mean   :  26.24   R5     :1933   Mean   :  22229            
##  3rd Qu.:   0.00   R6     :1456   3rd Qu.:  12632            
##  Max.   :2016.00   R3     : 331   Max.   :1631322            
##                    (Other):1063                              
##   present_use     
##  Min.   :  0.000  
##  1st Qu.:  2.000  
##  Median :  2.000  
##  Mean   :  6.598  
##  3rd Qu.:  2.000  
##  Max.   :300.000  
## 

b. created the following variables 1) Sale price and 2)Square feet of lot 3) Square feet of living area 4) year built.

salePrice1 <- homesales$Sale.Price
sqFoot <- homesales$sq_ft_lot
yearBuilt <- homesales$year_built
sqFootLiving <- homesales$square_feet_total_living

build a model where sale price is predicted from square foot of the lot

homesales1 <- lm(salePrice1 ~ sqFoot, data = homesales)
summary(homesales1)
## 
## Call:
## lm(formula = salePrice1 ~ sqFoot, data = homesales)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2016064  -194842   -63293    91565  3735109 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 6.418e+05  3.800e+03  168.90   <2e-16 ***
## sqFoot      8.510e-01  6.217e-02   13.69   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 401500 on 12863 degrees of freedom
## Multiple R-squared:  0.01435,    Adjusted R-squared:  0.01428 
## F-statistic: 187.3 on 1 and 12863 DF,  p-value: < 2.2e-16

build a model where sale price is predicted from square feet of the lot, square feet of living area and year built

homesales2 <- lm(salePrice1 ~ sqFoot + yearBuilt + sqFootLiving, data = homesales)
summary(homesales2)
## 
## Call:
## lm(formula = salePrice1 ~ sqFoot + yearBuilt + sqFootLiving, 
##     data = homesales)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2158828  -119944   -41323    46104  3761175 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -5.547e+06  3.901e+05 -14.219  < 2e-16 ***
## sqFoot        2.924e-01  5.837e-02   5.009 5.55e-07 ***
## yearBuilt     2.900e+03  1.971e+02  14.711  < 2e-16 ***
## sqFootLiving  1.663e+02  3.495e+00  47.592  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 357200 on 12861 degrees of freedom
## Multiple R-squared:   0.22,  Adjusted R-squared:  0.2198 
## F-statistic:  1209 on 3 and 12861 DF,  p-value: < 2.2e-16

c. homesales1 modle was generated using square foot data and the value of R2 is 0.014, which means only 1.4% of the sales price is influenced by the lot footage. When I added additional variables the R2 increased to 22%. That means actual living area and year of built account for 20.6% of the variability in home sale price.

The difference in the R-squared and Adjusted R-squared in the first model is 0.07%, which indicates that if the model is derived from the population rather than a sample it would account for approximately 0.007% less variance in the outcome. This variation is negigible

when I added more predictor variables, the difference in R values increased to 0.02%.

d. the beta values in the multiple regression model are intercept=-5.547, sqfoot of lot(b1)=0.2924, year built(b2)=2900, living area(b3)=166.3. It indicates there is positive relation ship between b values and the price of the home. As all beta value increases, the price of the homes increase. Also, as the living areas increases by one foot, the value of the home increases by $166 and as year increases by one unit, the value of the home increases by $2900 when rest of the effects are held constant in each case.

Find the confidence intervals below

confint(homesales2)
##                      2.5 %        97.5 %
## (Intercept)  -6.311551e+06 -4.782253e+06
## sqFoot        1.779547e-01  4.067827e-01
## yearBuilt     2.513176e+03  3.285875e+03
## sqFootLiving  1.594730e+02  1.731737e+02

e.In regression model, the confidence interval for living area is tight (159.4 and 173.1), indicating that the estimates of the current model are likely to be representative of the true population values. Same thing is true with year built parameter.

Compare models

anova(homesales1, homesales2)
## Analysis of Variance Table
## 
## Model 1: salePrice1 ~ sqFoot
## Model 2: salePrice1 ~ sqFoot + yearBuilt + sqFootLiving
##   Res.Df        RSS Df  Sum of Sq    F    Pr(>F)    
## 1  12863 2.0734e+15                                 
## 2  12861 1.6409e+15  2 4.3252e+14 1695 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

f. the value of F is 1695 and F(2,12861)=1695, P<2.22-16. It means the homesales2 significantly improved the fit of the model to the data compared to homesales1

g. Perform casewise dignostics and save each function’s output as a variable in a dataframe

homesales$residuals <- resid(homesales2)
homesales$standardized.residuals <- rstandard(homesales2)
homesales$studentized.residuals <- rstudent(homesales2)
homesales$dfbeta <- dfbeta(homesales2)
homesales$dffit <- dffits(homesales2)
write.table(homesales, "Home sales with Diagnostics", sep = "\t", row.names= FALSE)

h. Calculate the standardized residuals specifying those that are +-2, storing the results of large residuals in a variable

i. show the sum of large residuals

homesales$large.residual <-  homesales$standardized.residuals > 2 | homesales$standardized.residuals < -2
sum(homesales$large.residual)
## [1] 334

There are 334 cases with large residuals

j. show the variables with large residuals. Selected only a few columns

homesales[homesales$large.residual, c("Sale.Price", "addr_full", "zip5", "year_built", "square_feet_total_living" )]
##       Sale.Price                       addr_full  zip5 year_built
## 6         184667                8101 229TH DR NE 98053       2005
## 25        265000          25149 NE PATTERSON WAY 98053       2007
## 115      1390000             19656 NE REDMOND RD 98053       1955
## 160       229000                28527 NE 47TH PL 98053       2008
## 178       390000 13414 WOODINVILLE REDMOND RD NE 98052       2008
## 239      1588359               24103 NE 122ND ST 98053       2005
## 246      1450000   3068 W LAKE SAMMAMISH PKWY NE 98052       1918
## 287       163000                28218 NE 40TH ST 98053       2014
## 295       270000                5806 249TH CT NE 98053       2016
## 300       200000               8015 228TH AVE NE 98053       2008
## 341       300000               11650 154TH PL NE 98052       2008
## 344        90000               1520 268TH AVE NE 98053       2003
## 359       187000               3131 269TH AVE NE 98053       2008
## 385      2500000                20424 NE 64TH PL 98053       2005
## 396      2169000               8024 255TH AVE NE 98053       2005
## 475      1534000   2454 W LAKE SAMMAMISH PKWY NE 98052       1963
## 482       555000                3624 175TH CT NE 98052       2007
## 508        65000               7717 252ND AVE NE 98053       2010
## 528       435000   2829 W LAKE SAMMAMISH PKWY NE 98052       2014
## 576       333000                25525 NE 67TH PL 98053       2008
## 661      2569000               8027 255TH AVE NE 98053       2006
## 670      2583000   2612 W LAKE SAMMAMISH PKWY NE 98052       1992
## 679       350000          24300 NE UNION HILL RD 98053       2008
## 784       325000               4224 244TH AVE NE 98053       2015
## 802       340000               4402 244TH AVE NE 98053       2008
## 811      3000000   2438 W LAKE SAMMAMISH PKWY NE 98052       2001
## 853      1595000               24629 NE 109TH ST 98053       1985
## 877       157000               8303 250TH AVE NE 98053       2008
## 916       450000                7350 259TH PL NE 98053       2007
## 1009      175000               5235 279TH AVE NE 98053       2005
## 1119      279150               7515 238TH AVE NE 98053       2007
## 1142      279150               7533 238TH AVE NE 98053       2007
## 1155       32000               8700 196TH AVE NE 98053       2007
## 1305     1316000   2458 W LAKE SAMMAMISH PKWY NE 98052       1929
## 1368      375000                 27935 E MAIN ST 98053       2010
## 1380       80000               3605 289TH AVE NE 98053       2008
## 1442     1085000          3122 W AMES LAKE DR NE 98053       1954
## 1492      285000              11820 204TH AVE NE 98053       2007
## 1504      452800               25509 NE 100TH ST 98053       2008
## 1550      276450              11926 204TH AVE NE 98053       2007
## 1633        5000                8490 138TH LN NE 98052       2014
## 1650      349999 14338 WOODINVILLE REDMOND RD NE 98052       2009
## 1716        1000                22340 NE 65TH PL 98053       2015
## 1745     2235000                23812 NE 61ST ST 98053       2006
## 1870     2988000               4130 244TH AVE NE 98053       2003
## 1962     2493000               8407 255TH AVE NE 98053       2006
## 1963     1600000   2030 W LAKE SAMMAMISH PKWY NE 98052       1978
## 1964     1600000   2030 W LAKE SAMMAMISH PKWY NE 98052       1979
## 1976     2625000                14026 NE 85TH CT 98052       2009
## 1977     2625000                14009 NE 85TH CT 98052       2009
## 1978     2625000                14007 NE 85TH CT 98052       2008
## 1979     2625000                14005 NE 85TH CT 98052       2008
## 1980     2625000                14006 NE 85TH CT 98052       2008
## 1981     2625000                14018 NE 85TH CT 98052       2008
## 1982     2625000                14022 NE 85TH CT 98052       2009
## 2022     1384950   2140 W LAKE SAMMAMISH PKWY NE 98052       1940
## 2099     1975000                5838 246TH PL NE 98053       2004
## 2137     1787000   3272 W LAKE SAMMAMISH PKWY NE 98052       1972
## 2157     1678000   2240 W LAKE SAMMAMISH PKWY NE 98052       1965
## 2257       20000              12726 164TH AVE NE 98052       2015
## 2264     1651000   2632 W LAKE SAMMAMISH PKWY NE 98052       1938
## 2302      450000                18446 NE 95TH ST 98052       2009
## 2360     1640000   2350 W LAKE SAMMAMISH PKWY NE 98052       1968
## 2361     1640000   2350 W LAKE SAMMAMISH PKWY NE 98052       1964
## 2469     1710000   2768 W LAKE SAMMAMISH PKWY NE 98052       1980
## 2604       40191                26909 NE 45TH ST 98053       2008
## 2684     2590000                5215 157TH CT NE 98052       2008
## 2685     2590000                5221 157TH CT NE 98052       2010
## 2686     2590000                5216 157TH CT NE 98052       2008
## 2687     2590000                5209 157TH CT NE 98052       2010
## 2688     2590000                5103 157TH CT NE 98052       2008
## 2689     2590000                5210 157TH CT NE 98052       2008
## 2690     2590000                5104 157TH CT NE 98052       2009
## 2699      379950               6415 196TH AVE NE 98053       2015
## 2708     2300000               9233 255TH AVE NE 98053       2015
## 2709     2300000               9113 258TH AVE NE 98053       2016
## 2710     2300000               9429 255TH AVE NE 98053       2015
## 2717     2598000               8212 255TH AVE NE 98053       2007
## 2742       10570                5826 249TH CT NE 98053       2013
## 2852     3995000              13707 160TH AVE NE 98052       2000
## 2867     1850000               17234 NE 126TH PL 98052       1990
## 2934        1500                22340 NE 65TH PL 98053       2015
## 2937       20000                22340 NE 65TH PL 98053       2015
## 3097     2549000               8406 255TH AVE NE 98053       2007
## 3102     2080000               15335 NE 106TH CT 98052       2008
## 3110     1250000   2524 W LAKE SAMMAMISH PKWY NE 98052       1961
## 3111     1250000   2524 W LAKE SAMMAMISH PKWY NE 98052       1961
## 3168     3175000               23541 NE 111TH ST 98053       2008
## 3169     3175000               23525 NE 111TH ST 98053       2008
## 3170     3175000           11070 ELLISTON WAY NE 98053       2009
## 3171     3175000           11030 ELLISTON WAY NE 98053       2008
## 3172     3175000           11019 ELLISTON WAY NE 98053       2008
## 3173     3175000           11027 ELLISTON WAY NE 98053       2008
## 3174     3175000           11031 ELLISTON WAY NE 98053       2008
## 3175     3175000           11035 ELLISTON WAY NE 98053       2008
## 3176     3175000           11043 ELLISTON WAY NE 98053       2009
## 3177     3175000           11049 ELLISTON WAY NE 98053       2008
## 3178     3175000           11061 ELLISTON WAY NE 98053       2008
## 3179     3175000           11073 ELLISTON WAY NE 98053       2008
## 3180     3175000           11087 ELLISTON WAY NE 98053       2008
## 3181     3175000           11093 ELLISTON WAY NE 98053       2008
## 3182     3175000               23518 NE 111TH ST 98053       2008
## 3183     3175000               23526 NE 111TH ST 98053       2008
## 3184     3175000               23558 NE 111TH ST 98053       2008
## 3185     3175000               23553 NE 111TH ST 98053       2008
## 3186     3175000               23549 NE 111TH ST 98053       2008
## 3187     3175000               23533 NE 111TH ST 98053       2008
## 3188     3175000               23517 NE 111TH ST 98053       2008
## 3189     3175000           11062 ELLISTON WAY NE 98053       2008
## 3190     3175000           11054 ELLISTON WAY NE 98053       2008
## 3191     3175000           11048 ELLISTON WAY NE 98053       2008
## 3192     3175000           11042 ELLISTON WAY NE 98053       2008
## 3193     3175000           11038 ELLISTON WAY NE 98053       2008
## 3194     3175000           11022 ELLISTON WAY NE 98053       2008
## 3195     3175000           11057 ELLISTON WAY NE 98053       2008
## 3196     3175000           11067 ELLISTON WAY NE 98053       2008
## 3197     3175000           11079 ELLISTON WAY NE 98053       2009
## 3198     3175000               23502 NE 111TH ST 98053       2008
## 3199     3175000               23510 NE 111TH ST 98053       2008
## 3200     3175000               23534 NE 111TH ST 98053       2008
## 3201     3175000               23542 NE 111TH ST 98053       2008
## 3202     3175000               23550 NE 111TH ST 98053       2008
## 3424       20146                16771 NE 86TH CT 98052       2008
## 3464     3150000               11044 236TH PL NE 98053       2008
## 3465     3150000               11020 236TH PL NE 98053       2009
## 3466     3150000               11004 236TH PL NE 98053       2008
## 3467     3150000               11005 236TH PL NE 98053       2008
## 3468     3150000               11013 236TH PL NE 98053       2008
## 3469     3150000               11021 236TH PL NE 98053       2008
## 3470     3150000               11029 236TH PL NE 98053       2008
## 3471     3150000               11037 236TH PL NE 98053       2009
## 3472     3150000               11045 236TH PL NE 98053       2008
## 3473     3150000               11053 236TH PL NE 98053       2008
## 3474     3150000               11061 236TH PL NE 98053       2008
## 3475     3150000               11077 236TH PL NE 98053       2008
## 3476     3150000           11001 ELLISTON WAY NE 98053       2008
## 3477     3150000           11011 ELLISTON WAY NE 98053       2008
## 3478     3150000               23566 NE 111TH ST 98053       2008
## 3479     3150000               23574 NE 111TH ST 98053       2008
## 3480     3150000               23600 NE 111TH ST 98053       2008
## 3481     3150000               23608 NE 111TH ST 98053       2008
## 3482     3150000               23616 NE 111TH ST 98053       2008
## 3483     3150000               23632 NE 111TH ST 98053       2008
## 3484     3150000               23656 NE 111TH ST 98053       2008
## 3485     3150000               11092 236TH PL NE 98053       2010
## 3486     3150000               11052 236TH PL NE 98053       2008
## 3487     3150000               11036 236TH PL NE 98053       2009
## 3488     3150000               11028 236TH PL NE 98053       2008
## 3489     3150000               11012 236TH PL NE 98053       2008
## 3490     3150000               11069 236TH PL NE 98053       2008
## 3491     3150000           11018 ELLISTON WAY NE 98053       2008
## 3492     3150000           11014 ELLISTON WAY NE 98053       2009
## 3493     3150000           11006 ELLISTON WAY NE 98053       2008
## 3494     3150000           11007 ELLISTON WAY NE 98053       2008
## 3495     3150000               23624 NE 111TH ST 98053       2008
## 3496     3150000               23640 NE 111TH ST 98053       2008
## 3497     3150000               23648 NE 111TH ST 98053       2008
## 3523     2000000   2400 W LAKE SAMMAMISH PKWY NE 98052       1955
## 3837      130000               22465 NE 111TH LN 98053       2014
## 3918      500000               7515 238TH AVE NE 98053       2007
## 3919      475000               7533 238TH AVE NE 98053       2007
## 4055     2000000   2844 W LAKE SAMMAMISH PKWY NE 98052       1991
## 4056     2000000   2844 W LAKE SAMMAMISH PKWY NE 98052       1937
## 4248        1500               5106 272ND AVE NE 98053       1988
## 4285      155026               9256 225TH WAY NE 98053       2003
## 4391      125000                5920 216TH PL NE 98053       2015
## 4435      188750                15808 NE 51ST ST 98052       2011
## 4571         873               8340 196TH AVE NE 98053       1955
## 4648     4400000               12025 154TH PL NE 98052       1999
## 4649     4400000               12053 154TH PL NE 98052       1935
## 4671      800000               6910 264TH AVE NE 98053       2011
## 4695     2300000   2424 W LAKE SAMMAMISH PKWY NE 98052       2003
## 4696     2300000   2424 W LAKE SAMMAMISH PKWY NE 98052       2005
## 4740     1448000   2850 W LAKE SAMMAMISH PKWY NE 98052       1974
## 4750     2300000                7350 259TH PL NE 98053       2007
## 4821     1430000                8436 143RD CT NE 98052       1999
## 4834     1300000   2140 W LAKE SAMMAMISH PKWY NE 98052       1940
## 4840        6000               8700 196TH AVE NE 98053       2007
## 4934     1780000   3402 W LAKE SAMMAMISH PKWY NE 98052       1959
## 5083         698        19805 NE NOVELTY HILL RD 98053       1969
## 5491     1550000                16644 NE 43RD CT 98052       2011
## 5494     1550000                16525 NE 43RD CT 98052       2011
## 5495     1550000                16631 NE 43RD CT 98052       2011
## 5496     1550000                16639 NE 43RD CT 98052       2011
## 5497     1550000                16501 NE 43RD CT 98052       2011
## 5549      241000               8036 196TH AVE NE 98053       2013
## 5935      180000              10100 203RD AVE NE 98053       2012
## 6055      130000                19821 NE 61ST PL 98053       2013
## 6230     2885000                17144 NE 46TH CT 98052       2012
## 6231     2885000                17372 NE 46TH CT 98052       2014
## 6232     2885000                17376 NE 46TH CT 98052       2013
## 6233     2885000                17380 NE 46TH CT 98052       2013
## 6234     2885000                17252 NE 46TH CT 98052       2012
## 6235     2885000                17256 NE 46TH CT 98052       2012
## 6236     2885000                17260 NE 46TH CT 98052       2012
## 6237     2885000                17364 NE 46TH CT 98052       2013
## 6238     2885000                17368 NE 46TH CT 98052       2013
## 6239     2885000                17384 NE 46TH CT 98052       2014
## 6429     4380542               17137 NE 120TH ST 98052       2012
## 6430     4380542               11818 171ST PL NE 98052       2010
## 6431     4380542              17011 NE 118TH WAY 98052       2012
## 6432     4380542              16943 NE 118TH WAY 98052       2012
## 6433     4380542              16944 NE 118TH WAY 98052       2010
## 6434     4380542               16909 NE 120TH ST 98052       2012
## 6435     4380542               17128 NE 120TH ST 98052       2012
## 6436     4380542               17136 NE 120TH ST 98052       2012
## 6437     4380542               11902 171ST PL NE 98052       2010
## 6438     4380542               11719 171ST PL NE 98052       2011
## 6439     4380542              16955 NE 118TH WAY 98052       2011
## 6440     4380542               11703 169TH PL NE 98052       2012
## 6441     4380542              16906 NE 118TH WAY 98052       2012
## 6442     4380542              17020 NE 118TH WAY 98052       2012
## 6443     4140203               12212 164TH CT NE 98052       2012
## 6444     4140203               12238 164TH CT NE 98052       2012
## 6445     4140203               12300 164TH CT NE 98052       2013
## 6446     4140203               12308 164TH CT NE 98052       2013
## 6447     4140203               12351 164TH CT NE 98052       2012
## 6448     4140203               12261 164TH CT NE 98052       2011
## 6449     4140203               12249 164TH CT NE 98052       2012
## 6450     4140203               12237 164TH CT NE 98052       2012
## 6451     4140203               12228 164TH CT NE 98052       2012
## 6452     4140203               12250 164TH CT NE 98052       2013
## 6453     4140203               12393 164TH CT NE 98052       2013
## 6454     4140203               12375 164TH CT NE 98052       2012
## 6455     4140203               12285 164TH CT NE 98052       2012
## 6456     4140203               12273 164TH CT NE 98052       2012
## 6457     4140203               12225 164TH CT NE 98052       2012
## 6512     2500000   3018 W LAKE SAMMAMISH PKWY NE 98052       1990
## 6527      275000               5120 159TH AVE NE 98052       2012
## 6739       50000                21117 NE 78TH ST 98053       2013
## 6766      155000               2930 288TH AVE NE 98053       2013
## 6796      226610                17340 NE 36TH ST 98052       2014
## 6821       20000                13354 NE 80TH ST 98052       1955
## 6931      149650               8937 236TH AVE NE 98053       2004
## 6938     2300000               11516 174TH CT NE 98052       2013
## 6939     2300000               11527 174TH CT NE 98052       2013
## 6940     2300000               17317 NE 116TH CT 98052       2013
## 6941     2300000               17321 NE 116TH CT 98052       2013
## 6942     2300000               11586 174TH CT NE 98052       2013
## 6943     2300000               11504 174TH CT NE 98052       2013
## 6944     2300000               11503 174TH CT NE 98052       2013
## 6945     2300000               11519 174TH CT NE 98052       2013
## 6946     2300000               11571 174TH CT NE 98052       2013
## 6947     2300000               17327 NE 116TH CT 98052       2013
## 6948     2300000               17333 NE 116TH CT 98052       2013
## 7039     1920000               18852 NE 116TH ST 98052       1976
## 7147      254000               6226 148TH AVE NE 98052       2014
## 7167     3200000   3408 W LAKE SAMMAMISH PKWY NE 98052       1975
## 7210     2500000               16224 NE 130TH ST 98052       1978
## 7211     2500000              13031 164TH AVE NE 98052       1982
## 7446     3462000              10814 240TH AVE NE 98053       2013
## 7447     3462000              10818 240TH AVE NE 98053       2013
## 7448     3462000              10932 240TH AVE NE 98053       2013
## 7449     3462000           10921 EASTRIDGE DR NE 98053       2013
## 7450     3462000           10915 EASTRIDGE DR NE 98053       2013
## 7451     3462000           10821 EASTRIDGE DR NE 98053       2013
## 7452     3462000           10811 EASTRIDGE DR NE 98053       2013
## 7453     3462000              10888 240TH AVE NE 98053       2012
## 7454     3462000              10910 240TH AVE NE 98053       2012
## 7455     3462000              10918 240TH AVE NE 98053       2012
## 7456     3462000              10940 240TH AVE NE 98053       2013
## 7457     3462000              10956 240TH AVE NE 98053       2013
## 7458     3462000           10989 EASTRIDGE DR NE 98053       2013
## 7459     3462000           10945 EASTRIDGE DR NE 98053       2013
## 7460     3462000           10937 EASTRIDGE DR NE 98053       2013
## 7461     3462000           10929 EASTRIDGE DR NE 98053       2013
## 7462     3462000           10909 EASTRIDGE DR NE 98053       2013
## 7463     3462000           10815 EASTRIDGE DR NE 98053       2013
## 7507      229687               4224 244TH AVE NE 98053       2015
## 7649      280000                13521 NE 70TH ST 98052       2014
## 7650      280000                13524 NE 70TH ST 98052       2014
## 7791      525400                26510 NE 70TH ST 98053       2015
## 7871      347000                25025 NE 80TH ST 98053       2015
## 8119      100000                13354 NE 80TH ST 98052       1955
## 8154      192000                21817 NE 97TH PL 98053       2014
## 8232      226000               4224 244TH AVE NE 98053       2015
## 8262     1300000                26408 NE 70TH ST 98053       1999
## 8320      302500              11320 244TH AVE NE 98053       2016
## 8377       14000                20210 NE 85TH ST 98053       1996
## 8457     1586000   2030 W LAKE SAMMAMISH PKWY NE 98052       1978
## 8458     1586000   2030 W LAKE SAMMAMISH PKWY NE 98052       1979
## 8535      245000                13304 NE 75TH ST 98052       2014
## 8541        2500                8490 138TH LN NE 98052       2014
## 8698     1700000   3040 W LAKE SAMMAMISH PKWY NE 98052       2014
## 8710     2750000   3244 W LAKE SAMMAMISH PKWY NE 98052       1996
## 8763     1650000   2608 W LAKE SAMMAMISH PKWY NE 98052       1972
## 8887     3340000   3026 W LAKE SAMMAMISH PKWY NE 98052       2008
## 8911     2160200                2006 250TH PL NE 98074       2003
## 8946     2160200                2006 250TH PL NE 98074       2003
## 9215     1401322             12210 WILLOWS RD NE 98052       1954
## 9293      425000   2829 W LAKE SAMMAMISH PKWY NE 98052       2014
## 9369      150000               2722 288TH AVE NE 98053       2015
## 9420      320000          22614 NE UNION HILL RD 98053       2015
## 9453      299500                22340 NE 65TH PL 98053       2015
## 9528        8000                20338 NE 85TH ST 98053       2006
## 9546      150000               22465 NE 111TH LN 98053       2014
## 9722     1700000   2850 W LAKE SAMMAMISH PKWY NE 98052       1974
## 10125    2200000                20015 NE 85TH ST 98053       1998
## 10318    2140000               8565 261ST AVE NE 98053       1997
## 10371     299000   22016 NE REDMOND FALL CITY RD 98053       2016
## 10418     325000             19841 NE REDMOND RD 98053       2003
## 10623     321000                25621 NE 42ND PL 98053       2016
## 10707    1442500                16410 NE 43RD CT 98052       1987
## 10723    1850000               15339 NE 106TH CT 98052       2008
## 10741     285000               6228 224TH AVE NE 98053       2015
## 10787    2200000   3230 W LAKE SAMMAMISH PKWY NE 98052       1952
## 10844    1200000                15430 NE 51ST ST 98052       1918
## 10958      18000                24143 NE 58TH PL 98053       1997
## 10995    1050000               8513 255TH AVE NE 98053       2005
## 11165    1890000   2410 W LAKE SAMMAMISH PKWY NE 98052       1995
## 11289    2300000   3260 W LAKE SAMMAMISH PKWY NE 98052       1982
## 11413    2025000               8071 208TH AVE NE 98053       1948
## 11558    2150000              11004 132ND AVE NE 98052       1952
## 11586    1700000   2864 W LAKE SAMMAMISH PKWY NE 98052       1938
## 11728    1840000               21031 NE 122ND ST 98053       1981
## 11758     269000   22016 NE REDMOND FALL CITY RD 98053       2016
## 11772    3750000   2808 W LAKE SAMMAMISH PKWY NE 98052       2001
## 11822    2850000   2420 W LAKE SAMMAMISH PKWY NE 98052       2005
## 11898    2165000              11207 248TH AVE NE 98053       1999
## 11899    2165000              11207 248TH AVE NE 98053       1999
## 11982    3175000                7350 259TH PL NE 98053       2007
## 11992    4311000               17656 NE 116TH ST 98052       1964
## 12212    1200000                25205 NE 80TH ST 98053       1932
## 12255    1730000               19610 NE 116TH ST 98053       1980
## 12256    1730000               19610 NE 116TH ST 98053       1980
## 12392    1450000              11220 196TH AVE NE 98053       1987
## 12472    2350000   3020 W LAKE SAMMAMISH PKWY NE 98052       1955
## 12487    2200000   2656 W LAKE SAMMAMISH PKWY NE 98052       1962
## 12577    2700000               7702 196TH AVE NE 98053       2005
## 12582    3950000   2942 W LAKE SAMMAMISH PKWY NE 98052       1974
## 12643    3850000               7917 219TH AVE NE 98053       2009
## 12686     148200          3851 E AMES LAKE DR NE 98053       2006
## 12759    1700000              13301 180TH AVE NE 98052       1990
## 12764    2988000               18025 NE 136TH ST 98052       2006
##       square_feet_total_living
## 6                         4160
## 25                        4920
## 115                        660
## 160                       3840
## 178                       5800
## 239                       3360
## 246                        900
## 287                       4710
## 295                       5060
## 300                       6880
## 341                       4490
## 344                       2700
## 359                       5140
## 385                       6310
## 396                       5080
## 475                       3320
## 482                       6380
## 508                       3700
## 528                       5830
## 576                       4320
## 661                       8090
## 670                       4710
## 679                       8490
## 784                       5150
## 802                       4380
## 811                       5270
## 853                       3470
## 877                       4640
## 916                       7640
## 1009                      4040
## 1119                      6340
## 1142                      5980
## 1155                      4740
## 1305                      2800
## 1368                      4550
## 1380                      3660
## 1442                       340
## 1492                      4610
## 1504                      7780
## 1550                      5380
## 1633                      3130
## 1650                      9360
## 1716                      4610
## 1745                      5360
## 1870                     10630
## 1962                      5300
## 1963                      3090
## 1964                       550
## 1976                      3830
## 1977                      3330
## 1978                      3480
## 1979                      3370
## 1980                      3350
## 1981                      4080
## 1982                      3690
## 2022                       900
## 2099                      5020
## 2137                      2820
## 2157                      3130
## 2257                      2940
## 2264                      1540
## 2302                      6340
## 2360                      3200
## 2361                       310
## 2469                      2980
## 2604                      3060
## 2684                      3410
## 2685                      3660
## 2686                      4500
## 2687                      3480
## 2688                      3310
## 2689                      4340
## 2690                      4390
## 2699                      5270
## 2708                      4710
## 2709                      5100
## 2710                      4910
## 2717                      5390
## 2742                      3950
## 2852                     11810
## 2867                      5400
## 2934                      4610
## 2937                      4610
## 3097                      5320
## 3102                      4790
## 3110                      1290
## 3111                      1920
## 3168                      1290
## 3169                      1290
## 3170                      1600
## 3171                      1740
## 3172                      1710
## 3173                      1740
## 3174                      1710
## 3175                      1460
## 3176                      1820
## 3177                      1840
## 3178                      1840
## 3179                      1600
## 3180                      1840
## 3181                      1600
## 3182                      1290
## 3183                      1290
## 3184                      1290
## 3185                      1290
## 3186                      1290
## 3187                      1290
## 3188                      1290
## 3189                      1460
## 3190                      1710
## 3191                      1460
## 3192                      1740
## 3193                      1710
## 3194                      1710
## 3195                      1840
## 3196                      1840
## 3197                      1820
## 3198                      1290
## 3199                      1290
## 3200                      1290
## 3201                      1290
## 3202                      1290
## 3424                      4290
## 3464                      1460
## 3465                      1600
## 3466                      1840
## 3467                      1840
## 3468                      1460
## 3469                      1600
## 3470                      1840
## 3471                      1600
## 3472                      1740
## 3473                      1710
## 3474                      1460
## 3475                      1740
## 3476                      1830
## 3477                      1740
## 3478                      1290
## 3479                      1290
## 3480                      1290
## 3481                      1290
## 3482                      1290
## 3483                      1290
## 3484                      1290
## 3485                      1840
## 3486                      1600
## 3487                      1840
## 3488                      1710
## 3489                      1740
## 3490                      1710
## 3491                      1840
## 3492                      1600
## 3493                      1840
## 3494                      1460
## 3495                      1290
## 3496                      1290
## 3497                      1290
## 3523                      3980
## 3837                      4480
## 3918                      6340
## 3919                      5980
## 4055                      4110
## 4056                       900
## 4248                      2610
## 4285                      4180
## 4391                      3140
## 4435                      4330
## 4571                      3430
## 4648                      5790
## 4649                      2410
## 4671                      7810
## 4695                      1430
## 4696                      5330
## 4740                      2900
## 4750                      7640
## 4821                       890
## 4834                       900
## 4840                      4740
## 4934                      4210
## 5083                      5830
## 5491                      2960
## 5494                      3010
## 5495                      2960
## 5496                      2960
## 5497                      2950
## 5549                      4130
## 5935                      5640
## 6055                      3500
## 6230                      3320
## 6231                      3530
## 6232                      3720
## 6233                      3150
## 6234                      3340
## 6235                      3320
## 6236                      3340
## 6237                      3320
## 6238                      3060
## 6239                      3530
## 6429                      3290
## 6430                      2450
## 6431                      2750
## 6432                      3010
## 6433                      3200
## 6434                      3200
## 6435                      3620
## 6436                      2810
## 6437                      2550
## 6438                      2440
## 6439                      3160
## 6440                      3400
## 6441                      2960
## 6442                      3110
## 6443                      2900
## 6444                      3220
## 6445                      2510
## 6446                      2970
## 6447                      3470
## 6448                      2580
## 6449                      3590
## 6450                      3890
## 6451                      2520
## 6452                      2990
## 6453                      3620
## 6454                      3300
## 6455                      2830
## 6456                      2680
## 6457                      3330
## 6512                      5040
## 6527                      5050
## 6739                      3850
## 6766                      2550
## 6796                      4000
## 6821                      4200
## 6931                      4000
## 6938                      3970
## 6939                      4610
## 6940                      3360
## 6941                      3370
## 6942                      4390
## 6943                      4380
## 6944                      4790
## 6945                      3970
## 6946                      3370
## 6947                      3260
## 6948                      3210
## 7039                      5320
## 7147                      5370
## 7167                      4460
## 7210                      4460
## 7211                      3640
## 7446                      2650
## 7447                      2520
## 7448                      2655
## 7449                      2520
## 7450                      2515
## 7451                      2510
## 7452                      2520
## 7453                      2630
## 7454                      2640
## 7455                      2530
## 7456                      2520
## 7457                      2640
## 7458                      2510
## 7459                      2445
## 7460                      2515
## 7461                      2475
## 7462                      2460
## 7463                      2475
## 7507                      5150
## 7649                      4350
## 7650                      4350
## 7791                      5620
## 7871                      6650
## 8119                      4200
## 8154                      3960
## 8232                      5150
## 8262                     13540
## 8320                      5820
## 8377                      8750
## 8457                      3090
## 8458                       550
## 8535                      4420
## 8541                      3130
## 8698                      3380
## 8710                      4950
## 8763                      3460
## 8887                      6360
## 8911                      6280
## 8946                      6280
## 9215                      1650
## 9293                      5830
## 9369                      3240
## 9420                      4800
## 9453                      4610
## 9528                      7110
## 9546                      4480
## 9722                      2900
## 10125                     6680
## 10318                     5150
## 10371                     4930
## 10418                     4770
## 10623                     4570
## 10707                     2630
## 10723                     4790
## 10741                     4200
## 10787                     4640
## 10844                     1800
## 10958                     4010
## 10995                     9070
## 11165                     4140
## 11289                     3310
## 11413                     2610
## 11558                      730
## 11586                     2770
## 11728                     2280
## 11758                     4930
## 11772                     6600
## 11822                     4240
## 11898                     3690
## 11899                     1230
## 11982                     7640
## 11992                     1670
## 12212                      820
## 12255                     1650
## 12256                     3260
## 12392                     2140
## 12472                     3150
## 12487                     5000
## 12577                     5030
## 12582                     7070
## 12643                     4690
## 12686                     3720
## 12759                     4380
## 12764                     6990

calculate leverage, cook’s distance and covariance ratios

homesales$cooks.distance <- cooks.distance(homesales2)
homesales$leverage <- hatvalues(homesales2)
homesales$covariance.ratios <- covratio(homesales2)
homesales[homesales$large.residual, c("cooks.distance", "leverage", "covariance.ratios")]
##       cooks.distance     leverage covariance.ratios
## 6       0.0003786119 3.206527e-04         0.9991633
## 25      0.0008996870 6.219188e-04         0.9991345
## 115     0.0040741281 1.735686e-03         0.9991324
## 160     0.0014918590 1.334527e-03         1.0002574
## 178     0.0013674027 9.234733e-04         0.9993943
## 239     0.0001783162 1.573739e-04         0.9990592
## 246     0.0051550064 1.596054e-03         0.9978968
## 287     0.0008192822 4.950746e-04         0.9987487
## 295     0.0010288656 6.526365e-04         0.9990039
## 300     0.0089655448 2.676565e-03         0.9988337
## 341     0.0004153141 3.885293e-04         0.9993703
## 344     0.0103999269 8.403722e-03         1.0072495
## 359     0.0025140509 1.266065e-03         0.9991103
## 385     0.0034436518 1.273529e-03         0.9982258
## 396     0.0019727976 9.956501e-04         0.9988445
## 475     0.0007174399 5.259101e-04         0.9991408
## 482     0.0016488903 1.368855e-03         1.0001840
## 508     0.0037460466 2.244823e-03         1.0004866
## 528     0.0013766838 1.016638e-03         0.9996449
## 576     0.0012653507 1.221090e-03         1.0002451
## 661     0.0043654857 2.721463e-03         1.0010461
## 670     0.0026620678 5.532028e-04         0.9948897
## 679     0.0110155133 2.968427e-03         0.9986792
## 784     0.0022094263 1.413021e-03         0.9997821
## 802     0.0012580374 1.206275e-03         1.0002220
## 811     0.0050272267 7.379854e-04         0.9925994
## 853     0.0007886185 7.034817e-04         0.9996209
## 877     0.0021996661 1.229049e-03         0.9993166
## 916     0.0056933033 2.243517e-03         0.9994060
## 1009    0.0003070119 2.615081e-04         0.9991125
## 1119    0.0027951267 1.263876e-03         0.9988276
## 1142    0.0020380856 1.029285e-03         0.9988799
## 1155    0.0195775221 6.981544e-03         1.0038587
## 1305    0.0018071616 1.433052e-03         1.0001782
## 1368    0.0011232454 1.094906e-03         1.0001315
## 1380    0.0002658155 2.074826e-04         0.9989253
## 1442    0.0010899082 6.843401e-04         0.9990156
## 1492    0.0006205572 5.128773e-04         0.9993195
## 1504    0.0084924616 3.019928e-03         0.9998461
## 1550    0.0012901280 7.732854e-04         0.9990106
## 1633    0.0002581482 2.006823e-04         0.9989120
## 1650    0.0180781135 4.075723e-03         0.9988962
## 1716    0.0012360741 5.309096e-04         0.9979482
## 1745    0.0015802035 7.162464e-04         0.9982853
## 1870    0.0090535902 5.660062e-03         1.0040160
## 1962    0.0034523123 1.057159e-03         0.9973119
## 1963    0.0003313060 2.121601e-04         0.9985814
## 1964    0.0013690239 4.055014e-04         0.9965220
## 1976    0.0014186714 2.483554e-04         0.9934698
## 1977    0.0010989366 1.748296e-04         0.9926865
## 1978    0.0011303787 1.845172e-04         0.9928937
## 1979    0.0010854651 1.734164e-04         0.9927179
## 1980    0.0010861113 1.727814e-04         0.9926841
## 1981    0.0016516685 3.025577e-04         0.9938376
## 1982    0.0013259343 2.257156e-04         0.9932465
## 2022    0.0022503071 8.641750e-04         0.9979396
## 2099    0.0008212073 5.675052e-04         0.9990795
## 2137    0.0006314130 2.470687e-04         0.9973817
## 2157    0.0008458614 4.289362e-04         0.9982885
## 2257    0.0002424133 2.077547e-04         0.9990677
## 2264    0.0029822023 8.795848e-04         0.9969791
## 2302    0.0020485512 1.322888e-03         0.9997104
## 2360    0.0006568707 3.769444e-04         0.9985214
## 2361    0.0022719723 5.624629e-04         0.9958567
## 2469    0.0003484108 1.726631e-04         0.9979750
## 2604    0.0001736068 1.548624e-04         0.9990717
## 2684    0.0010750288 1.799420e-04         0.9930770
## 2685    0.0012827808 2.268448e-04         0.9935193
## 2686    0.0020716549 4.314632e-04         0.9947810
## 2687    0.0011775318 2.010374e-04         0.9932430
## 2688    0.0010261141 1.685239e-04         0.9929239
## 2689    0.0018898151 3.805644e-04         0.9945264
## 2690    0.0019433263 3.969598e-04         0.9946299
## 2699    0.0610004015 2.504189e-02         1.0229761
## 2708    0.0016526131 5.956223e-04         0.9974588
## 2709    0.0019542860 8.011953e-04         0.9980811
## 2710    0.0020945930 8.143143e-04         0.9979291
## 2717    0.0044039902 1.190442e-03         0.9969074
## 2742    0.0006129755 3.396996e-04         0.9984073
## 2852    0.0448084144 7.459410e-03         1.0003742
## 2867    0.0008756189 8.643949e-04         0.9999165
## 2934    0.0012349398 5.309096e-04         0.9979509
## 2937    0.0011933361 5.309096e-04         0.9980482
## 3097    0.0037436999 1.062350e-03         0.9969966
## 3102    0.0010527025 5.305816e-04         0.9983753
## 3110    0.0006043130 3.882771e-04         0.9987642
## 3111    0.0004289112 3.539678e-04         0.9991582
## 3168    0.0048353662 3.422295e-04         0.9831861
## 3169    0.0048353662 3.422295e-04         0.9831861
## 3170    0.0037900061 2.797401e-04         0.9838369
## 3171    0.0031633555 2.370321e-04         0.9840432
## 3172    0.0032591200 2.433284e-04         0.9839902
## 3173    0.0031680599 2.374391e-04         0.9840474
## 3174    0.0032584052 2.432677e-04         0.9839897
## 3175    0.0041317843 2.988310e-04         0.9835142
## 3176    0.0030827320 2.339303e-04         0.9842462
## 3177    0.0028845637 2.189748e-04         0.9842373
## 3178    0.0028861594 2.191171e-04         0.9842390
## 3179    0.0036231322 2.667836e-04         0.9837840
## 3180    0.0028884200 2.193161e-04         0.9842412
## 3181    0.0036216846 2.666649e-04         0.9837832
## 3182    0.0048370220 3.423599e-04         0.9831869
## 3183    0.0048340335 3.421243e-04         0.9831854
## 3184    0.0048340335 3.421243e-04         0.9831854
## 3185    0.0048372178 3.423753e-04         0.9831870
## 3186    0.0048353662 3.422295e-04         0.9831861
## 3187    0.0048353662 3.422295e-04         0.9831861
## 3188    0.0048480604 3.432253e-04         0.9831920
## 3189    0.0041297057 2.986639e-04         0.9835131
## 3190    0.0032550812 2.429833e-04         0.9839869
## 3191    0.0041288784 2.985973e-04         0.9835127
## 3192    0.0031637968 2.370706e-04         0.9840436
## 3193    0.0032543520 2.429204e-04         0.9839863
## 3194    0.0032538755 2.428792e-04         0.9839859
## 3195    0.0028853418 2.190444e-04         0.9842382
## 3196    0.0028870095 2.191922e-04         0.9842399
## 3197    0.0030945613 2.349509e-04         0.9842557
## 3198    0.0048404537 3.426297e-04         0.9831885
## 3199    0.0048401663 3.426072e-04         0.9831884
## 3200    0.0048340335 3.421243e-04         0.9831854
## 3201    0.0048340335 3.421243e-04         0.9831854
## 3202    0.0048340335 3.421243e-04         0.9831854
## 3424    0.0006578619 3.551590e-04         0.9983634
## 3464    0.0040509577 2.985521e-04         0.9838307
## 3465    0.0037005325 2.782561e-04         0.9841418
## 3466    0.0028284732 2.189086e-04         0.9845474
## 3467    0.0028320388 2.192327e-04         0.9845512
## 3468    0.0040531208 2.987298e-04         0.9838319
## 3469    0.0035460814 2.660647e-04         0.9840941
## 3470    0.0028276297 2.188305e-04         0.9845464
## 3471    0.0037021298 2.783914e-04         0.9841428
## 3472    0.0031033652 2.370624e-04         0.9843564
## 3473    0.0031949437 2.431432e-04         0.9843019
## 3474    0.0040582632 2.991506e-04         0.9838347
## 3475    0.0031080513 2.374757e-04         0.9843605
## 3476    0.0028553700 2.207114e-04         0.9845291
## 3477    0.0031064222 2.373330e-04         0.9843592
## 3478    0.0047444125 3.421243e-04         0.9835072
## 3479    0.0047444125 3.421243e-04         0.9835072
## 3480    0.0047444125 3.421243e-04         0.9835072
## 3481    0.0047444125 3.421243e-04         0.9835072
## 3482    0.0047444125 3.421243e-04         0.9835072
## 3483    0.0047444214 3.421251e-04         0.9835072
## 3484    0.0047443858 3.421222e-04         0.9835072
## 3485    0.0031159380 2.422344e-04         0.9846414
## 3486    0.0035453360 2.660015e-04         0.9840936
## 3487    0.0029685404 2.302604e-04         0.9845940
## 3488    0.0031919770 2.428828e-04         0.9842993
## 3489    0.0031015990 2.369040e-04         0.9843546
## 3490    0.0031950517 2.431526e-04         0.9843020
## 3491    0.0028273493 2.188044e-04         0.9845460
## 3492    0.0037007925 2.782782e-04         0.9841420
## 3493    0.0028291972 2.189752e-04         0.9845482
## 3494    0.0040536602 2.987741e-04         0.9838322
## 3495    0.0047444214 3.421251e-04         0.9835072
## 3496    0.0047444214 3.421251e-04         0.9835072
## 3497    0.0047444214 3.421251e-04         0.9835072
## 3523    0.0026508257 9.226346e-04         0.9976642
## 3837    0.0008982730 5.199545e-04         0.9986833
## 3918    0.0017526328 1.263876e-03         0.9998524
## 3919    0.0013206358 1.029285e-03         0.9997460
## 4055    0.0007882483 3.407559e-04         0.9977764
## 4056    0.0058836897 9.494907e-04         0.9935725
## 4248    0.0011810632 1.170288e-03         1.0002278
## 4285    0.0004103083 3.240811e-04         0.9990607
## 4391    0.0020970477 1.802946e-03         1.0006712
## 4435    0.0004925569 3.746697e-04         0.9990510
## 4571    0.0007270647 7.104353e-04         0.9997493
## 4648    0.1800856691 1.003828e-02         0.9883132
## 4649    1.1769957921 4.365379e-02         1.0128200
## 4671    0.0046273853 3.142908e-03         1.0016339
## 4695    0.0016467356 2.602263e-04         0.9927196
## 4696    0.0019306262 7.541541e-04         0.9978840
## 4740    0.0002836988 2.351624e-04         0.9990459
## 4750    0.0022546554 2.243517e-03         1.0013103
## 4821    0.0007627341 3.662813e-04         0.9980887
## 4834    0.0019306063 8.641750e-04         0.9983990
## 4840    0.0204438832 6.981544e-03         1.0037047
## 4934    0.0016263328 9.335410e-04         0.9990796
## 5083    0.1320504653 2.973075e-02         1.0254461
## 5491    0.0001929156 1.654051e-04         0.9990259
## 5494    0.0001911179 1.673503e-04         0.9990581
## 5495    0.0001938638 1.660483e-04         0.9990251
## 5496    0.0001930188 1.654742e-04         0.9990258
## 5497    0.0001948333 1.660888e-04         0.9990182
## 5549    0.0005138256 4.461296e-04         0.9993250
## 5935    0.0022001806 9.567101e-04         0.9984101
## 6055    0.0016298308 1.273361e-03         0.9999946
## 6230    0.0016145639 1.970646e-04         0.9903512
## 6231    0.0018602312 2.363573e-04         0.9907890
## 6232    0.0019495726 2.550420e-04         0.9910873
## 6233    0.0016180218 1.926846e-04         0.9900947
## 6234    0.0016248097 1.989621e-04         0.9903860
## 6235    0.0016134663 1.969388e-04         0.9903515
## 6236    0.0016241298 1.988838e-04         0.9903862
## 6237    0.0016764588 2.052034e-04         0.9903882
## 6238    0.0016046873 1.883606e-04         0.9899398
## 6239    0.0018608539 2.364312e-04         0.9907889
## 6429    0.0047518776 1.929573e-04         0.9702076
## 6430    0.0044575261 1.669673e-04         0.9676663
## 6431    0.0045203752 1.745775e-04         0.9686498
## 6432    0.0044307491 1.753499e-04         0.9694102
## 6433    0.0042880911 1.720489e-04         0.9698255
## 6434    0.0046572420 1.874667e-04         0.9699389
## 6435    0.0054560138 2.286800e-04         0.9711775
## 6436    0.0044421539 1.727114e-04         0.9688582
## 6437    0.0042731544 1.615057e-04         0.9679506
## 6438    0.0047499885 1.780232e-04         0.9676957
## 6439    0.0043885199 1.757414e-04         0.9697711
## 6440    0.0049617830 2.035737e-04         0.9705262
## 6441    0.0044736804 1.761038e-04         0.9692461
## 6442    0.0045447637 1.814312e-04         0.9696819
## 6443    0.0038911815 1.748394e-04         0.9730759
## 6444    0.0040840289 1.894174e-04         0.9739375
## 6445    0.0045098703 1.953908e-04         0.9720906
## 6446    0.0041026237 1.859288e-04         0.9733188
## 6447    0.0044755781 2.129193e-04         0.9746209
## 6448    0.0039017399 1.696550e-04         0.9721662
## 6449    0.0047319781 2.279179e-04         0.9749511
## 6450    0.0056553251 2.808689e-04         0.9757691
## 6451    0.0042406567 1.835807e-04         0.9720564
## 6452    0.0041075973 1.865188e-04         0.9733719
## 6453    0.0049496689 2.395539e-04         0.9750845
## 6454    0.0041813564 1.955152e-04         0.9741566
## 6455    0.0038882018 1.735664e-04         0.9728966
## 6456    0.0039983513 1.758944e-04         0.9724971
## 6457    0.0042297917 1.983749e-04         0.9742377
## 6512    0.0029029073 7.199107e-04         0.9960231
## 6527    0.0008947873 6.217587e-04         0.9991437
## 6739    0.0004613583 2.914610e-04         0.9986343
## 6766    0.0076877384 7.564572e-03         1.0066716
## 6796    0.0003264600 3.083179e-04         0.9993026
## 6821    0.0013239946 1.040755e-03         0.9997710
## 6931    0.0003315936 2.768138e-04         0.9990982
## 6938    0.0010770205 3.022898e-04         0.9961871
## 6939    0.0014447326 4.778399e-04         0.9970320
## 6940    0.0008567372 2.080121e-04         0.9954035
## 6941    0.0008520316 2.075052e-04         0.9954186
## 6942    0.0013055232 4.075967e-04         0.9967389
## 6943    0.0013019166 4.053457e-04         0.9967257
## 6944    0.0015577149 5.409615e-04         0.9972739
## 6945    0.0010770205 3.022898e-04         0.9961871
## 6946    0.0008579593 2.088057e-04         0.9954164
## 6947    0.0008386385 1.990590e-04         0.9952776
## 6948    0.0008297585 1.948163e-04         0.9952161
## 7039    0.0014192040 1.105810e-03         0.9998223
## 7147    0.0013316292 7.756072e-04         0.9989526
## 7167    0.0067486219 6.659268e-04         0.9884256
## 7210    0.0046751759 1.043304e-03         0.9957909
## 7211    0.0029470393 5.522945e-04         0.9942399
## 7446    0.0027496462 1.882051e-04         0.9824416
## 7447    0.0028905678 1.947612e-04         0.9821637
## 7448    0.0027435033 1.879167e-04         0.9824539
## 7449    0.0028916806 1.948163e-04         0.9821619
## 7450    0.0028981562 1.951341e-04         0.9821511
## 7451    0.0029046674 1.954546e-04         0.9821404
## 7452    0.0028900522 1.947369e-04         0.9821646
## 7453    0.0026134937 1.780907e-04         0.9823514
## 7454    0.0026044760 1.776953e-04         0.9823732
## 7455    0.0027166350 1.828912e-04         0.9821368
## 7456    0.0028906475 1.947650e-04         0.9821635
## 7457    0.0027593031 1.886302e-04         0.9824196
## 7458    0.0029029724 1.953748e-04         0.9821436
## 7459    0.0029966823 2.000699e-04         0.9820014
## 7460    0.0028981562 1.951341e-04         0.9821511
## 7461    0.0029525764 1.978397e-04         0.9820655
## 7462    0.0029742694 1.989330e-04         0.9820334
## 7463    0.0029525458 1.978383e-04         0.9820656
## 7507    0.0027068028 1.413021e-03         0.9993448
## 7649    0.0004269719 3.991099e-04         0.9993798
## 7650    0.0004273070 3.994994e-04         0.9993804
## 7791    0.0017592217 1.514207e-03         1.0003830
## 7871    0.0077407189 2.979407e-03         1.0000710
## 8119    0.0010738887 1.040755e-03         1.0000698
## 8154    0.0003579616 3.038300e-04         0.9991497
## 8232    0.0027270564 1.413021e-03         0.9993270
## 8262    0.0358408052 1.073599e-02         1.0070189
## 8320    0.0110337357 4.680867e-03         1.0020852
## 8377    0.6636528396 6.370680e-02         1.0554687
## 8457    0.0003209938 2.121601e-04         0.9986418
## 8458    0.0013399647 4.055014e-04         0.9966109
## 8535    0.0005038155 4.160318e-04         0.9992212
## 8541    0.0002597440 2.006823e-04         0.9989021
## 8698    0.0002953519 2.133484e-04         0.9988029
## 8710    0.0034828842 6.275339e-04         0.9940502
## 8763    0.0006188175 3.892478e-04         0.9987237
## 8887    0.0104601632 1.330079e-03         0.9918923
## 8911    0.0016479316 1.216828e-03         0.9998455
## 8946    0.0016479316 1.216828e-03         0.9998455
## 9215    0.0042542061 2.576135e-03         1.0008412
## 9293    0.0014100380 1.016638e-03         0.9996042
## 9369    0.0023524641 2.036880e-03         1.0009163
## 9420    0.0085285048 5.204139e-03         1.0035062
## 9453    0.0006515232 5.309096e-04         0.9993161
## 9528    0.0095261587 2.136525e-03         0.9969157
## 9546    0.0008603946 5.199545e-04         0.9987738
## 9722    0.0004952458 2.351624e-04         0.9979281
## 10125   0.0020786427 1.678259e-03         1.0004522
## 10318   0.0261844364 2.222189e-02         1.0215795
## 10371   0.0009624012 6.752997e-04         0.9992147
## 10418   0.0020804200 1.630009e-03         1.0003569
## 10623   0.0006826384 5.861345e-04         0.9994492
## 10707   0.0001214075 9.981802e-05         0.9988982
## 10723   0.0006302687 5.334653e-04         0.9993755
## 10741   0.0003508417 3.469648e-04         0.9994005
## 10787   0.0045484606 1.349635e-03         0.9974755
## 10844   0.0023988819 1.597504e-03         1.0000442
## 10958   0.0006636672 3.940425e-04         0.9986111
## 10995   0.0044475345 3.705608e-03         1.0025388
## 11165   0.0005876438 3.254236e-04         0.9983914
## 11289   0.0010351137 2.207959e-04         0.9947106
## 11413   0.0046745001 1.158445e-03         0.9964591
## 11558   0.0044728700 6.238003e-04         0.9920420
## 11586   0.0028588670 1.076254e-03         0.9980872
## 11728   0.0119150426 4.675383e-03         1.0018422
## 11758   0.0010313489 6.752997e-04         0.9990878
## 11772   0.0167299080 1.496278e-03         0.9879681
## 11822   0.0022709876 3.299199e-04         0.9921025
## 11898   0.0663281580 3.418654e-02         1.0333064
## 11899   0.1463847873 3.690804e-02         1.0337185
## 11982   0.0111575241 2.243517e-03         0.9963857
## 11992   0.1259398797 4.502498e-03         0.9704760
## 12212   0.0027848613 1.538777e-03         0.9996024
## 12255   0.0037819076 1.348070e-03         0.9981747
## 12256   0.0018448651 1.092883e-03         0.9993064
## 12392   0.0011421621 8.560378e-04         0.9995087
## 12472   0.0035237958 6.248723e-04         0.9939372
## 12487   0.0037885394 1.288023e-03         0.9979458
## 12577   0.0062196039 1.352017e-03         0.9959528
## 12582   0.0322490030 2.443888e-03         0.9864407
## 12643   0.0071298373 4.740877e-04         0.9822009
## 12686   0.0002249663 2.063750e-04         0.9991617
## 12759   0.0004195772 3.964855e-04         0.9993916
## 12764   0.0095134947 2.178446e-03         0.9970713

k. none of the values in cook’s distance is greater than 1, so none of the cases is having an undue influence on the model. the average leverage is equal to 4/12865=3.10e-04 and all cases are within boundary of the 3 times the average and many cases are close to 2 times the average.

covariance ration should be between [1 + 3(4/12865)] = 1.0009 and [1-3(4/12865)] = 0.999

there are many cases outside but very close to these boundaries. However given the Cook’s distance no or little cause for alarm

##dwtest(homesales2)

l.the DW value is 0.56049, which means the value is within the limits. anything greater than 3 or less than 1 should raise alarm.

Perform the necessary calculations to assess the assumption of no multicollinearity and state if the condition is met or not.

##vif(homesales2)
##1/vif(homesales2)
##mean(vif(homesales2))

m. The laregest vif(1.16) is not greater than 10. The tolerance values are well above 0.2 and the average VIF is 1.1605. All these values indicate there is no collinearity within the data.

use plot() and hist() functions

plot(homesales2)

hist(homesales$studentized.residuals)

#### n. I think the fitted values against residuals indicates the values are evenly distributed around 0. So I assume that this is linear graph. I don’t see any funnel type data. So it is does not violate homoscedasticity #### o. The histogram for residulas looks similar to bell shape. So the data is not skewed and it is not biased either. Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.