Title: | Sign test and Mood's median test |
---|---|
Description: | Provides alternatives to t-test and two-sample t / ANOVA when normality is questionable. |
Authors: | Ken Butler |
Maintainer: | Ken Butler <[email protected]> |
License: | GPL-2 |
Version: | 1.0.1 |
Built: | 2025-02-19 03:13:27 UTC |
Source: | https://github.com/nxskok/smmr |
Confidence interval for median by inverting sign test
ci_median(d, x, conf.level = 0.95, tol = 0.01)
ci_median(d, x, conf.level = 0.95, tol = 0.01)
d |
a data frame |
x |
unquoted name of column of data |
conf.level |
level for CI (as decimal), default 95 percent |
tol |
ends of CI determined to within this accuracy, default 0.01 |
lower and upper limits
Ken Butler, [email protected]
d=data.frame(z=1:20) d1=data.frame(z=1:5) ci_median(d,z) ci_median(d1,z) ci_median(datasets::mtcars, mpg)
d=data.frame(z=1:20) d1=data.frame(z=1:5) ci_median(d,z) ci_median(d1,z) ci_median(datasets::mtcars, mpg)
Confidence interval for median by inverting sign test
ci_median0(x, conf.level = 0.95, tol = 0.01)
ci_median0(x, conf.level = 0.95, tol = 0.01)
x |
vector of data |
conf.level |
level for CI (as decimal), default 95 percent |
tol |
ends of CI determined to within this accuracy, default 0.01 |
lower and upper limits
Ken Butler, [email protected]
ci_median0(1:20) ci_median0(1:5)
ci_median0(1:20) ci_median0(1:5)
Mood's median test for comparison of group medians
median_test(d, x, g, tol = 1e-06)
median_test(d, x, g, tol = 1e-06)
d |
a data frame |
x |
unquoted name of quantitative variable |
g |
unquoted name of grouping variable |
tol |
(default 1e-6) any data values closer to overall median than this are discarded |
list of 2 objects: table, counts of values above and below the grand median in each group; value, test statistic, df and P-value
Ken Butler, [email protected]
median_test(datasets::mtcars,mpg,cyl) d=data.frame(z=1:9,gg=c(1,1,1,1,1,2,2,2,2)) median_test(d,z,gg)
median_test(datasets::mtcars,mpg,cyl) d=data.frame(z=1:9,gg=c(1,1,1,1,1,2,2,2,2)) median_test(d,z,gg)
Mood's median tests for one pair of groups
median_test_pair(d, x, g, g1, g2, tol = 1e-06)
median_test_pair(d, x, g, g1, g2, tol = 1e-06)
d |
a data frame |
x |
unquoted name of quantitative variable |
g |
unquoted name of grouping variable (as character, not a factor) |
g1 |
first group to compare (as text) |
g2 |
second group to compare (as text) |
tol |
(default 1e-6) any data values closer to overall median than this are discarded |
(two-sided) P-value
Ken Butler, [email protected]
median_test_pair(datasets::mtcars,mpg,cyl,4,8)
median_test_pair(datasets::mtcars,mpg,cyl,4,8)
Mood's median test for comparison of group medians
median_test0(x, g)
median_test0(x, g)
x |
vector of data |
g |
vector of group memberships (same length as x) |
list of 3 objects: grand median of all obs, table, counts of values above and below the grand median in each group; value, test statistic, df and P-value
Ken Butler, [email protected]
median_test0(datasets::mtcars$mpg,datasets::mtcars$cyl)
median_test0(datasets::mtcars$mpg,datasets::mtcars$cyl)
Pairwise Mood's median tests for all comparison of pairs of group medians
pairwise_median_test(d, x, g, tol = 1e-06)
pairwise_median_test(d, x, g, tol = 1e-06)
d |
a data frame |
x |
unquoted name of quantitative variable |
g |
unquoted name of grouping variable (can be a factor, is treated as text) |
tol |
(default 1e-6) any data values closer to overall median than this are discarded |
data frame of groups being compared and unadjusted and Bonferroni-adjusted P-values
Ken Butler, [email protected]
pairwise_median_test(datasets::mtcars,mpg,cyl)
pairwise_median_test(datasets::mtcars,mpg,cyl)
Two-sided P-value for sign test
pval_sign(med0, d, x)
pval_sign(med0, d, x)
med0 |
null median |
d |
data frame |
x |
vector of data for test |
P-value of two-sided sign test for median
Ken Butler, [email protected]
d=data.frame(z=1:10) pval_sign(3.5,d,z) pval_sign(3,d,z) pval_sign(25, datasets::mtcars, mpg)
d=data.frame(z=1:10) pval_sign(3.5,d,z) pval_sign(3,d,z) pval_sign(25, datasets::mtcars, mpg)
Two-sided P-value for sign test
pval_sign0(med0, x)
pval_sign0(med0, x)
med0 |
null median |
x |
vector of data for test |
P-value of two-sided sign test for median
Ken Butler, [email protected]
pval_sign0(3.5,1:10) pval_sign0(3,1:10) pval_sign0(25, datasets::mtcars$mpg)
pval_sign0(3.5,1:10) pval_sign0(3,1:10) pval_sign0(25, datasets::mtcars$mpg)
Sign test for given median
sign_test(d, x, med0 = 0, tol = 1e-06)
sign_test(d, x, med0 = 0, tol = 1e-06)
d |
a data frame |
x |
unquoted name of column to test |
med0 |
null median (defaults to zero) |
tol |
(default 1e-6) how close a data value has to be to the null median to be considered equal to null median (and discarded) |
list of two elements: table of values above and below null median, data frame of 1-sided and 2-sided P-values
Ken Butler, [email protected]
d=data.frame(z=1:10) sign_test(d,z,3.5) sign_test(d,z,3) sign_test(datasets::mtcars, mpg, 25)
d=data.frame(z=1:10) sign_test(d,z,3.5) sign_test(d,z,3) sign_test(datasets::mtcars, mpg, 25)
Sign test (simplified) for given median
sign_test0(x, med0 = 0, tol = 1e-06)
sign_test0(x, med0 = 0, tol = 1e-06)
x |
vector of data |
med0 |
null median (defaults to zero) |
tol |
(default 1e-6) how close a data value has to be to the null median to be considered equal to null median (and discarded) |
list of two elements: table of values above and below null median, data frame of 1-sided and 2-sided P-values
Ken Butler, [email protected]
sign_test0(1:10,3.5) sign_test0(1:10,3) sign_test0(datasets::mtcars$mpg,25)
sign_test0(1:10,3.5) sign_test0(1:10,3) sign_test0(datasets::mtcars$mpg,25)