simPower: Monte-Carlo power simulation

View source: R/simPower.R

simPowerR Documentation

Monte-Carlo power simulation

Description

Power simulation of a likelihood ratio test between two models given simulated data from a true model in R/OpenMx Assume you have a H1 model that test whether a pretest and a posttest score

Usage

simPower(h0Model, h1Model, populationModel, N = c(20, 100),
  repetitions = 100, keepModels = FALSE, simfunc = simulateData,
  simargs = NULL)

Arguments

h0Model

Model representing the null hypothesis

h1Model

Model representing the alternative hypothesis

N

Sample size. For RAM models, this is either (1) a scalar representing a fixed sample size, (2) a list with two items representing a minimum and a maximum for randomly drawn sample sizes (when sample size is the dependent variable), or (3) for multiple group models, this is a named list of sample sizes for the sub models where the names must match the submodels' names.

repetitions

Number of Monte Carlo trials

keepModels

Boolean. Keep models from all trials for later inspection?

simfunc

Function to simulate data. Default is based on multivariate normal distribution.

simargs

Extra arguments to be passed to the method for simulating data.

populationModel

True

population model used to generate data from.

psim

SimPower result object

prng

Range for plotting p values

target.power

If not null, draw a line to indicate sample size for a specified target power in a power curve plot.

lw

line width for power curve

lty

line type for power curve

Author(s)

: Andreas Brandmaier

See Also

simPowerZeroRestriction

Examples

simPower(h0Model,h1Model, populationModel, N=c(20,100),repetitions=100, keepModels=F)

plot(psim, prng=seq(0.4,0.95,0.05), target.power=NULL, lw=2, lty=1,
                         xlab="sample size", ylab="statistical power",
                          main="Monte Carlo Power Simulation", add=F,...)
					   
print(psim, ...)	


brandmaier/semper documentation built on April 20, 2024, 4:23 p.m.