getPowerFit: Find power in rejecting alternative models based on fit...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/getPowerFit.R

Description

Find the proportion of fit indices that indicate worse fit than a specified cutoffs. The cutoffs may be calculated from getCutoff of the null model.

Usage

1
2
3
getPowerFit(altObject, cutoff = NULL, nullObject = NULL, revDirec = FALSE, 
usedFit = NULL, alpha = 0.05, nVal = NULL, pmMCARval = NULL, pmMARval = NULL, 
condCutoff = TRUE, df = 0)

Arguments

altObject

SimResult that indicates alternative model that users wish to reject

cutoff

Fit indices cutoffs from null model or users. This should be a vector with a specified fit indices names as the name of vector elements. The cutoff cannot be specified if the nullObject is specified.

nullObject

The SimResult that contains the simulation result from fitting the null model by the data from the null model. The nullObject cannot be specified if the cutoff is specified.

revDirec

Reverse the direction of deciding a power by fit indices (e.g., less than –> greater than). The default is to count the proportion of fit indices that indicates lower fit to the model, such as how many RMSEA in the alternative model that is worse than cutoffs. The direction can be reversed by setting as TRUE.

usedFit

The vector of names of fit indices that researchers wish to get powers from. The default is to get powers of all fit indices

alpha

The alpha level used to find the cutoff if the nullObject is specified. This argument is not applicable if the cutoff is specified.

nVal

The sample size value that researchers wish to find the power from. This argument is applicable when altObject has a random sample size.

pmMCARval

The percent missing completely at random value that researchers wish to find the power from. This argument is applicable when altObject has a random percent missing completely at random.

pmMARval

The percent missing at random value that researchers wish to find the power from. This argument is applicable when altObject has a random percent missing at random.

condCutoff

A logical value to use a conditional quantile method (if TRUE) or logistic regression method (if FALSE) to find the power. The conditional quantile method use quantile regression to find the quantile of the cutoff on the alternative sampling distribution that varies nVal, pmMCARval, or pmMARval. The value of 1 - quantile will be reported as the power given the set of nVal, pmMCARval, and pmMARval. The logistic regression method is based on transforming the fit indices value to reject/retain decision first. Then, the logistic regression is used to predict reject/retain decision given the set of nVal, pmMCARval, and pmMARval. The predicted probability is reported as a power. This argument is applicable for specification of cutoff only.

df

The degree of freedom used in spline method in quantile regression (condCutoff = TRUE). If df is 0, which is the default, the spline method will not be applied.

Value

List of power given different fit indices. The TraditionalChi means the proportion of replications that are rejected by the traditional chi-square test.

Author(s)

Sunthud Pornprasertmanit (psunthud@gmail.com)

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
## Not run: 
# Null model with one factor
loading.null <- matrix(0, 6, 1)
loading.null[1:6, 1] <- NA
LY.NULL <- bind(loading.null, 0.7)
RPS.NULL <- binds(diag(1))
RTE <- binds(diag(6))
CFA.Model.NULL <- model(LY = LY.NULL, RPS = RPS.NULL, RTE = RTE, modelType="CFA")

# We make the examples running only 5 replications to save time.
# In reality, more replications are needed.
Output.NULL <- sim(5, n=500, model=CFA.Model.NULL)

# Get the fit index cutoff from the null model
Cut.NULL <- getCutoff(Output.NULL, 0.05)

# Alternative model with two factor
loading.alt <- matrix(0, 6, 2)
loading.alt[1:3, 1] <- NA
loading.alt[4:6, 2] <- NA
LY.ALT <- bind(loading.alt, 0.7)
latent.cor.alt <- matrix(NA, 2, 2)
diag(latent.cor.alt) <- 1
RPS.ALT <- binds(latent.cor.alt, "runif(1, 0.7, 0.9)")
CFA.Model.ALT <- model(LY = LY.ALT, RPS = RPS.ALT, RTE = RTE, modelType="CFA")

# We make the examples running only 5 replications to save time.
# In reality, more replications are needed.
Output.ALT <- sim(5, n=500, model=CFA.Model.NULL, generate=CFA.Model.ALT)

# Get the power based on the derived cutoff
getPowerFit(Output.ALT, cutoff=Cut.NULL)

# Get the power based on the rule of thumb proposed by Hu & Bentler (1999)
Rule.of.thumb <- c(RMSEA=0.05, CFI=0.95, TLI=0.95, SRMR=0.06)
getPowerFit(Output.ALT, cutoff=Rule.of.thumb, usedFit=c("RMSEA", "CFI", "TLI", "SRMR"))

# The example of continous varying sample size. Note that more fine-grained 
# values of n is needed, e.g., n=seq(50, 500, 1)
Output.NULL2 <- sim(NULL, n=seq(50, 500, 50), model=CFA.Model.NULL, generate=CFA.Model.NULL)
Output.ALT2 <- sim(NULL, n=seq(50, 500, 50), model=CFA.Model.NULL, generate=CFA.Model.ALT)

# Get the power based on the derived cutoff from the null model at the sample size of 250
getPowerFit(Output.ALT2, nullObject=Output.NULL2, nVal=250)

## End(Not run)

Example output

Loading required package: lavaan
This is lavaan 0.6-3
lavaan is BETA software! Please report any bugs.
 
#################################################################
This is simsem 0.5-14
simsem is BETA software! Please report any bugs.
simsem was first developed at the University of Kansas Center for
Research Methods and Data Analysis, under NSF Grant 1053160.
#################################################################

Attaching package: 'simsem'

The following object is masked from 'package:lavaan':

    inspect

Progress: 1 / 5 
Progress: 2 / 5 
Progress: 3 / 5 
Progress: 4 / 5 
Progress: 5 / 5 
Progress: 1 / 5 
Progress: 2 / 5 
Progress: 3 / 5 
Progress: 4 / 5 
Progress: 5 / 5 
chisq   cfi   tli   aic   bic rmsea  srmr 
    1     1     1     1     1     1     1 
  cfi   tli rmsea  srmr 
  0.2   0.6   1.0   0.0 
Progress: 1 / 10 
Progress: 2 / 10 
Progress: 3 / 10 
Progress: 4 / 10 
Progress: 5 / 10 
Progress: 6 / 10 
Progress: 7 / 10 
Progress: 8 / 10 
Progress: 9 / 10 
Progress: 10 / 10 
Progress: 1 / 10 
Progress: 2 / 10 
Progress: 3 / 10 
Progress: 4 / 10 
Progress: 5 / 10 
Progress: 6 / 10 
Progress: 7 / 10 
Progress: 8 / 10 
Progress: 9 / 10 
Progress: 10 / 10 
Loading required namespace: quantreg
    chisq       aic       bic     rmsea       cfi       tli      srmr 
0.6575927 1.0000000 1.0000000 0.6575927 0.6575927 0.6575927 0.7205968 

simsem documentation built on March 29, 2021, 1:07 a.m.

Related to getPowerFit in simsem...