chi_power: Power Estimation of Chi Square Tests

View source: R/chi_power.R

chi_powerR Documentation

Power Estimation of Chi Square Tests

Description

This function finds the power of various chi-square tests.

Usage

chi_power(
  pnull,
  ralt,
  param_alt,
  phat = function(x) -99,
  alpha = 0.05,
  Ranges = matrix(c(-Inf, Inf, -Inf, Inf), 2, 2),
  nbins = c(5, 5),
  rate = 0,
  minexpcount = 5,
  dnull = function(x) -99,
  Retry = TRUE,
  SuppressMessages = TRUE,
  B = 1000
)

Arguments

pnull

distribution function to find cdf under null hypothesis

ralt

function to generate data under alternative hypothesis

param_alt

vector of parameter values for distribution under alternative hypothesis

phat

=function(x) -99, function to estimate parameters

alpha

=0.05, the level of the hypothesis test

Ranges

=matrix(c(-Inf, Inf, -Inf, Inf),2,2), a 2x2 matrix with lower and upper bounds, if any

nbins

=c(5, 5), number of bins for chi square tests

rate

=0 rate of Poisson if sample size is random, 0 if sample size is fixed

minexpcount

=5 minimal expected bin count required

dnull

=function(x) -99, density function to find probabilities under null hypothesis, mostly used for discrete data, or -99 if missing.

Retry

=TRUE, retry if test fails?

SuppressMessages

=TRUE, should info be shown?

B

=1000 number of simulation runs to find power

Value

A numeric matrix of power values.


MDgof documentation built on Feb. 13, 2026, 1:06 a.m.