Generate a power curve

Description

Generate a power curve either based on Sobel test or bootstrap

Usage

1
2
3
4
5
power.curve(model, indirect=NULL, nobs=100, type='basic', nrep=1000, 
nboot=1000, alpha=.95, skewness=NULL, kurtosis=NULL, ovnames=NULL,  
ci='default', boot.type='default', 
se="default", estimator="default", parallel="no", 
ncore=1, interactive=TRUE, ...)

Arguments

model

A model specified using lavaan notation and above. See model.syntax for basic model specification.

For the power analysis, the population parameter values should be provided in the following way. For example, the coefficient between math and HE is .39. Then it is specified as start(.39). If the parameter will be referred in the mediation effect, a label should be given as a modifier as b*HE+start(.39)*HE.

model<-' math ~ c*ME+start(0)*ME + b*HE+start(.39)*HE HE ~ a*ME+start(.39)*ME '

indirect

The indirect or other composite effects are specified in the following way

indirect<-' ab: = a*b abc := a*b + c '

nobs

Number of observations for power analysis. It is typically should be a vector for single group analysis. For multiple group analysis, it should be a matrix.

type

Type of power analysis

nrep

Number of replications for Monte Carlo simulation. At least 1,000 is recommended.

nboot

Number of bootstraps to conduct.

alpha

The alpha level is used to obtain the confidence interval for model parameters.

skewness

A vector to give the skewness for the observed variables.

kurtosis

A vector to give the kurtosis for the observed variables.

ovnames

A vector to give the variable names for the observed variables. This is only needed when the skewness and kurtosis are provided. The skewness, kurtosis and variable names should be in the same order.

se

How to calculate the standard error, for example, robust standard error can be specified using se="robust".

estimator

Estimation methods to be used here.

parallel

Parallel methods, snow or multicore, can be used here.

ncore

Number of cores to be used in parallel. By default, the maximum number of cores are used.

ci

Type of bootstrap confidence intervals. By default, the percentile one is used. To get the bias-corrected one, use ci='BC'

boot.type

Type of bootstrap method. By default, the nonparametric one is used. Changing it to "BS" to use the Bollen-Stine method.

interactive

Whether to get the figure interactively.

...

Other named arguments for lavaan can be passed here.

Value

power

power for all parameters and required ones in the model

coverage

coverage probability

pop.value

Population parameter values

results

A list to give all intermediate results

data

The last data set generated for checking purpose

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
## Not run: 
ex2model<-'
 ept ~ start(.4)*hvltt + b*hvltt + start(0)*age + start(0)*edu + start(2)*R
 hvltt ~ start(-.35)*age + a*age + c*edu + start(.5)*edu
 R ~ start(-.06)*age + start(.2)*edu
 R =~ 1*ws + start(.8)*ls + start(.5)*lt
 age ~~ start(30)*age
 edu ~~ start(8)*edu
 age ~~ start(-2.8)*edu
 hvltt ~~ start(23)*hvltt
 R ~~ start(14)*R
 ws ~~ start(3)*ws
 ls ~~ start(3)*ls
 lt ~~ start(3)*lt
 ept ~~ start(3)*ept 
'

indirect<-'ind1 := a*b + c*b'

nobs <- seq(100, 2000, by=200)

power.curve(model=ex2model, indirect=indirect, nobs=nobs, 
type='boot', parallel='multicore', ncore=60, ci='percent', 
boot.type='simple', interactive=F)

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.