semPower.postHoc: semPower.postHoc

View source: R/postHoc.R

semPower.postHocR Documentation

semPower.postHoc

Description

Performs a post-hoc power analysis, i. e., determines power (= 1 - beta) given alpha, df, and and a measure of effect.

Usage

semPower.postHoc(
  effect = NULL,
  effect.measure = NULL,
  alpha,
  N,
  df = NULL,
  p = NULL,
  SigmaHat = NULL,
  Sigma = NULL,
  muHat = NULL,
  mu = NULL,
  fittingFunction = "ML",
  simulatedPower = FALSE,
  modelH0 = NULL,
  modelH1 = NULL,
  simOptions = NULL,
  lavOptions = NULL,
  lavOptionsH1 = lavOptions,
  ...
)

Arguments

effect

effect size specifying the discrepancy between the null hypothesis (H0) and the alternative hypothesis (H1). A list for multiple group models; a vector of length 2 for effect-size differences. Can be NULL if Sigma and SigmaHat are set.

effect.measure

type of effect, one of "F0", "RMSEA", "Mc", "GFI", "AGFI". Can be NULL if Sigma and SigmaHat are set.

alpha

alpha error

N

the number of observations (a list for multiple group models)

df

the model degrees of freedom. See semPower.getDf() for a way to obtain the df of a specific model.

p

the number of observed variables, only required for effect.measure = "GFI" and effect.measure = "AGFI".

SigmaHat

can be used instead of effect and effect.measure: model implied covariance matrix (a list for multiple group models). Used in conjunction with Sigma to define the effect.

Sigma

can be used instead of effect and effect.measure: population covariance matrix (a list for multiple group models). Used in conjunction with SigmaHat to define effect.

muHat

can be used instead of effect and effect.measure: model implied mean vector. Used in conjunction with mu. If NULL, no meanstructure is involved.

mu

can be used instead of effect and effect.measure: observed (or population) mean vector. Use in conjunction with muHat. If NULL, no meanstructure is involved.

fittingFunction

one of 'ML' (default), 'WLS', 'DWLS', 'ULS'. Defines the discrepancy function used to obtain Fmin.

simulatedPower

whether to perform a simulated (TRUE, rather than analytical, FALSE) power analysis. Only available if Sigma and modelH0 are defined.

modelH0

for simulated power: lavaan model string defining the (incorrect) analysis model.

modelH1

for simulated power: lavaan model string defining the comparison model. If omitted, the saturated model is the comparison model.

simOptions

a list of additional options specifying simulation details, see simulate() for details.

lavOptions

a list of additional options passed to lavaan, e. g., list(estimator = 'mlm') to request robust ML estimation.

lavOptionsH1

alternative options passed to lavaan that are only used for the H1 model. If NULL, identical to lavOptions. Probably only useful for multigroup models.

...

other parameters related to plots, notably plotShow, plotShowLabels, and plotLinewidth.

Value

Returns a list. Use summary() to obtain formatted results.

See Also

semPower.aPriori() semPower.compromise()

Examples

## Not run: 
# achieved power with a sample of N = 250 to detect misspecifications corresponding
# to RMSEA >= .05 on 200 df on alpha = .05.
ph <- semPower.postHoc(effect = .05, effect.measure = "RMSEA", 
                       alpha = .05, N = 250, df = 200)
summary(ph)

# power analysis for to detect the difference between a model (with df = 200) exhibiting RMSEA = .05
# and a model (with df = 210) exhibiting RMSEA = .06.
ph <- semPower.postHoc(effect = c(.05, .06), effect.measure = "RMSEA", 
                       alpha = .05, N = 500, df = c(200, 210))
summary(ph)

# multigroup example
ph <- semPower.postHoc(effect = list(.02, .01), effect.measure = "F0", 
                        alpha = .05, N = list(250, 350), df = 200)
summary(ph)

# power analysis based on SigmaHat and Sigma (nonsense example)
ph <- semPower.postHoc(alpha = .05, N = 1000, df = 5,  
                       SigmaHat = diag(4), 
                       Sigma = cov(matrix(rnorm(4*1000),  ncol=4)))
summary(ph)

# simulated power analysis (nonsense example)
ph <- semPower.aPriori(alpha = .05, N = 500, df = 200,  
                       SigmaHat = list(diag(4), diag(4)), 
                       Sigma = list(cov(matrix(rnorm(4*1000), ncol=4)), 
                                    cov(matrix(rnorm(4*1000), ncol=4))),
                       simulatedPower = TRUE, nReplications = 100)
summary(ph)

## End(Not run)

semPower documentation built on Sept. 30, 2024, 9:24 a.m.