8장 과제

8.2

데이터

x = c(36,40,34,44,33,36,40,33,26,36,31,44,41,29,42,35,45,31,32,38)
y = c(29,32,29,40,31,29,34,30,25,31,28,34,34,27,33,33,34,27,30,33)

산점도 상관계수 회귀직선

plot(x,y)

cor(x,y)
## [1] 0.8707
fit=lm(y~x)
fit
## 
## Call:
## lm(formula = y ~ x)
## 
## Coefficients:
## (Intercept)            x  
##      10.992        0.555
abline(fit)

plot of chunk unnamed-chunk-2

귀무가설 검정 신뢰구간

cor.test(x,y)
## 
##  Pearson's product-moment correlation
## 
## data:  x and y
## t = 7.512, df = 18, p-value = 5.938e-07
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.6966 0.9480
## sample estimates:
##    cor 
## 0.8707
# H0 reject
# 결론 : 'rho' = 0 이라고 말할 수 없다

8.4

# 3개조  (표에의해)
mu0 = 102.5
k=3 
n=5
v = 11.1
c =2.38
R1 = c(102.8,103.9,101.6,103.7,102.3)
R2 = c(103.4,102.0,104.3,102.4,102.8)
R3 = c(104.1,103.7,101.7,102.4,102.8)

barx = sum(R1+R2+R3)/15

barR1 = max(R1)-min(R1)
barR2 = max(R2)-min(R2)
barR3 = max(R3)-min(R3)

barR = (barR1+barR2+barR3)/3

t0 = (barx - mu0)/((barR/c)/sqrt(k*n))

t0.025 = qt(0.975,11.1)

t0; t0.025
## [1] 1.686
## [1] 2.199
# 결론 t0가 기각역에 속하지 않으므로 H0를 기각하지 못함
# 즉 모평균이 변화되었다고 말할 수 없다.

8.5

A1 = c(10.8,11.0,11.4,11.2)
A2 = c(11.4,10.9,11.3,11.3)
B1 = c(11.0,10.5,10.9,11.0)
B2 = c(10.7,11.0,11.2,10.5)

Ra1 = max(A1)-min(A1)
Ra2 = max(A2)-min(A2)
Rb1 = max(B1)-min(B1)
Rb2 = max(B2)-min(B2)

barR1 = (Ra1 + Ra2)/2
barR2 = (Rb1 + Rb2)/2

k=2
n=4
v=5.7
c=2.5

F0 = (barR1/c)^2/(barR2/c)^2

F0.975 = qf(0.975,5.7,5.7)

F0
## [1] 0.8403
F0.975
## [1] 6.148
#결론 : F0가 F0.975보다 작으므로 "H0:모분산이 같다" 를 기각 할 수 없다.

8.8

x = 1:11
y = c(3,4,1,2,6,5,9,7,8,11,10)

#유의수준 5%에서 양쪽 검정을 시행한다
cor.test(x, y,alternative = "two.sided",method = "spearman",conf.level = 0.95)
## 
##  Spearman's rank correlation rho
## 
## data:  x and y
## S = 26, p-value = 0.0006683
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
##    rho 
## 0.8818
#결론 : p-value : 0.0006 < 0.05 이므로 "H0 : rho =0 "를 기각하지 못한다
# 따라서 유의수준 5%에서 작업자들의 키와 몸무게 간에는 상관관계가 없다고 말 할 수 있다.

8.9

n =100
s = 66 # '+' 개수
E.s = n/2
V.s = n/4

u0 = (s-E.s)/sqrt(V.s)

#유의수준 5%에서 검정
u0.95 = qnorm(0.95)
u0
## [1] 3.2
u0.95
## [1] 1.645
# 결론 : u0 > u0.95 이므로 "H0 : A와 B사이에 차가 없다" 를 기각 할 수 있다.
# 따라서 A가 B보다 효능이 좋다고 할 수 있다.