# SampleSize_Means: Determining required sample size with two means of equal n In isaacahuvia/QuickPower: Quick and Easy Power Calculations

## Description

This function runs power calculations with two means 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_Means(populationmean = NULL, populationdev = NULL, effectsize = NULL, alternative = c("two.sided", "less", "greater"), treatmentrate = 1, sig.level = 0.05, power = 0.8, d = NULL) ```

## Arguments

 `populationmean` The population mean for the statistic in question. Required for all analyses. `populationdev` The population standard deviation for the statistic in question. Required for all analyses. `effectsize` The difference in means 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 mean > control mean), `"less"` (treatment mean < control mean), or `"two.sided"` (treatment mean != control mean). `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`. `d` Refers to Cohen's d, the formal score for effect size in tests of means. You may supply a Cohen's d 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 means in observed units, unlike Cohen's d. 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 d is calculated after taking treatment rate into effect. If the treatment rate given to the function is lower than 1, the d 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_Means(populationmean = 100, populationdev = 30, effectsize = -20, treatmentrate = .9) #Determining required per-group sample size across multiple effect sizes SampleSize_Means(populationmean = 100, populationdev = 30, effectsize = c(-20, -10, -5), treatmentrate = .9) #Assigning (unrounded) required sample size n <- SampleSize_Means(populationmean = 100, populationdev = 30, effectsize = c(-20, -10, -5), treatmentrate = .9) n ```

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