setSliderColor has been deprecated and will be removed in a future release of shinyWidgets. If you absolutely need to use this function, copy the source code into your project https://github.com/dreamRs/shinyWidgets/blob/26838f9e9ccdc90a47178b45318d110f5812d6e1/R/setSliderColor.R
## Sample Size Calculator

### Inputs

### Inputs

### Inputs

### Inputs

### Inputs

### Results

### Results

### Results

### Results

### Results

### References

This sample size calculator is for when you want to know if a group of animals with population size (N) has a disease.

**Example: **
You want to know how many fish from a
tank of fish should be tested to detect presence or absence
of disease.

**Note: **
This calculation assumes a perfect
diagnostic test and is based on one or more diseased animals
indicating the presence of disease.

Please choose the confidence interval, population size and the disease prevalence you require for the calculation.

This sample size calculator is for when you want to test for a certain proportion of animals with or without a condition (e.g. a disease, a pathogen, or a genetic condition).

**Example: **
You read in literature that disease X
usually affects 10% of the animals. How many animals do you
have to sample to find out if you have a similar proportion
of diseased animals to a certain level of precision?

**Note: **
This calculation assumes a perfect
diagnostic test and the value of
**L**
may
change depending on the expected proportion.

Please choose the confidence interval, the disease prevalence and the precision you require for the calculation.

This sample size calculator is for when you want to know an average continuous trait (e.g. length, growth, or weight) in your population.

**Example: **
How many animals do you have to sample
to know the average weight of individuals to a certain level
of precision?

Please choose the confidence interval, population variance and the precision you require for the calculation.

This sample size calculator is for when you want to compare the proportion of animals with or without a condition (e.g. a disease, a pathogen, or genetic condition) between 2 populations.

**Example: **
You have coughing animals that you split
in 2 groups, one group is treated with vitamin C and one is not.
You consider the treatment effective if a certain percentage
of the animals stop coughing. How many animals do you have to
sample in each group?

**Note: **
This calculation assumes a perfect
diagnostic test.

Please choose the confidence level, the proportions that you want to compare and the power you require.

This sample size calculator is for when you want to compare an average continuous trait (e.g. length, growth, or weight) between 2 populations.

**Example: **
How many animals do you have to sample
to find out if there is a difference in average length between
animals that are raised in 2 different geographical areas?

Please choose the confidence interval, the means for the populations you want to compare, the population standard deviation and the power you require for your calculation.

If the prevalence used in the above calculation is an estimate then plot below will give you an idea of possible sample size required. If you hover over the individual points you will see the sample size.

This sample size calculator is designed to calculate the minimum sample size required to detect a disease within a population. The formula used is:

$$n = \left(1 - \left(1 - p\right) ^ {\frac{1}{NP}}\right) \times \left(N - \frac{NP - 1}{2}\right)$$

and then \(\lceil n \rceil\) (the next largest integer) is returned. In the calculation

- \(p\) is the confidence level
- \(N\) is population size
- \(P\) is the prevalence

Minimum sample size:

If the proportion used in the above calculation is an estimate then plot below will give you an idea of possible sample size required. If you hover over the individual points you will see the sample size.

**Warning: The value of L has been changed automatically.**

The formula used for this sample size calculation is:

$$n = \frac{Z_\alpha^2 p (1 - p)}{L^2}$$

and then \(\lceil n \rceil\) (the next largest integer) is returned. In the calculation

- \(Z_\alpha\) is the two-tailed \(Z\)-value from the confidence level.
- \(p\) is the expected proportion of animals that will test positive.
- \(L\) is the precision on the expected proportion. If the expected proportion is \(p = 50\)% (or 0.5) and \(L = 5\)% then we are estimating a sample size to be \(95\)% sure that our result is between \(45\)% and \(55\)%.

Minimum sample size:

The formula used for this sample size calculation is:

$$n = \frac{Z_\alpha^2 \sigma^2}{L^2}$$

and then \(\lceil n \rceil\) (the next largest integer) is returned. In the calculation

- \(Z_\alpha\) is the two-tailed Z-value from the confidence level.
- \(\sigma\) is the population variance.
- \(L\) is the precision on the estimated population mean. If the mean is \(100\) with a confidence interval of \(95\)% and \(L = 5\) then we are estimating a sample size to be \(95\)% sure that our result is between \(95\) and \(105\).

Minimum sample size (per group):

If either proportion used in the above calculation is an estimate then the plots below will give you an idea of possible sample size required. If you hover over the individual points you will see the sample size.

The formula used for this sample size calculation is:

$$n = \frac{\left(Z_\alpha\sqrt{2p(1 - p)} - Z_\beta\sqrt{p_1(1 - p_1) + p_2(1 - p_2)}\right)^2}{\left(p_1 - p_2\right)^2}$$

and then \(\lceil n \rceil\) (the next largest integer) is returned. In the calculation

- \(Z_\alpha\) is the two-tailed \(Z\)-value from the confidence level.
- \(Z_\beta\) is the one-tailed \(Z\)-value from the power.
- \(p_1\) is the proportion from group 1.
- \(p_2\) is the proportion from group 2. Note that it is assumed that \(p_2 < p_1\) and the calculator will force value changes to control this.
- \(p = \frac{p_1 + p_2}{2}\) the mean proportion.

The formula used for this sample size calculation is:

$$n = 2\frac{\left(Z_\alpha - Z_\beta\right)^2\sigma^2}{\left(\mu_1 - \mu_2\right)^2}$$

and then \(\lceil n \rceil\) (the next largest integer) is returned. In the calculation

- \(Z_\alpha\) is the two-tailed \(Z\)-value from the confidence level.
- \(Z_\beta\) is the one-tailed \(Z\)-value from the power.
- \(\mu_1\) is the mean from group 1.
- \(\mu_2\) is the mean from group 2. Note the test assumes that the means are different.
- \(\sigma\) is the population standard deviation (the test assumes that both groups have the same variance).

Noordhuizen, J.P.T.M., Frankena, K., Thrusfield, M.V., Graat, E.A.M. 2001. Application of quantitative methods in veterinary epidemiology. Wageningen Pers, Wageningen, The Netherlands. 429 pp.

Dohoo, I., Martin, W., Stryhn, H., 2009. Veterinary Epidemiologic Research 2nd edition. VER Inc., Charlottetown, Canada. 865 pp.