Code
Non-smoker Smoker
Male 105 17
Female 101 9
Sex
and Smoke
from the Pulse
dataset
Non-smoker Smoker
Male 105 17
Female 101 9
Sex
and Smoke
: FrequenciesSex
and Smoke
: MarginsSex
and Smoke
: Marginal probSex
and Smoke
: Conditional probSmoke
)Sex
)prop.test()
function from stats package
2-sample test for equality of proportions with continuity correction
data: smoke_sex[, 2] out of smoke_sex_margins[c(1, 2), 3]
X-squared = 1.389, df = 1, p-value = 0.2386
alternative hypothesis: two.sided
95 percent confidence interval:
-0.03111589 0.14616805
sample estimates:
prop 1 prop 2
0.13934426 0.08181818
riskratio.wald()
function from epitools package$data
Non-smoker Smoker Total
Male 105 17 122
Female 101 9 110
Total 206 26 232
$measure
risk ratio with 95% C.I.
estimate lower upper
Male 1.0000000 NA NA
Female 0.5871658 0.2730208 1.262774
$p.value
two-sided
midp.exact fisher.exact chi.square
Male NA NA NA
Female 0.1729872 0.2118609 0.1654532
$correction
[1] FALSE
attr(,"method")
[1] "Unconditional MLE & normal approximation (Wald) CI"
oddsratio.wald()
function from epitools package$data
Non-smoker Smoker Total
Male 105 17 122
Female 101 9 110
Total 206 26 232
$measure
odds ratio with 95% C.I.
estimate lower upper
Male 1.0000000 NA NA
Female 0.5503786 0.2345618 1.291415
$p.value
two-sided
midp.exact fisher.exact chi.square
Male NA NA NA
Female 0.1729872 0.2118609 0.1654532
$correction
[1] FALSE
attr(,"method")
[1] "Unconditional MLE & normal approximation (Wald) CI"
\[odds~ratio = \frac{p_1/(1 - p_1)}{p_2/(1 - p_2)} = relative~risk \frac{(1 - p_1)}{(1 - p_2)} \]
\[\chi^2 = \Sigma_{i = 1} ^N \frac{(O_i - E_i)^2}{E_i}\]
\[\chi^2 = \Sigma_{i = 1} ^N \frac{(|O_i - E_i| - 0.5)^2}{E_i}\]
Pearson's Chi-squared test with Yates' continuity correction
data: smoke_sex
X-squared = 1.389, df = 1, p-value = 0.2386
Tea first | Milk first | Total | |
---|---|---|---|
Guess tea | 3 | 1 | 4 |
Guess milk | 1 | 3 | 4 |
Total | 4 | 4 | 8 |
fisher.test()
function in stats package
Fisher's Exact Test for Count Data
data: TeaTasting
p-value = 0.2429
alternative hypothesis: true odds ratio is greater than 1
95 percent confidence interval:
0.3135693 Inf
sample estimates:
odds ratio
6.408309
\[t = \frac{\bar{d} - 0}{\sigma_d/\sqrt{n}}\]
Paired t-test
data: paired$Active and paired$Rest
t = 23.204, df = 231, p-value < 0.00000000000000022
alternative hypothesis: true mean difference is not equal to 0
95 percent confidence interval:
20.99966 24.89689
sample estimates:
mean difference
22.94828
SIGN.test()
function in BSDA package
Dependent-samples Sign-Test
data: paired$Active and paired$Rest
S = 227, p-value < 0.00000000000000022
alternative hypothesis: true median difference is not equal to 0
95 percent confidence interval:
20 23
sample estimates:
median of x-y
21
Achieved and Interpolated Confidence Intervals:
Conf.Level L.E.pt U.E.pt
Lower Achieved CI 0.9433 20 23
Interpolated CI 0.9500 20 23
Upper Achieved CI 0.9584 20 23
wilcox.test()
function from stats package
Wilcoxon signed rank test with continuity correction
data: paired$Active and paired$Rest
V = 26931, p-value < 0.00000000000000022
alternative hypothesis: true location shift is not equal to 0
Design | ||||
---|---|---|---|---|
Post | ||||
Success | Failure | |||
Pre | Success | a | b | a+b |
Failure | c | d | c+d | |
a+c | b+d |
Post success Post failure Sum
Pre success 183 55 238
Pre failure 49 13 62
Sum 232 68 300
mcnemar.test()
function in stats package