np_stat_test: Non-parametric test for any statistic

Description Usage Arguments Details Value Author(s) Examples

View source: R/np_stat_test.R

Description

Performs a non parametric test for any statistics by bootstraping. Combines all values and samples vectors of length a_data, b_data. Then calculates differences in statistics to get distribution of differences in statatistics. Then compares observed difference with that distribution.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
np_stat_test(
  a_data,
  b_data,
  stat_fun = mean,
  n_sim = 1000,
  alternative = "two.sided",
  alpha = 0.05,
  plot = TRUE,
  ...
)

Arguments

a_data

Numeric vector of values from group a.

b_data

Numeric vector of values from group b.

stat_fun

Function that calculates desired statistic.

n_sim

Number of times to sample groups and calculate difference.

alternative

Setting up alternative hypothesis: "two.sided" meaning stat(A) != stat(B), "less" meaning stat(A) < stat(B), "greater" meaning stat(A) > stat(B)

alpha

statistical significance

plot

(logical) Plot the distribution of differences in mean if TRUE.

...

Any additional parameters that stat_fun needs.

Details

H0: No difference in statistics

Value

returns a named list containing:

diff

all the statistics differences

observed

observed statistics difference

n_sim

number of simulations ran

p_value

two sided p-value for the test

Author(s)

Elio Bartoš

Examples

1
2
3
4
5
6
7
8
x = rnorm(300, mean = 5, sd = 1)
y = rnorm(200, mean = 4, sd = 1.5)
y2 = c(y, 110)

np_stat_test(x, y, mean)
np_stat_test(x, y2, mean)
np_stat_test(x, y, mean, trim = 0.1)
np_stat_test(x, y, median)

eliobartos/misc documentation built on Oct. 8, 2021, 1:10 a.m.