TD_power {singcar}R Documentation

Power calculator for TD

Description

Calculates exact power given sample size or sample size given power, using analytical methods for the frequentist test of deficit for a specified case score and mean and standard deviation for the control sample. The mean and standard deviation defaults to 0 and 1, so if no other values are given the case score is interpreted as deviation from the mean in standard deviations.

Usage

TD_power(
  case,
  mean = 0,
  sd = 1,
  sample_size = NULL,
  power = NULL,
  alternative = c("less", "greater", "two.sided"),
  alpha = 0.05,
  spec = 0.005
)

Arguments

case

A single value from the expected case observation.

mean

The expected mean of the control sample.

sd

The expected standard deviation of the control sample.

sample_size

The size of the control sample, vary this parameter to see how the sample size affects power. One of sample size or power must be specified, not both.

power

A single value between 0 and 1 specifying desired power for calculating necessary sample size. One of sample size or power must be specified, not both.

alternative

The alternative hypothesis. A string of either "less" (default), "greater" or "two.sided".

alpha

The specified Type I error rate. This can also be varied, with effects on power.

spec

A single value between 0 and 1. If desired power is given as input the function will utilise a search algorithm to find the sample size needed to reach the desired power. However, if the power specified is greater than what is actually possible to achieve the algorithm could search forever. Hence, when power does not increase substantially for any additional participant in the sample, the algorithm stops. By default the algorithm stops when power does not increase more than 0.5% for any added participant, but by varying spec, this specificity can be changed.

Value

Either a single value of the exact power, if sample size is given. Or a dataframe consisting of both the sample size and the exact power such size would yield.

Examples

TD_power(case = -2, mean = 0, sd = 1, sample_size = 20)
TD_power(case = -2, mean = 0, sd = 1, power = 0.8)

[Package singcar version 0.1.5 Index]