SampleSize_Proportions: Determining required sample size with two proportions of...

Description Usage Arguments Details Examples

View source: R/SampleSize_Proportions.R

Description

This function runs power calculations with two proportions of equal n, determining what sample size is necessary to see a statistically significant effect. Results are printed and can also be assigned.

Usage

1
2
3
SampleSize_Proportions(baserate = NULL, effectsize = NULL,
  alternative = c("two.sided", "less", "greater"), treatmentrate = 1,
  sig.level = 0.05, power = 0.8, h = NULL)

Arguments

baserate

The base rate for the population and probability in question. Required for all analyses.

effectsize

The difference in probability between the treatment group and the base rate. Can be a single integer x or a combination of integers c(x1, x2, etc). This is a "practical" effect size; see details.

alternative

The type of hypothesis. Can be "greater" (treatment probability > control probability), "less" (treatment probability < control probability), or "two.sided" (treatment probability != control probability).

treatmentrate

The proportion of those in the treatment group who are expected to complete treatment; see details.

sig.level

The significance level of the hypothetical test. Defaults to 0.05.

power

The power of the hypothetical test. Defaults to 0.8.

h

Refers to Cohen's h, the formal score for effect size in tests of probabilities. You may supply a Cohen's h score instead of a practical effect size if you prefer.

Details

The effect size input is a "practical" effect size in that it is the difference in observed probabilities, unlike Cohen's h. The calculations adjust for treatment rate, so consider the effect size the mean effect among those who successfully receive treatment.

The treatment rate is used to (crudely) calculate the sample size. Assuming that those who do not receive treatment will be identical to the control group, the required sample size will need to be inversely proportional to the treatment rate. That is, a completed treatment is worth an effect size of 1, but only 90 for the treatment group will only be .9. This means that the n will need to be higher than it would if the treatment rate was 1.

In the output, Cohen's h is calculated after taking treatment rate into effect. If the treatment rate given to the function is lower than 1, the h supplied will also be lower, even if all other numbers are constant.

Printed value is rounded; for an unrounded value, assign output to an object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
Please refer to vignette for detailed examples.

#Determining required per-group sample given effect size, etc
SampleSize_Proportions(baserate = .5, effectsize = -.2, alternative = "less", treatmentrate = .9)
 
#Determining required per-group sample size across multiple effect sizes
SampleSize_Proportions(baserate = .5, effectsize = c(-.1, -.2, -.3), alternative = "less", treatmentrate = .9)

#Assigning (unrounded) required sample size
n <- SampleSize_Proportions(baserate = .5, effectsize = c(-.1, -.2, -.3), alternative = "less", treatmentrate = .9)
n

isaacahuvia/QuickPower documentation built on May 6, 2019, 11:30 a.m.