Skip to content

Commit 4c13a4a

Browse files
committed
Increased test coverage
1 parent 75a0ec8 commit 4c13a4a

10 files changed

Lines changed: 1185 additions & 37 deletions

File tree

tests/testthat/_snaps/binomial.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,24 @@
4444
[2] " normal approx: 0.5 "
4545
[3] " normal approx with continuity: 0.5885 "
4646

47+
# iscambinomnorm handles two-sided alternatives
48+
49+
Code
50+
res_lower$output
51+
Output
52+
[1] " binomial: 0.1153 "
53+
[2] " normal approx: 0.07364 "
54+
[3] " normal approx with continuity: 0.1175 "
55+
56+
---
57+
58+
Code
59+
res_upper$output
60+
Output
61+
[1] " binomial: 0.1153 "
62+
[2] " normal approx: 0.07364 "
63+
[3] " normal approx with continuity: 0.1175 "
64+
4765
# iscambinompower reports rejection probabilities
4866

4967
Code
@@ -52,6 +70,22 @@
5270
[1] "Null: Probability 15 and above = 0.02069473 "
5371
[2] "Alternative: Probability 15 and above = 0.125599 "
5472

73+
# iscambinompower handles less and two-sided cases
74+
75+
Code
76+
res_less$output
77+
Output
78+
[1] "Null: Probability 5 and below = 0.0826247 "
79+
[2] "Alternative: Probability 5 and below = 0.3782785 "
80+
81+
---
82+
83+
Code
84+
res_two$output
85+
Output
86+
[1] "Null: Probability in rejection region 0.03027 "
87+
[2] "Alternative: Probability in rejection region 0.1648196 "
88+
5589
# iscambinomtest matches binom.test results
5690

5791
Code
@@ -67,3 +101,70 @@
67101
[8] "p-value: 0.36159 "
68102
[9] "95 % Confidence interval for pi: ( 0.40603 , 0.77344 ) "
69103

104+
# iscambinomtest handles one-sided alternatives
105+
106+
Code
107+
res_less$output
108+
Output
109+
[1] ""
110+
[2] "Exact Binomial Test"
111+
[3] ""
112+
[4] "Data: observed successes = 6, sample size = 15, sample proportion = 0.4"
113+
[5] ""
114+
[6] "Null hypothesis : pi = 0.4 "
115+
[7] "Alternative hypothesis: pi < 0.4 "
116+
[8] "p-value: 0.60981 "
117+
118+
---
119+
120+
Code
121+
res_greater$output
122+
Output
123+
[1] ""
124+
[2] "Exact Binomial Test"
125+
[3] ""
126+
[4] "Data: observed successes = 11, sample size = 18, sample proportion = 0.6111"
127+
[5] ""
128+
[6] "Null hypothesis : pi = 0.45 "
129+
[7] "Alternative hypothesis: pi > 0.45 "
130+
[8] "p-value: 0.12796 "
131+
132+
# iscambinomtest converts proportion inputs and multiple confidence levels
133+
134+
Code
135+
res$output
136+
Output
137+
[1] ""
138+
[2] "Exact Binomial Test"
139+
[3] ""
140+
[4] "Data: observed successes = 14, sample size = 100, sample proportion = 0.14"
141+
[5] ""
142+
[6] "90 % Confidence interval for pi: ( 0.086668 , 0.21017 ) "
143+
[7] "95 % Confidence interval for pi: ( 0.078705 , 0.22373 ) "
144+
145+
# iscambinomtest treats not.equal as two-sided
146+
147+
Code
148+
res$output
149+
Output
150+
[1] ""
151+
[2] "Exact Binomial Test"
152+
[3] ""
153+
[4] "Data: observed successes = 13, sample size = 24, sample proportion = 0.5417"
154+
[5] ""
155+
[6] "Null hypothesis : pi = 0.5 "
156+
[7] "Alternative hypothesis: pi 0.5 "
157+
[8] "p-value: 0.83882 "
158+
159+
# iscambinomtest returns single confidence intervals without hypothesis
160+
161+
Code
162+
res$output
163+
Output
164+
[1] ""
165+
[2] "Exact Binomial Test"
166+
[3] ""
167+
[4] "Data: observed successes = 18, sample size = 40, sample proportion = 0.45"
168+
[5] ""
169+
[6] "90 % Confidence interval for pi: ( 0.31461 , 0.59119 ) "
170+

