Description Usage Arguments Details Value Examples

Power is the probability we reject the null hypothesis given it is false. Building on this definition, create a function that uses simulations to estimate power for a two-sample T-test.

1 2 3 |

`Var1mean` |
Variable 1 mean |

`Var2mean` |
Variable 2 mean |

`Var1sd` |
Variable 1 standard deviation |

`Var2sd` |
Variable 2 standard deviation |

`Var1samplesize` |
Variable 1 sample size |

`Var2samplesize` |
Variable 2 sample size |

`nsim` |
Number of simulations |

`alphalevel` |
alpha-level (default=0.05) |

First, you will need to simulate two normally distributed variables, each with a distinct sample size, mean, and standard deviation, and perform a T-test. For that single simulation, evaluate if we would reject the null hypothesis given a specific alpha-level. Now repeat this simulation many times. Power can then be estimated as the proportion of simulations for which we rejected the null hypothesis.

Empirical power calculation

1 2 | ```
SimTtestPower(Var1mean=20,Var2mean=22,Var1sd=4,Var2sd=6,
Var1samplesize=40,Var2samplesize=40,nsim=10000,alphalevel=0.05)
``` |

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.