Solution to assignment 4, MAT 2375 - University of...
Click here to load reader
Transcript of Solution to assignment 4, MAT 2375 - University of...
MAT 2375, Assignment 4 1
Solution to assignment 4,MAT 2375
Total= 100 points
[7.6-13]
Solution. We have
n∑i=1
[Yi − α− β(xi − x)]2 =n∑i=1
[Yi − α + α− α + (β − β − β)(xi − x)]2
=n∑i=1
[Yi − α− β(xi − x)]2 + n(α− α)2 + (β − β)2n∑i=1
(xi − x)2.
It is important to notice that all the cross products are zero. For example, since∑ni=1(xi − x) = 0,
we get
(α− α)n∑i=1
(xi − x) = 0
Also
(α− α)n∑i=1
((Yi − α)− β(xi − x)) = nY − α− βn∑i=1
(xi − x) = 0.
[7.6-20]
Solution
x=c(32,23,23,23,26,30,17,20,17,18,26,16,21,24,30)
y=c(28,25,24,32,31,27,23,30,18,18,32,22,28,31,26)
> mean(x)
[1] 23.06667
> mean(y)
[1] 26.33333
a=lm(y~x)
summary(a)
Call:
lm(formula = y ~ x)
Residuals:
Min 1Q Median 3Q Max
-5.7688 -2.8489 -0.7564 3.6819 5.7004
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 14.6578 5.0382 2.909 0.0122 *
x 0.5062 0.2137 2.369 0.0340 *
MAT 2375, Assignment 4 2
---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Residual standard error: 4.037 on 13 degrees of freedom
Multiple R-squared: 0.3015,Adjusted R-squared: 0.2477
F-statistic: 5.611 on 1 and 13 DF, p-value: 0.03402
>hsigma=sum(model$resid**2)/(length(x)-2)
[1] 211.8864
We find confidence interval for β0 and β1 and σ2 in the model
Yi = β0 + β1xi + εi.
C.I. for β0 and β1 (this is similar for α and β) are
14.6578± (2.160369)(5.0382) = 14.6578± 10.88437
and0.5062± (2.160369)(0.2137) = 0.5062± 0.4616709.
For the modelYi = α + β(xi − x) + εi
the 95% c.i. for α is
α± t0.025(13)
√√√√ n∑i=1
e2i /(n(n− 2)).
Using R we get
>sigma=sqrt(sum(e**2)/((length(x)-2)*length(x)))
> mean(y)
[1] 26.33333
> mean(y)+qt(0.975,13)*sigma
[1] 28.5853
> mean(y)-qt(0.975,13)*sigma
[1] 24.08137
The 95% confidence interval for α is [24.08137, 28.5853]. The confidence interval for β1 and β arethe same.
Sincen∑i=1
e2i /σ2 ∼ χ2(13).
The confidence interval for σ2 is
(n∑i=1
e2i /χ20.975(13),
n∑i=1
e2i /χ20.025(13)).
We have∑ni=1 e
2i = 211.8658.
MAT 2375, Assignment 4 3
> qchisq(0.975,13)
[1] 24.7356
> qchisq(0.025,13)
[1] 5.008751
The confidence interval for σ2 is
(211.8658/24.7356, 211.8658/5.008751) = (8.565218, 42.29913).
[8.1-6].
Solution (a, b)H0 : µ = 3.4 H1 : µ > 3.4
(c)X ≥ 3.4 + tα(8)s/
√9⇒ RH0.
The test statistics is
T =X − 3.4
s/√n.
(d)X ≥ 3.4 + s/
√9⇒ RH0.
(e)
> qt(0.95,8)
[1] 1.859548
> x=c(3.4,3.6,3.8,3.3,3.4,3.5,3.7,3.6,3.7)
> length(x)
[1] 9
> mean(x)
[1] 3.555556
> sd(x)
[1] 0.1666667
We have3.4 + 1.859548s/
√9 = 3.4 + (1.859548)(0.1666667)/3 = 3.503308.
Since3.555556 > 3.503308
we reject H0.
Tobserved =X − 3.4
s/√n
=3.555556− 3.4
0.1666667/3= 2.800007.
Thereforep− value = P (t(8) > 2.800007).
MAT 2375, Assignment 4 4
> pt(2.800007,8)
[1] 0.9884012
> 1-0.9884012
[1] 0.0115988
p− value = 0.0115988
This confirms the we should reject H0 with α = 0.05.
[8.1-12].
Solution. We get
di = xi − yi : 13,−4, 3, 14,−1, 17, 11, 13, 17, 14, 7, 2,−7,−10, 0,−1,−7.
Calculate
d =1
n
17∑i=1
di = 4.764706
and
sd =
√√√√ 1
n− 1
n∑i=1
(di − d)2 = 9.086593.
Therefore
tobserved =d
sd/√n
=4.764706
9.086593/sqrt17= 2.162019.
Since t16(0.05) = 1.746, we reject H0.
We can also do this in R. Notice that a paired t-test is a one sample test on D = X − Y .
> x
[1] 265 272 246 260 274 263 255 258 276 274 274 269 244 212 235 254 224
> y
[1] 252 276 243 246 275 246 244 245 259 260 267 267 251 222 235 255 231
>d=x-y
> t.test(d,alternative="greater")
One Sample t-test
data: d
t = 2.162, df = 16, p-value = 0.02306
alternative hypothesis: true mean is greater than 0
95 percent confidence interval:
0.917088 Inf
sample estimates:
mean of x
4.764706
MAT 2375, Assignment 4 5
[8.1-14]
Solution. (a) We reject H0 if
(n− 1)S2
100< χ2
0.975(22) = 10.98.
Since(n− 1)S2
100= 7.8144
Therefore, we reject H0.
(b) If(n− 1)S2
100< 10.98 = χ2
0.975(22) or(n− 1)S2
100> χ2
0.025(22) = 36.78
then we reject H0. Based on the data provided, we should reject H0.
Here are commands and output in R for comparison. (a) From R we get
> (22)*(35.52)/100
[1] 7.8144
> qchisq(0.025,22)
[1] 10.98232
We should reject H0.
(b) This is a two-sided test
> qchisq(0.025,22)
[1] 10.98232
> qchisq(0.975,22)
[1] 36.78071
Since10.98232 > 7.8144
we reject H0.
[8.2-10]
Solution. We can use From the text seems the assumption of equality of variances can be assumeddue to similarity of conditions. Therefore
tobserved =x− y
sp√
1/n+ 1/m= −1.24621.
For simplicity we did our calculations in R as follows:
MAT 2375, Assignment 4 6
> x=c(4.67,4.21,2.18,3.91,4.09,5.24,2.94,4.71,4.04,5.79,3.8,4.38)
> y=c(5.04,4.52,6.18,7.01,4.36,1.81,6.22,5.7)
> mean(x)
[1] 4.163333
> mean(y)
[1] 5.105
> var(x)
[1] 0.9142606
> var(y)
[1] 2.591486
> length(x)
[1] 12
> length(y)
[1] 8
> sp=(11*0.9142606+7*2.591486)/(12+8-2)
> T=(mean(x)-mean(y))/(sp*sqrt(1/12+1/8))
> T
[1] -1.316992
H0 = µ1 = µ2 H1 : µ1 < µ2.
p− value = P (t(18) < −1.316992) = 0.1021812.
With α = 0.05 or 0.1 we accept H0.