tests/testthat/_snaps/chisq-hyper.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,26 @@
3737
[2] " normal approx: 0.1521 "
3838
[3] " normal approx with continuity: 0.3037 "
3939

40+
# iscamhypernorm converts fractional k inputs
41+
42+
Code
43+
res$output
44+
Output
45+
[1] " hypergeometric: 0.9973 "
46+
[2] " normal approx: 0.9901 "
47+
[3] " normal approx with continuity: 0.9967 "
48+
49+
# iscamhyperprob matches fractional inputs for both tails
50+
51+
Code
52+
res_lower$output
53+
Output
54+
[1] "Probability 6 and below = 0.9758352 "
55+
56+
---
57+
58+
Code
59+
res_upper$output
60+
Output
61+
[1] "Probability 6 and above = 0.1182716 "
62+

tests/testthat/_snaps/normal.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@
1212
Output
1313
[1] "probability: 0.6827 "
1414

15+
# iscamnormprob handles below and outside directions
16+
17+
Code
18+
res_below$output
19+
Output
20+
[1] "probability: 0.3085 "
21+
22+
---
23+
24+
Code
25+
res_outside$output
26+
Output
27+
[1] "probability: 0.3935 "
28+
1529
# iscamnormpower reports null and alternative rejection rates
1630

1731
Code
@@ -34,3 +48,33 @@
3448
Output
3549
[1] "There is 0.1 probability outside -1.645 and 1.645 "
3650

51+
# iscamnormpower handles less and two-sided alternatives
52+
53+
Code
54+
res_less$output
55+
Output
56+
[1] "Null: Probability 0.3677 and below = 0.1 "
57+
[2] "Alt: Probability 0.3677 and below = 0.3047272 "
58+
59+
---
60+
61+
Code
62+
res_two$output
63+
Output
64+
[1] "Null: Probability in rejection region 0.05 "
65+
[2] "Alt: Probability in rejection region 0.1549 "
66+
67+
# iscaminvnorm supports legacy Sd values
68+
69+
Code
70+
res_above$output
71+
Output
72+
[1] "The observation with 0.2 probability above is 3.262 "
73+
74+
---
75+
76+
Code
77+
res_between$output
78+
Output
79+
[1] "There is 0.9 probability between -0.3159 and 2.3159 "
80+

tests/testthat/_snaps/prop-tests.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,49 @@
1414
[9] "p-value: 0.002339 "
1515
[10] "95 % Confidence interval for pi: ( 0.5729798 , 0.8270202 ) "
1616

17+
# iscamonepropztest handles less alternatives with proportion input
18+
19+
Code
20+
res$output
21+
Output
22+
[1] ""
23+
[2] "One Proportion z test"
24+
[3] ""
25+
[4] "Data: observed successes = 16, sample size = 50, sample proportion = 0.32"
26+
[5] ""
27+
[6] "Null hypothesis : pi = 0.35 "
28+
[7] "Alternative hypothesis: pi < 0.35 "
29+
[8] "z-statistic: -0.4447 "
30+
[9] "p-value: 0.3283 "
31+
[10] "90 % Confidence interval for pi: ( 0.2114895 , 0.4285105 ) "
32+
33+
# iscamonepropztest covers two-sided comparisons when sample is below null
34+
35+
Code
36+
res$output
37+
Output
38+
[1] ""
39+
[2] "One Proportion z test"
40+
[3] ""
41+
[4] "Data: observed successes = 18, sample size = 60, sample proportion = 0.3"
42+
[5] ""
43+
[6] "Null hypothesis : pi = 0.4 "
44+
[7] "Alternative hypothesis: pi <> 0.4 "
45+
[8] "z-statistic: -1.581 "
46+
[9] "p-value: 0.1138 "
47+
48+
# iscamonepropztest reports intervals when hypothesis is omitted
49+
50+
Code
51+
res$output
52+
Output
53+
[1] ""
54+
[2] "One Proportion z test"
55+
[3] ""
56+
[4] "Data: observed successes = 28, sample size = 100, sample proportion = 0.28"
57+
[5] ""
58+
[6] "90 % Confidence interval for pi: ( 0.2061463 , 0.3538537 ) "
59+
1760
# iscamtwopropztest matches two-sample z test calculations
1861

