Email : ali.19arifin@gmail.com
RPubs : https://rpubs.com/aliciaarifin/
Jurusan :
Statistika
Address : ARA Center, Matana University Tower
Jl. CBD Barat Kav, RT.1, Curug Sangereng, Kelapa Dua,
Tangerang, Banten 15810.
Right Tail: A food company argue that for each a cookie bag of their products, there is at most 2 grams of saturated fat in a single cookie. In a sample of 40 cookies, it is found that the mean amount of saturated fat per cookie is 2.1 grams. Assume that the population standard deviation is 0.25 grams. At .05 significance level, can we reject the claim?
m0 = 2
xbar= 2.1
sigma = 0.25
n = 40
z = (xbar-m0) / (sigma/sqrt(n));z## [1] 2.529822
alpha = 0.05
z.alpha = qnorm(1-alpha, lower.tail = TRUE);z.alpha ## [1] 1.644854
pnorm(z) #dilihat dari p-value, H0 diterima jika p>0.05 ## [1] 0.994294
H0 = \(Z_{hitung} \ge Z_{\alpha}\) ,
saturated fat lebih dari sama dengan 2 gram per satu bungkus kukis.
H1 = \(Z_{hitung} < Z \alpha\) ,
saturated fat kurang dari 2 gram per satu bungkus kukis.
H0
diterima
Karena \(Z_{hitung}\)
lebih besar dari \(Z_{alpha}\), maka H0
diterima, dan klaim bisa diterima dalam satu bungkus kukis terdapat 2
gram saturated fat.
To test the hypothesis that the mean systolic blood pressure in a certain population equals 140 mmHg. The standard deviation has a known value of 20 and a data set of 55 patients is available.
#Blood_pressure dataset
no <- seq(1:55)
status <- c(rep(0, 25), rep(1, 30))
mmhg <- c(120,115,94,118,111,102,102,131,104,107,115,139,115,113,114,105,
115,134,109,109,93,118,109,106,125,150,142,119,127,141,149,144,
142,149,161,143,140,148,149,141,146,159,152,135,134,161,130,125,
141,148,153,145,137,147,169)
blood_pressure <-data.frame(no,status,mmhg)
blood_pressure## no status mmhg
## 1 1 0 120
## 2 2 0 115
## 3 3 0 94
## 4 4 0 118
## 5 5 0 111
## 6 6 0 102
## 7 7 0 102
## 8 8 0 131
## 9 9 0 104
## 10 10 0 107
## 11 11 0 115
## 12 12 0 139
## 13 13 0 115
## 14 14 0 113
## 15 15 0 114
## 16 16 0 105
## 17 17 0 115
## 18 18 0 134
## 19 19 0 109
## 20 20 0 109
## 21 21 0 93
## 22 22 0 118
## 23 23 0 109
## 24 24 0 106
## 25 25 0 125
## 26 26 1 150
## 27 27 1 142
## 28 28 1 119
## 29 29 1 127
## 30 30 1 141
## 31 31 1 149
## 32 32 1 144
## 33 33 1 142
## 34 34 1 149
## 35 35 1 161
## 36 36 1 143
## 37 37 1 140
## 38 38 1 148
## 39 39 1 149
## 40 40 1 141
## 41 41 1 146
## 42 42 1 159
## 43 43 1 152
## 44 44 1 135
## 45 45 1 134
## 46 46 1 161
## 47 47 1 130
## 48 48 1 125
## 49 49 1 141
## 50 50 1 148
## 51 51 1 153
## 52 52 1 145
## 53 53 1 137
## 54 54 1 147
## 55 55 1 169
sigma = 20
n = 55
m0 = 140
xbar = mean(mmhg)
alpha = 0.05
z = (xbar-m0)/(sigma/sqrt(n)) ;z## [1] -3.708099
z.two.tailed = qnorm(1-alpha/2)
c(-z.two.tailed, z.two.tailed)## [1] -1.959964 1.959964
H0 = $-Z_{} Z_{hitung} Z_{} $, tekanan darah populasi 140 mmhg.
H1 = $Z_{hitung} < -Z_{} atau Z_{hitung} > Z_{} $, tekanan darah
populasi bukan 140 mmhg.
H0 ditolak, \(Z_{hitung} < Z_\frac{\alpha}{2}\).
tekanan darah dari suatu populasi bukan 140mmhg.
Right tail: Garuda-food Indonesia claims that for each a cookie bag states of their product, there is at most 2 grams of saturated fat in a single cookie. In a sample of 40 cookies, it is found that the mean amount of saturated fat per cookie is 2.1 grams. Assume that the sample standard deviation is 0.3 gram. At .05 significance level, can we reject the claim?
m0 = 2
n = 40
xbar = 2.1
s = 0.3
alpha = 0.05
t.one = (xbar-m0)/(s/sqrt(n)); t.one## [1] 2.108185
t.alpha = qt(1-alpha, df= n-1) ; t.alpha## [1] 1.684875
pt(t.one, df=n-1)## [1] 0.979254
H0 = \(t_{hitung} \ge t_{\alpha}\) ,
saturated fat lebih dari sama dengan 2 gram per satu bungkus kukis.
H1 = \(t_{hitung} < t_{\alpha}\) ,
saturated fat kurang dari 2 gram per satu bungkus kukis.
H0
diterima, \(t_{hitung} >
t_{alpha}\)
Klaim bisa diterima dalam satu bungkus kukis
terdapat 2 gram saturated fat.
To test the hypothesis that the mean systolic blood pressure in a certain population equals 140 mmHg. The dataset at hands has measurements on 55 patients.
#Blood_pressure dataset
no <- seq(1:55)
status <- c(rep(0, 25), rep(1, 30))
mmhg <- c(120,115,94,118,111,102,102,131,104,107,115,139,115,113,114,105,
115,134,109,109,93,118,109,106,125,150,142,119,127,141,149,144,
142,149,161,143,140,148,149,141,146,159,152,135,134,161,130,125,
141,148,153,145,137,147,169)
blood_pressure <-data.frame(no,status,mmhg)
m0 = 140
xbar = mean(mmhg)
s = sd(mmhg)
n = 55
t.two.tailed = (xbar-m0)/(s-sqrt(n)) ; t.two.tailed## [1] -0.8510124
ta.two.tailed = qt(1-0.05, df = n-1) ; c(-ta.two.tailed, ta.two.tailed)## [1] -1.673565 1.673565
H0 = $-t_{} t_{hitung} t_{} $
H1 = \(t_{hitung}< -t_{\frac{\alpha}{2}}\) atau
$ t_{hitung} > t_{}$
H0 = rata-rata sistolik suatu populasi 140 mmhg
H1 = rata-rata
sistolik suatu populasi bukan 140 mmhg
H0 diterima, $-t_{} t_{hitung} t_{} $
asumsi rata-rata sistolik
suatu populasi 140 mmhg diterima.
Right tail: Garuda-food Indonesia claims that for each a cookie bag states of their product, there is at most 2 grams of saturated fat in a single cookie. Assume the actual mean amount of saturated fat per cookie is 2.075 grams and the sample standard deviation is 0.25 grams. At .05 significance level, what is the probability of having a type II error for a sample size of 35 cookies?
m0 = 2
xbar = 2.075
s = 0.25
alpha = 0.05
n = 35
# standard error of the mean
sem = s/sqrt(n);sem ## [1] 0.04225771
q = qnorm(alpha, mean=m0, sd = sem);q## [1] 1.930492
#probability of Error
pnorm(q, mean=m0, sd=sem, lower.tail = FALSE)## [1] 0.95
H0 diterima jika mean lebih dari 1.93, H0 diterima.
Jika sample
kukisnya 35 dengan rata-rata saturated fat 0.075 gram per bungkus dan
standar deviasi sample 0.25 gram. Probability atau peluang error type II
untuk mengetes hipotesis 0 \(\mu \ge
2.075\) dengan 0.05 level signifikansi error sebesar 4.22% dan
kekuatan tes hipotesis sebesar 95.78%.
Under same assumptions as case 27, if actual mean population weight is 14.9 kg, what is the probability of type II errors? What is the power of the hypothesis test?
m0 = 15.1
xbar = 14.9
sigma = 2.5
alpha = 0.05
n = 35
sem = (sigma/sqrt(n)); sem # standard error## [1] 0.4225771
I = c(alpha/2, 1-alpha/2)
q=qnorm(I, mean = m0, sd=sem);q # H0 diterima diantara 14.27 dan 15.93## [1] 14.27176 15.92824
p=pnorm(q, mean=xbar, sd=sem);p## [1] 0.06854999 0.99251803
diff(p)## [1] 0.923968
Probabilitas dari error type II diantara titik poin ujung, jika sample anjing hachiko 35, mean populasi dari berat adalah 14.9 kg, dan standar deviasi populasi sebesar 2.5 kg. Probabilitas atau peluang error type II untuk mengetes Hipotesis 0 \(\mu = 14.9\) di level siknifikansi 0.05 adalah 92.40% dan kekuatan tes hipotesisnya adalah 7.6%
type 1 error :
qnorm() # Z test
qt() # t-test
type 2 error:
1. standard error of mean
sem = sigma/sqrt(n)
2. sample mean
a. one way
q =qnorm(alpha, mean = m0, sd=sem);q
* if sample mean > or < than q,
the null hypothesis will not be rejected.
b. two way
I = c(alpha/2, 1-alpha/2)
q=qnorm(I, mean = m0, sd=sem);q
* to find sample mean between a and b,
if sample between a and b, hypothesis null will not be rejected.
3. probability of error
p=pnorm(q, mean=xbar, sd=sem);p
* If two way, find the difference or diff(p)
* Probability of type II error for testing the null hypothesis μ=...
at alpha significance level.