Learn R Programming

extraSuperpower (version 1.5.0)

test_power_overkn: Test simulated two-way factorial design experiments over different sample sizes.

Description

Wrapper to test data simulated under independent or repeated measurements and under different outcome distributions with different sample sizes. Takes output from simulate_twoway_nrange as input, along with test and plotting options.

Usage

test_power_overkn(
  data,
  test = "ANOVA",
  plot = TRUE,
  target_power = NULL,
  title = NULL,
  target_line = TRUE,
  alpha_line = TRUE,
  alpha = 0.05
)

Value

Data frame with power and confidence intervals for the main effects and interaction for each of the sample sizes. Also presented in graphical form if plot=TRUE.

Arguments

data

data.frame - data.frame with modeled outcome values, factor level labels, iteration number and sample size.

test

character - Statistical test to be applied, possible values are 'ANOVA', 'rank' and 'permutation'.

plot

logical - Should the power curve be plotted. Default is TRUE.

target_power

Desired power to be attained. Accepts values between 0 and 1, defaults to 0.8.

title

Title for the graph. Defaults to 'Power curve from exact ANOVA test'

target_line

Set to TRUE. If FALSE no target line will be drawn. Overrides target_power.

alpha_line
  • logical Should a line at the set type I error be plotted

alpha
  • numeric Type I error probability

Examples

Run this code


## In this example we simulate an independent sample design with skewed outcome
## Model was specified with the 'calculate_mean_matrix function' (see ?calculate_mean_matrix)
refmean <- 1
treatgroups <- 4
timepoints <- 5
treateff <- 1.25
timeeff <- 0.85
factors_levels_names <- list(treatment=letters[1:treatgroups], time=1:timepoints)

indep_matrix <- calculate_mean_matrix(refmean = refmean,
                                      fAeffect = treateff, fBeffect = timeeff,
                                      nlfA = treatgroups, nlfB = timepoints,
                                      label_list = factors_levels_names)

indep_skewsim <- simulate_twoway_nrange(indep_matrix, seq(6, 12, 2),
                            distribution = "skewed", skewness = 1.8, nsims=5)
##used low number of iterations to reduce computation time

test_power_overkn(indep_skewsim, test="rank")

Run the code above in your browser using DataLab