1962
Code
@@ -32,3 +75,69 @@
3275
[11] "95 % Confidence interval for pi1-pi2: ( -0.1124861 , 0.2680417 ) "
3376
[12] "p-value: 0.2116 "
3477

78+
# iscamtwopropztest handles less alternative with proportion input
79+
80+
Code
81+
res$output
82+
Output
83+
[1] ""
84+
[2] "Two Proportion z test"
85+
[3] ""
86+
[4] "Group1: observed successes = 25, sample size = 60, sample proportion = 0.4167"
87+
[5] ""
88+
[6] "Group2: observed successes = 28, sample size = 55, sample proportion = 0.5091"
89+
[7] ""
90+
[8] "Null hypothesis : pi1-pi2 = 0 "
91+
[9] "Alternative hypothesis: pi1-pi2 < 0 "
92+
[10] "z-statistic: -0.9932 "
93+
[11] "90 % Confidence interval for pi1-pi2: ( -0.2449163 , 0.06006778 ) "
94+
[12] "p-value: 0.1603 "
95+
96+
# iscamtwopropztest covers two-sided alternatives below the null
97+
98+
Code
99+
res$output
100+
Output
101+
[1] ""
102+
[2] "Two Proportion z test"
103+
[3] ""
104+
[4] "Group1: observed successes = 20, sample size = 60, sample proportion = 0.3333"
105+
[5] ""
106+
[6] "Group2: observed successes = 28, sample size = 60, sample proportion = 0.4667"
107+
[7] ""
108+
[8] "Null hypothesis : pi1-pi2 = 0 "
109+
[9] "Alternative hypothesis: pi1-pi2 <> 0 "
110+
[10] "z-statistic: -1.491 "
111+
[11] "p-value: 0.136 "
112+
113+
# iscamtwopropztest accepts tabular input and confidence-only intervals
114+
115+
Code
116+
res_alt$output
117+
Output
118+
[1] ""
119+
[2] "Two Proportion z test"
120+
[3] ""
121+
[4] "Group1: observed successes = 30, sample size = 50, sample proportion = 0.6"
122+
[5] ""
123+
[6] "Group2: observed successes = 25, sample size = 50, sample proportion = 0.5"
124+
[7] ""
125+
[8] "Null hypothesis : pi1-pi2 = 0 "
126+
[9] "Alternative hypothesis: pi1-pi2 > 0 "
127+
[10] "z-statistic: 1.005 "
128+
[11] "p-value: 0.1574 "
129+
130+
---
131+
132+
Code
133+
res_conf$output
134+
Output
135+
[1] ""
136+
[2] "Two Proportion z test"
137+
[3] ""
138+
[4] "Group1: observed successes = 62, sample size = 100, sample proportion = 0.62"
139+
[5] ""
140+
[6] "Group2: observed successes = 50, sample size = 90, sample proportion = 0.5556"
141+
[7] ""
142+
[8] "90 % Confidence interval for pi1-pi2: ( -0.05301566 , 0.1819045 ) "
143+

0 commit comments

Comments
 (0)