Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
>
> source("C:\\Users\\Stark\\Desktop\\table1.txt")
Error in source("C:\\Users\\Stark\\Desktop\\table1.txt") :
C:\Users\Stark\Desktop\table1.txt:1:17: unexpected symbol
1: observation
^
> pesawat = read.table("C:\\Users\\Stark\\Desktop\\table1.txt" , header = TRUE)
> pesawat
observation y x1 x2 x3 x4 x5 x6
1
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
>
> ## simplify for only required data that had been given
>
> mirage = c("y","x1","x5")
> sukhoi = pesawat[mirage]
> sukhoi
y x1 x5
1 4540 2140 1732
2 4315 2016 1697
3 4095 1905 1662
4 3650 1675 1598
5 3200 1474 1541
6 4833 2239 1709
7 4617 2120 1669
8 4340 1990 1640
9 3820 1702 1572
10 3368 1487 1522
11 4445 2107 1740
12 4188 1973 1711
13 3981 1864 1682
14 3622 1674 1630
15 3125 1440 1572
> ## Variance
> var(y)
[1] 254667.6
> var(x1)
[1] 63479.05
> var(x5)
[1] 4922.849
>
> ## Standard Deviation
> sd(y)
[1] 504.646
> sd(x1)
[1] 251.9505
> sd(x5)
[1] 70.16302
>
> ## In summary
> colMeans(sukhoi)
y
x1
x5
x1
x5
sd(<data.frame>) is deprecated.
Use sapply(*, sd) instead.
>
> ## Stem
> stem(y)
30 | 56783
32 | 017
34 | 7833
36 | 235
38 | 294778
40 | 022389
42 | 023445
44 | 01546
46 | 2
48 | 3
> stem(x1)
13 | 9
14 | 0114799
15 | 9
16 | 012678
17 | 0
18 | 12346
19 | 12344579
20 | 255677
21 | 1247
22 | 4
> stem(x5)
152 | 228
154 | 1
156 | 199226
158 | 8
160 | 96
162 | 140
164 | 02
166 | 27999
168 | 24027
170 | 49134
172 | 992
174 | 0688
> boxplot(sukhoi)
> boxplot(y)
> boxplot(x1)
> boxplot(x5)
>
> ## Histogram
> hist(y)
> hist(x1)
> hist(x5)
>
> ## CORRELATION AND REGRESSION
> ## check the linearity of the data
> plot(sukhoi)
>
> ## fitting multiple linear regression
> regression = lm(y ~ x1 + x5 , data = sukhoi)
> regression
Call:
lm(formula = y ~ x1 + x5, data = sukhoi)
Coefficients:
(Intercept)
x1
1085.9051
2.1525
x5
-0.6524
> summary(regression)
Call:
lm(formula = y ~ x1 + x5, data = sukhoi)
Residuals:
Min
1Q Median
3Q
Max
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1085.90511 302.33023 3.592 0.00095 ***
x1
x5
>
> ## Analysis of Variance (ANOVA)
> ## One - Way ANOVA
> ## ANOVA Table
>
> anova(regression)
Analysis of Variance Table
Response: y
Df Sum Sq Mean Sq F value Pr(>F)
x1
x5