-
Notifications
You must be signed in to change notification settings - Fork 0
/
DSC 423 - Quiz 0701.R
111 lines (77 loc) · 2.76 KB
/
DSC 423 - Quiz 0701.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# 1
seatpos <- read.csv("C:\\Users\\wodnj\\OneDrive\\바탕 화면\\Data Analysis and Regression\\DSC 423 - Week 7\\Data File\\seatpos.csv")
# 2, 3
plot(seatpos)
# 4, 5
cor(seatpos)
# 6
model.seatpos <- lm(hipcenter ~ ., data = seatpos)
summary(model.seatpos)
# 7
library(car)
vif(model.seatpos)
# 9
flights <- read.csv("C:\\Users\\wodnj\\OneDrive\\바탕 화면\\Data Analysis and Regression\\DSC 423 - Week 7\\Data File\\flights.csv")
# 10
flights <- flights[complete.cases(flights), ]
# 11
flights$delay <- flights$dep_time - flights$sched_dep_time
# 12
flights$late <- flights$arr_time - flights$sched_arr_time
# 13
flights$time <- flights$arr_time - flights$dep_time
flights$speed <- flights$distance / flights$time
# 14
flightsJan <- flights[flights$month == 1, ]
summary(flightsJan)
# 15
flightsJun <- flights[flights$month == 6, ]
summary(flightsJun)
# 16
flightsUA <- flights[flights$carrier == 'UA', ]
summary(flightsUA)
# 17, 18, 19
wafer <- read.table("C:\\Users\\wodnj\\OneDrive\\바탕 화면\\Data Analysis and Regression\\DSC 423 - Week 7\\Data File\\WAFER.txt", header = TRUE)
model.wafer <- lm(FAILTIME ~ TEMP, data = wafer)
summary(model.wafer)
# 20
model.wafer$residuals
plot( wafer$TEMP,model.wafer$residuals )
# 21, 22, 23, 24
wafer$TEMP_SQ <- wafer$TEMP * wafer$TEMP
model.wafer2 <- lm(FAILTIME ~ TEMP + TEMP_SQ, data = wafer)
summary(model.wafer2)
# 26, 27, 28
appliance <- read.table("C:\\Users\\wodnj\\OneDrive\\바탕 화면\\Data Analysis and Regression\\DSC 423 - Week 7\\Data File\\APPLIANCE.txt", header = TRUE)
model.appliance <- lm(BUYPROP ~ AGE, data = appliance)
summary(model.appliance)
# 29
plot(model.appliance$fitted.values, model.appliance$residuals)
# 30, 31
appliance$Y_TRANS <- asin(sqrt(appliance$BUYPROP))
model.appliance2 <- lm(Y_TRANS ~ AGE, data = appliance)
summary(model.appliance2)
# 32
gasturbine <- read.table("C:\\Users\\wodnj\\OneDrive\\바탕 화면\\Data Analysis and Regression\\DSC 423 - Week 7\\Data File\\GASTURBINE.txt", header = TRUE)
model.gasturbine <- lm(HEATRATE ~ RPM + CPRATIO, data = gasturbine)
summary(model.gasturbine)
# 33, 34
hist(model.gasturbine$residuals)
# 35
set.seed(37)
x <- rnorm(100)
qqnorm(x)
qqline(x)
# 36
qqnorm(model.gasturbine$residuals)
qqline(model.gasturbine$residuals)
# 37, 38, 39
misswork <- read.table("C:\\Users\\wodnj\\OneDrive\\바탕 화면\\Data Analysis and Regression\\DSC 423 - Week 7\\Data File\\MISSWORK.txt", header = TRUE)
model.misswork <- lm(HOURS ~ WAGES, data = misswork)
summary(model.misswork)
# 40
plot(misswork$WAGES, model.misswork$residuals)
# 41
misswork.clean <- misswork[-13, ]
model.misswork2 <- lm(HOURS ~ WAGES, data = misswork.clean)
summary(model.misswork2)