|
| |
Lab 2
Toluca Company Example (Section 1.6)
> data<-read.table("/afs/stat.lsa.umich.edu/users/student/kutsyy/.public_html/classes/stat413.data/CH01TA01.DAT")
> data
V1 V2
1 80 399
2 30 121
3 50 221
4 90 376
5 70 361
6 60 224
7 120 546
8 80 352
9 100 353
10 50 157
11 40 160
12 70 252
13 90 389
14 20 113
15 110 435
16 100 420
17 30 212
18 50 268
19 90 377
20 110 421
21 30 273
22 90 468
23 40 244
24 80 342
25 70 323
> fit<-lm(V1~V2,data=data)
> summary(fit)
Call: lm(formula = V1 ~ V2, data = data)
Residuals:
Min 1Q Median
3Q Max
-30.96 -9.811 2.346 5.337 20.63
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) -1.8583 7.4105 -0.2508
0.8042
V2 0.2301
0.0224 10.2896 0.0000
Residual standard error: 12.4 on 23 degrees of freedom
Multiple R-Squared: 0.8215
F-statistic: 105.9 on 1 and 23 degrees of freedom, the p-value is 4.449e-10
Correlation of Coefficients:
(Intercept)
V2 -0.9424
> plot(data$V2,data$V1,xlab="LOT SIZE",ylab="HOURS",main="See
Figure 1.10(b) in the book")
> abline(fit$coef)
> fit$coef
(Intercept) V2
-1.858251 0.2301084
Problem 1.20
a)
>data<-read.table("/afs/stat.lsa.umich.edu/users/student/kutsyy/.public_html/classes/stat413.data/CH01PR20.DAT")
>data
V1 V2
1 97 7
2 86 6
3 78 5
4 10 1
5 75 5
6 62 4
7 101 7
8 39 3
9 53 4
10 33 2
11 118 8
12 65 5
13 25 2
14 71 5
15 105 7
16 17 1
17 49 4
18 68 5
> motif()
> fit<-lm(V1~V2, data=data)
> summary(fit)
Call: lm(formula = V1 ~ V2, data = data)
Residuals:
Min 1Q Median
3Q Max
-7.631 -3.25 -0.2383 4.023 6.631
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) -2.3221 2.5644 -0.9055
0.3786
V2 14.7383
0.5193 28.3834 0.0000
Residual standard error: 4.482 on 16 degrees of freedom
Multiple R-Squared: 0.9805
F-statistic: 805.6 on 1 and 16 degrees of freedom, the p-value is 4.108e-15
Correlation of Coefficients:
(Intercept)
V2 -0.9112
b)
> plot(data$V2,data$V1)
> abline(fit$coef)
c)
b0 is intercept
d)
> x0<-c(1,5)
> x0%*%fit$coef
[,1]
[1,] 71.36913
> fit$coef[1]+fit$coef[2]*5
(Intercept)
71.36913
|