power.groupsByFactor: power.groupsByFactor

Description Usage Arguments Details Value Author(s)

Description

Subsets a dataset by a factor then uses power.groups to calculate statistical power for each group

Usage

1
2
power.groupsByFactor(x, f, change, change.type, n1, n2, distribution, test,
  alternative = "two.sided", alpha = 0.05, nsims = 1000, nreps = 999)

Arguments

x

Numerical vector from which the distribution parameters will be calculated using fitdistr

f

Factor the same length as x, which is used to subset the data

change

Mean of second group minus mean of first group (i.e. mu2-mu1) or percentage change in mu1 to create mu2 (depending on value of change.type).

change.type

Whether the parameter change represents an additive ("A") or percentage ("M") change.

n1

Vector of sample sizes for group 1. Must be of same dimension as n2.

n2

Vector of sample sizes for group 2. Must be of same dimension as n1.

distribution

The statistical distribution for the two groups. Can be either: "Normal", "Poisson", "Lognormal" or "Negbin".

test

Should be "P" for parametric or "NP" for non-parametric. See ?power.groups for more details.

alternative

A character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter. As an example, "less" means that the alternative is that the mean of the first group is less than the mean of the second.

alpha

The type 1 error for assessing statistical significance (default is 0.05) in the power simulations.

nsims

Number of repeat simulations to estimate power (default is 1000).

nreps

Number of repeat permutations for randomisation test (default is 999).

Details

This function splits x into subsets based on f, then runs power.groups on each subset. pars1 and pars2 for power.groups are automatically calculated based on x and distribution using basic summary stats (e.g. mean, sd) or using MASS::fitdistr if distribution = "Negbin".

Value

An object of class powerByFactor, which is essentially a list containing the power results for each level of f. The package includes methods to plot() powerByFactor objects.

Author(s)

James Hutchison


hutchisonjtw/JNCCTools documentation built on May 17, 2019, 9:14 p.m.