2025-01-27

Shiny App - Calculating Power for Gaussian Data

This Shiny Application calculates statistical power based on a normal distribution function using pnorm and shows this graphically in the form of a plot of two normal densities.

Power is the probability of rejecting a null hypothesis when it is false.

We consider a theoretical example where our sample mean is normally distributed and the standard deviation of the population is known.

The null hypothesis H0: mu = mu0 versus the alternative hypothesis Ha: mu > mu0 (one sided test)

The application allows varying the parameters for calculating power:

mu0: sample mean under null; mua: sample mean under alternative; sigma: standard deviation; n: sample size; alpha: type I error rate. ## Code

## Installing package into '/home/asmae/R/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)

Application output example

## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

Results

We consider an example where mu0 =30; mua =32; sigma = 4, n= 16 and alpha = 0.05. The power is equal to: 0.63876, therefore we have a 64% probability of detecting a mean of 32 or larger. This is the area under the blue curve to the right of the vertical line. The line is set so that the area under the red curve to the right of it is always equal to alpha.

Links