Package 'smmr'

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

Help Index


Confidence interval for median by inverting sign test

Description

Confidence interval for median by inverting sign test

Usage

ci_median(d, x, conf.level = 0.95, tol = 0.01)

Arguments

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

Value

lower and upper limits

Author(s)

Ken Butler, [email protected]

Examples

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

Description

Confidence interval for median by inverting sign test

Usage

ci_median0(x, conf.level = 0.95, tol = 0.01)

Arguments

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

Value

lower and upper limits

Author(s)

Ken Butler, [email protected]

Examples

ci_median0(1:20)
ci_median0(1:5)

Mood's median test for comparison of group medians

Description

Mood's median test for comparison of group medians

Usage

median_test(d, x, g, tol = 1e-06)

Arguments

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

Value

list of 2 objects: table, counts of values above and below the grand median in each group; value, test statistic, df and P-value

Author(s)

Ken Butler, [email protected]

Examples

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

Description

Mood's median tests for one pair of groups

Usage

median_test_pair(d, x, g, g1, g2, tol = 1e-06)

Arguments

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

Value

(two-sided) P-value

Author(s)

Ken Butler, [email protected]

Examples

median_test_pair(datasets::mtcars,mpg,cyl,4,8)

Mood's median test for comparison of group medians

Description

Mood's median test for comparison of group medians

Usage

median_test0(x, g)

Arguments

x

vector of data

g

vector of group memberships (same length as x)

Value

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

Author(s)

Ken Butler, [email protected]

Examples

median_test0(datasets::mtcars$mpg,datasets::mtcars$cyl)

Pairwise Mood's median tests for all comparison of pairs of group medians

Description

Pairwise Mood's median tests for all comparison of pairs of group medians

Usage

pairwise_median_test(d, x, g, tol = 1e-06)

Arguments

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

Value

data frame of groups being compared and unadjusted and Bonferroni-adjusted P-values

Author(s)

Ken Butler, [email protected]

Examples

pairwise_median_test(datasets::mtcars,mpg,cyl)

Two-sided P-value for sign test

Description

Two-sided P-value for sign test

Usage

pval_sign(med0, d, x)

Arguments

med0

null median

d

data frame

x

vector of data for test

Value

P-value of two-sided sign test for median

Author(s)

Ken Butler, [email protected]

Examples

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

Description

Two-sided P-value for sign test

Usage

pval_sign0(med0, x)

Arguments

med0

null median

x

vector of data for test

Value

P-value of two-sided sign test for median

Author(s)

Ken Butler, [email protected]

Examples

pval_sign0(3.5,1:10)
pval_sign0(3,1:10)
pval_sign0(25, datasets::mtcars$mpg)

Sign test for given median

Description

Sign test for given median

Usage

sign_test(d, x, med0 = 0, tol = 1e-06)

Arguments

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)

Value

list of two elements: table of values above and below null median, data frame of 1-sided and 2-sided P-values

Author(s)

Ken Butler, [email protected]

Examples

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

Description

Sign test (simplified) for given median

Usage

sign_test0(x, med0 = 0, tol = 1e-06)

Arguments

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)

Value

list of two elements: table of values above and below null median, data frame of 1-sided and 2-sided P-values

Author(s)

Ken Butler, [email protected]

Examples

sign_test0(1:10,3.5)
sign_test0(1:10,3)
sign_test0(datasets::mtcars$mpg,25)