getwd()
## [1] "C:/data"
setwd("c:/data")
df<-read.csv("Data1.csv")
attach(swiss)
bs.out2=lm(Fertility ~ .,swiss)
summary(bs.out2)
## 
## Call:
## lm(formula = Fertility ~ ., data = swiss)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -15.2743  -5.2617   0.5032   4.1198  15.3213 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      66.91518   10.70604   6.250 1.91e-07 ***
## Agriculture      -0.17211    0.07030  -2.448  0.01873 *  
## Examination      -0.25801    0.25388  -1.016  0.31546    
## Education        -0.87094    0.18303  -4.758 2.43e-05 ***
## Catholic          0.10412    0.03526   2.953  0.00519 ** 
## Infant.Mortality  1.07705    0.38172   2.822  0.00734 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.165 on 41 degrees of freedom
## Multiple R-squared:  0.7067, Adjusted R-squared:  0.671 
## F-statistic: 19.76 on 5 and 41 DF,  p-value: 5.594e-10
library(car)
## Warning: 패키지 'car'는 R 버전 4.2.3에서 작성되었습니다
## 필요한 패키지를 로딩중입니다: carData
## Warning: 패키지 'carData'는 R 버전 4.2.3에서 작성되었습니다
sreg.res1=residuals(bs.out2)
durbinWatsonTest(sreg.res1)
## [1] 1.453536
par(mfrow=c(2,2))
plot(bs.out2)

shapiro.test(sreg.res1)
## 
##  Shapiro-Wilk normality test
## 
## data:  sreg.res1
## W = 0.98892, p-value = 0.9318