Free Access Week-  Data Engineering + BI
Data engineering and BI courses are free!
Free AI Access Week from June 2-8

R2sample (version 4.0.1)

twosample_power: Find the power of various two sample tests using Rcpp and parallel computing.

Description

Find the power of various two sample tests using Rcpp and parallel computing.

Usage

twosample_power(
  f,
  ...,
  TS,
  TSextra,
  alpha = 0.05,
  B = 1000,
  nbins = c(50, 10),
  minexpcount = 5,
  UseLargeSample,
  samplingmethod = "independence",
  rnull,
  SuppressMessages = FALSE,
  maxProcessor
)

Value

A numeric vector of power values.

Arguments

f

function to generate a list with data sets x, y and (optional) vals, weights

...

additional arguments passed to f, up to 2

TS

routine to calculate test statistics for non-chi-square tests

TSextra

additional info passed to TS, if necessary

alpha

=0.05, the level of the hypothesis test

B

=1000, number of simulation runs.

nbins

=c(50,10), number of bins for chi large and chi small.

minexpcount

=5 minimum required count for chi square tests

UseLargeSample

should p values be found via large sample theory if n,m>10000?

samplingmethod

=independence or MCMC in discrete data case

rnull

a function that generates data from a model, possibly with parameter estimation.

SuppressMessages

= FALSE print informative messages?

maxProcessor

maximum number of cores to use. If maxProcessor=1 no parallel computing is used.

Examples

Run this code
 f=function(mu) list(x=rnorm(25), y=rnorm(25, mu))
 twosample_power(f, mu=c(0,2), B=100, maxProcessor = 1)
 f=function(n, p) list(x=table(sample(1:5, size=1000, replace=TRUE)), 
       y=table(sample(1:5, size=n, replace=TRUE, 
       prob=c(1, 1, 1, 1, p))), vals=1:5)
 twosample_power(f, n=c(1000, 2000), p=c(1, 1.5), B=100, maxProcessor = 1)

Run the code above in your browser using DataLab