Description Usage Arguments Details Examples

View source: R/SampleSize_Proportions.R

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.

1 2 3 |

`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 |

`alternative` |
The type of hypothesis. Can be |

`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 |

`power` |
The power of the hypothetical test. Defaults to |

`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. |

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.

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
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.