SimTtestPower: Two-Sample Power Calculation Based on Simulation

Description Usage Arguments Details Value Examples

Description

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.

Usage

1
2
3
SimTtestPower(Var1mean = NULL, Var2mean = NULL, Var1sd = NULL,
  Var2sd = NULL, Var1samplesize = NULL, Var2samplesize = NULL,
  nsim = 100, alphalevel = 0.05)

Arguments

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)

Details

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.

Value

Empirical power calculation

Examples

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

epicentered/ClassExample documentation built on May 25, 2019, 5:21 p.m.