Package 'bmem'

Title: Mediation Analysis with Missing Data Using Bootstrap
Description: Four methods for mediation analysis with missing data: Listwise deletion, Pairwise deletion, Multiple imputation, and Two Stage Maximum Likelihood algorithm. For MI and TS-ML, auxiliary variables can be included. Bootstrap confidence intervals for mediation effects are obtained. The robust method is also implemented for TS-ML. Since version 1.4, bmem adds the capability to conduct power analysis for mediation models. Details about the methods used can be found in these articles. Zhang and Wang (2003) <doi:10.1007/s11336-012-9301-5>. Zhang (2014) <doi:10.3758/s13428-013-0424-0>.
Authors: Zhiyong Zhang and Lijuan Wang
Maintainer: Zhiyong Zhang <[email protected]>
License: GPL-2
Version: 2.1
Built: 2025-03-08 05:01:46 UTC
Source: https://github.com/cran/bmem

Help Index


Mediation analysis with missing data using bootstrap

Description

Four methods for mediation analysis with missing data: Listwise deletion, Pairwise deletion, Multiple imputation, and Two Stage Maximum Likelihood algorithm. For MI and TS-ML, auxiliary variables can be included. Bootstrap confidence intervals for mediation effects are obtained. The robust method is also implemented for TS-ML. Since version 1.4, bmem adds the capability to conduct power analysis for mediation models. Details about the methods used can be found in these articles. Zhang and Wang (2003) <doi:10.1007/s11336-012-9301-5>. Zhang (2014) <doi:10.3758/s13428-013-0424-0>.

Details

Package: bmem
Type: Package
License: GPL-2
LazyLoad: yes

Author(s)

Zhiyong Zhang and Lijuan Wang

Maintainer: Zhiyong Zhang <[email protected]>


Mediation analysis based on bootstrap

Description

Mediation analysis based on bootstrap

Usage

bmem(x, ram, indirect, v, method='tsml', ci='bc', cl=.95, 
     boot=1000, m=10, varphi=.1, st='i', robust=FALSE, 
     max_it=500, moment=FALSE, ...)

Arguments

x

A data set

ram

RAM path for the mediaiton model

indirect

A vector of indirect effec

v

Indices of variables used in the mediation model. If omitted, all variables are used.

method

list: listwise deletion, pair: pairwise deletion, mi: multiple imputation, em: EM algorithm.

ci

norm: normal approximation CI, perc: percentile CI, bc: bias-corrected CI, bca: BCa

cl

Confidence level. Can be a vector.

boot

Number of bootstraps

m

Number of imputations

varphi

Percent of data to be downweighted

st

Starting values

robust

Robust method

moment

Select mean structure or covariance analysis. moment=FALSE, covariance analysis. moment=TRUE, mean and covariance analysis.

max_it

Maximum number of iterations in EM

...

Other options for sem function can be used.

Details

The indirect effect can be specified using equations such as a*b, a*b+c, and a*b*c+d*e+f. A vector of indirect effects can be used indirect=c('a*b', 'a*b+c').

Value

The on-screen output includes the parameter estimates, bootstrap standard errors, and CIs.

Author(s)

Zhiyong Zhang and Lijuan Wang

References

Zhang, Z., & Wang, L. (2013). Methods for mediation analysis with missing data. Psychometrika, 78(1), 154-184.


Bootstrap but using the Bollen-Stine method

Description

The same as bmem but using the Bollen-Stine method

Usage

bmem.bs(x, ram, indirect, v, ci='bc', cl=.95, 
        boot=1000, max_it=500, ...)

Arguments

x

A data set

ram

RAM path for the mediaiton model

indirect

A vector of indirect effec

v

Indices of variables used in the mediation model. If omitted, all variables are used.

ci

norm: normal approximation CI, perc: percentile CI, bc: bias-corrected CI, bca: BCa

cl

Confidence level. Can be a vector.

boot

Number of bootstraps

max_it

Maximum number of iterations in EM

...

Other options for sem function can be used.

Value

The on-screen output includes the parameter estimates, bootstrap standard errors, and CIs.

Author(s)

Zhiyong Zhang and Lijuan Wang

References

Zhang, Z. & Wang, L. (2011) Four methods for mediation analysis with missing data.

Zhang, Z. (2011) Robust mediation analysis with missing data and auxiliary variables.

See Also

bmem, bmem.sobel, bmem.plot


Bias-corrected confidence intervals

Description

Bias-corrected confidence intervals

Usage

bmem.ci.bc(par.boot, par0, cl=.95)

Arguments

par.boot

A bootstrap object.

par0

Original estimate

cl

Confidence level. Default 0.95.

Value

BC confidence intervals. The output includes - estimates, bootstrap standard errors, and confidence intervals.

Author(s)

Zhiyong Zhang and Lijuan Wang

See Also

bmem.ci.norm, bmem.ci.p, bmem.ci.bca


Bias-corrected confidence intervals (for a single variable)

Description

Bias-corrected confidence intervals (for a single variable)

Usage

bmem.ci.bc1(x, b, cl = 0.95)

Arguments

x

A vector from a bootstrap output.

b

Parameter estimate from the original sample

cl

Confidence level. Default 0.95.

Author(s)

Zhiyong Zhang and Lijuan Wang

See Also

bmem.ci.norm, bmem.ci.p, bmem.ci.bca


Bias-corrected and accelerated confidence intervals

Description

Bias-corrected and accelerated confidence intervals

Usage

bmem.ci.bca(par.boot, par0, jack, cl = 0.95)

Arguments

par.boot

A bootstrap object.

par0

Original estimate

jack

A Jackknife object.

cl

Confidence level. Default 0.95.

Value

BCa confidence intervals. The output includes - estimates, bootstrap standard errors, and confidence intervals.

Author(s)

Zhiyong Zhang and Lijuan Wang

See Also

bmem.ci.norm, bmem.ci.p, bmem.ci.bc, bmem.list.jack, bmem.pair.jack, bmem.mi.jack, bmem.em.jack,


BCa for a single variable

Description

BCa for a single variable

Usage

bmem.ci.bca1(x, b, jack, cl = 0.95)

Arguments

x

A vector from a bootstrap output.

b

Parameter estimate from the original sample

jack

A vector from a Jackknife analysis

cl

Confidence level. Default 0.95.


Confidence interval based on normal approximation

Description

Confidence interval based on normal approximation

Usage

bmem.ci.norm(par.boot, par0, cl = 0.95)

Arguments

par.boot

A bootstrap object.

par0

Original estimate

cl

Confidence level. Default 0.95.

Value

Normal confidence intervals. The output includes - estimates, bootstrap standard errors, and confidence intervals.

Author(s)

Zhiyong Zhang and Lijuan Wang

See Also

bmem.ci.bca, bmem.ci.p, bmem.ci.bc


Percentile confidence interval

Description

Percentile confidence interval

Usage

bmem.ci.p(par.boot, par0, cl = 0.95)

Arguments

par.boot

A bootstrap object.

par0

Original estimate

cl

Confidence level. Default 0.95.

Value

Percentile confidence intervals. The output includes - estimates, bootstrap standard errors, and confidence intervals.

Author(s)

Zhiyong Zhang and Lijuan Wang

See Also

bmem.ci.bca, bmem.ci.norm, bmem.ci.bc


Calculate the covariance matrix based on a given ram model

Description

Can be used to simulated data for an SEM model.

Usage

bmem.cov(ram,obs.variables,moment=FALSE, debug=FALSE)

Arguments

ram

An ram model

obs.variables

Names of the observed variables

moment

Whether to use the mean structure

debug

debug mode


Estimate a mediation model based on EM covariance matrix

Description

Estimate a mediation model based on EM covariance matrix

Usage

bmem.em(x, ram, indirect, v, robust = FALSE, 
        varphi = 0.1, st= "i", moment = FALSE, 
        max_it = 500, ...)

Arguments

x

A data set

ram

RAM path for the mediaiton model

indirect

A vector of indirect effec

v

Indices of variables used in the mediation model. If omitted, all variables are used.

robust

Roubst method

varphi

Percent of data to be downweighted

st

Starting values

moment

Select mean structure or covariance analysis. moment=FALSE, covariance analysis. moment=TRUE, mean and covariance analysis.

max_it

Maximum number of iterations in EM

...

Other options for sem function can be used.


Bootstrap for EM

Description

Bootstrap for EM

Usage

bmem.em.boot(x, ram, indirect, v, robust = FALSE, 
             varphi = 0.1, st= "i", boot = 1000, 
             moment = FALSE, max_it = 500, ...)

Arguments

x

A data set

ram

RAM path for the mediaiton model

indirect

A vector of indirect effec

v

Indices of variables used in the mediation model. If omitted, all variables are used.

robust

Roubst method

varphi

Percent of data to be downweighted

st

Starting values

boot

Number of bootstraps. Default is 1000.

moment

Select mean structure or covariance analysis. moment=FALSE, covariance analysis. moment=TRUE, mean and covariance analysis.

max_it

Maximum number of iterations in EM

...

Other options for sem function can be used.

Details

The indirect effect can be specified using equations such as a*b, a*b+c, and a*b*c+d*e+f. A vector of indirect effects can be used indirect=c('a*b', 'a*b+c').

Value

par.boot

Parameter estimates from bootstrap samples

par0

Parameter estimates from the orignal samples

Author(s)

Zhiyong Zhang and Lijuan Wang


Covariance matrix from EM

Description

Covariance matrix from EM

Usage

bmem.em.cov(xmis, moment = FALSE, max_it = 500)

Arguments

xmis

An object from output of bmem.pattern.

moment

Whether estimating mean

max_it

Maximum number of iterations


Jackknife estimate using EM

Description

Jackknife estimate using EM

Usage

bmem.em.jack(x, ram, indirect, v, robust = FALSE, 
             varphi = 0.1, st= "i", moment = FALSE, 
             max_it = 500, ...)

Arguments

x

A data set

ram

RAM path for the mediaiton model

indirect

A vector of indirect effec

v

Indices of variables used in the mediation model. If omitted, all variables are used.

robust

Roubst method

varphi

Percent of data to be downweighted

st

Starting values

moment

Select mean structure or covariance analysis. moment=FALSE, covariance analysis. moment=TRUE, mean and covariance analysis.

max_it

Maximum number of iterations in EM

...

Other options for sem function can be used.


Estimation of robust covariance matrix

Description

Estimation of robust covariance matrix

Usage

bmem.em.rcov(xmis, varphi=.1, moment=FALSE, max_it=1000, st='i')

Arguments

xmis

Missing data pattern

varphi

Percent of data to be downweighted

moment

Moment analysis if TRUE

max_it

Maximum number of iteration

st

Starting values

Value

An interval function to calculate the robust covaraince matrix

Author(s)

Zhiyong Zhang and Lijuan Wang


Estimate a mediaiton model based on listwise deletion

Description

Estimate a mediaiton model based on listwise deletion

Usage

bmem.list(x, ram, indirect, moment = FALSE, ...)

Arguments

x

A data set

ram

RAM path for the mediaiton model

indirect

A vector of indirect effec

moment

Select mean structure or covariance analysis. moment=FALSE, covariance analysis. moment=TRUE, mean and covariance analysis.

...

Other options for sem function can be used.


Bootstrap for listwise deletion method

Description

Bootstrap for listwise deletion method

Usage

bmem.list.boot(x, ram, indirect, boot = 1000, moment = FALSE, ...)

Arguments

x

A data set

ram

RAM path for the mediaiton model

indirect

A vector of indirect effec

boot

Number of bootstraps. Default is 1000.

moment

Select mean structure or covariance analysis. moment=FALSE, covariance analysis. moment=TRUE, mean and covariance analysis.

...

Other options for sem function can be used.


Covariance matrix for listwise deletion

Description

Covariance matrix for listwise deletion

Usage

bmem.list.cov(x, moment = FALSE)

Arguments

x

A data set

moment

Estimate mean or not


Jackknife for listwise deletion

Description

Jackknife for listwise deletion

Usage

bmem.list.jack(x, ram, indirect, moment = FALSE, ...)

Arguments

x

A data set

ram

RAM path for the mediaiton model

indirect

A vector of indirect effec

moment

Select mean structure or covariance analysis. moment=FALSE, covariance analysis. moment=TRUE, mean and covariance analysis.

...

Other options for sem function can be used.


Estimate a mediation model based on multiple imputation

Description

Estimate a mediation model based on multiple imputation

Usage

bmem.mi(x, ram, indirect, v, m = 10, moment = FALSE, ...)

Arguments

x

A data set

ram

RAM path for the mediaiton model

indirect

A vector of indirect effec

v

Indices of variables used in the mediation model. If omitted, all variables are used.

m

Number of imputations.

moment

Select mean structure or covariance analysis. moment=FALSE, covariance analysis. moment=TRUE, mean and covariance analysis.

...

Other options for sem function can be used.


Bootstrap for multiple imputation

Description

Bootstrap for multiple imputation

Usage

bmem.mi.boot(x, ram, indirect, v, m = 10, boot = 1000, 
             moment = FALSE, ...)

Arguments

x

A data set

ram

RAM path for the mediaiton model

indirect

A vector of indirect effec

v

Indices of variables used in the mediation model. If omitted, all variables are used.

m

Number of imputations

boot

Number of bootstraps. Default is 1000.

moment

Select mean structure or covariance analysis. moment=FALSE, covariance analysis. moment=TRUE, mean and covariance analysis.

...

Other options for sem function can be used.


Covariance estimation for multiple imputation

Description

Covariance estimation for multiple imputation

Usage

bmem.mi.cov(x, m = 10, moment = FALSE)

Arguments

x

A data set

m

Number of imputations

moment

Estimate mean or not


Jackknife for multiple imputation

Description

Jackknife for multiple imputation

Usage

bmem.mi.jack(x, ram, indirect, v, m = 10, moment = FALSE, ...)

Arguments

x

A data set

ram

RAM path for the mediaiton model

indirect

A vector of indirect effec

v

Indices of variables used in the mediation model. If omitted, all variables are used.

m

Number of imputations.

moment

Select mean structure or covariance analysis. moment=FALSE, covariance analysis. moment=TRUE, mean and covariance analysis.

...

Other options for sem function can be used.


Calculate the moments of a data set

Description

Calculate the moments of a data set using either listwise deletion or pairwise deletion

Usage

bmem.moments(x, type=0)

Arguments

x

A data set

type

How to deal with missing data. 0: listwise deletion; 1: pairwise deletion


Estimate a mediaiton model based on pairwise deletion

Description

Estimate a mediaiton model based on pairwise deletion

Usage

bmem.pair(x, ram, indirect, moment = FALSE, ...)

Arguments

x

A data set

ram

RAM path for the mediaiton model

indirect

A vector of indirect effec

moment

Select mean structure or covariance analysis. moment=FALSE, covariance analysis. moment=TRUE, mean and covariance analysis.

...

Other options for sem function can be used.


Bootstrap for pairwise deletion

Description

Bootstrap for pairwise deletion

Usage

bmem.pair.boot(x, ram, indirect, boot = 1000, moment = FALSE, ...)

Arguments

x

A data set

ram

RAM path for the mediaiton model

indirect

A vector of indirect effec

boot

Number of bootstraps. Default is 1000.

moment

Select mean structure or covariance analysis. moment=FALSE, covariance analysis. moment=TRUE, mean and covariance analysis.

...

Other options for sem function can be used.


Covariance matrix estimation based on pairwise deletion

Description

Covariance matrix estimation based on pairwise deletion

Usage

bmem.pair.cov(x, moment = FALSE)

Arguments

x

A data set

moment

Estimate mean or not


Jackknife for pairwise deletion

Description

Jackknife for pairwise deletion

Usage

bmem.pair.jack(x, ram, indirect, moment = FALSE, ...)

Arguments

x

A data set

ram

RAM path for the mediaiton model

indirect

A vector of indirect effec

moment

Select mean structure or covariance analysis. moment=FALSE, covariance analysis. moment=TRUE, mean and covariance analysis.

...

Other options for sem function can be used.


Obtain missing data pattern information

Description

Obtain missing data pattern information

Usage

bmem.pattern(x)

Arguments

x

A data set


Plot of the bootstrap distribution. This function is replaced by plot.

Description

Plot of the bootstrap distribution

Usage

bmem.plot(x, par,...)

Arguments

x

A bmem object

par

Name of parameter to be plotted.

...

Options used for the generic plot function.

Value

A plot

Author(s)

Zhiyong Zhang and Lijuan Wang

References

Zhang, Z. & Wang, L. (2011) Four methods for mediation analysis with missing data.

Zhang, Z. (2011) Robust mediation analysis with missing data and auxiliary variables.

See Also

bmem, bmem.sobel, bmem.plot


Convert a raw moment matrix to covariance matrix

Description

Convert a raw moment matrix to covariance matrix

Usage

bmem.raw2cov(x)

Arguments

x

A moment matrix

Value

A covariance matrix

Author(s)

Zhiyong Zhang and Lijuan Wang

References

Zhang, Z. & Wang, L. (2011) Four methods for mediation analysis with missing data.

Zhang, Z. (2011) Robust mediation analysis with missing data and auxiliary variables.

See Also

bmem, bmem.sobel, bmem.plot


Estimate a mediaiton model using SEM technique

Description

Estimate a mediaiton model using SEM technique

Usage

bmem.sem(x, ram, N, indirect, moment=FALSE, ...)

Arguments

x

A covariance matrix

ram

A path diagram from specify.model

N

Sample size

indirect

A vector of indirect effects

moment

Whether mean strucuture is used. The default is FALSE

...

Options that can be supplied to function sem.

See Also

bmem.list.cov, bmem.pair.cov, bmem.mi.cov, bmem.em.cov


Mediation analysis using sobel test (for complete data only)

Description

Mediation analysis using sobel test (for complete data only)

Usage

bmem.sobel(x, ram, indirect, moment=FALSE, ...)

Arguments

x

A data set

ram

RAM path for the mediaiton model

indirect

A vector of indirect effec

moment

Covariance or moment analysis

...

Other options for sem function can be used.

Value

The on-screen output includes the parameter estimates and sobel standard errors.

Author(s)

Zhiyong Zhang and Lijuan Wang

References

Zhang, Z. & Wang, L. (2011) Four methods for mediation analysis with missing data.

Zhang, Z. (2011) Robust mediation analysis with missing data and auxiliary variables.

See Also

bmem, bmem.sobel, bmem.plot


Mediation analysis using sobel test for one indirect effect

Description

Internal function

Usage

bmem.sobel.ind(sem.object, ind)

Arguments

sem.object

A sem object

ind

Indirect effect

Value

Internal output

Author(s)

Zhiyong Zhang and Lijuan Wang

References

Zhang, Z. & Wang, L. (2011) Four methods for mediation analysis with missing data.

Zhang, Z. (2011) Robust mediation analysis with missing data and auxiliary variables.

See Also

bmem, bmem.sobel, bmem.plot


Sum square of a matrix

Description

Sum square of a matrix

Usage

bmem.ssq(x)

Arguments

x

A matrix


Select data according to a vector of indices

Description

Select data according to a vector of indices

Usage

bmem.v(x, v, moment = FALSE)

Arguments

x

A matrix

v

A vector of indices

moment

Covariane analysis or mean and covariance analysis


Plot of the bootstrap distribution

Description

Plot of the bootstrap distribution

Usage

## S3 method for class 'bmem'
plot(x, par, ...)

Arguments

x

A bmem object

par

Name of parameter to be plotted.

...

Options used for the generic plot function.

Value

Generate the bootstrap histogram for a chosen parameter.

Author(s)

Zhiyong Zhang and Lijuan Wang

References

Zhang, Z. & Wang, L. (2011) Four methods for mediation analysis with missing data.

Zhang, Z. (2011) Robust mediation analysis with missing data and auxiliary variables.

See Also

bmem, bmem.sobel, bmem.plot


Get the population parameter values

Description

Get the population parameter values including both direct and indirect effects in a model

Usage

popPar(object)

Arguments

object

A lavaan object


Conducting power analysis based on Sobel test

Description

Different from power.boot, this function conduct power analysis based on the Sobel test.

Usage

power.basic(model, indirect = NULL, nobs, nrep = 1000, alpha = 0.95, 
skewness = NULL, kurtosis = NULL, ovnames = NULL, se = "default", 
estimator = "default", parallel = "no", ncore = 1,  ...)

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. If it is a vector, multiple group analysis will be conducted.

nrep

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

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 defautl, the maximum number of cores are used.

...

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

ex1model<-'
math ~ c*ME+start(0)*ME + b*HE+start(0.39)*HE
HE ~ a*ME+start(0.39)*ME
'

indirect<-'ab:=a*b'

N<-50

## change nrep to at least 1000 in real analysis

system.time(non.normal<-power.basic(ex1model, indirect, N, 
 nrep=30, skewness=c(-.3, -.7, 1.3), 
 kurtosis=c(1.5, 0, 5), ovnames=c('ME', 'HE', 'math')))
 
summary(non.normal)

Conducting power analysis based on bootstrap

Description

Different from power.basic, this function conduct power analysis based on the bootstrap method.

Usage

power.boot(model, indirect = NULL, nobs, nrep = 1000, nboot = 1000, 
alpha = 0.95, skewness = NULL, kurtosis = NULL, ovnames = NULL,  
ci='default', boot.type='default', 
se = "default", estimator = "default", parallel = "no", 
ncore = 1,  ...)

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. If it is a vector, multiple group analysis will be conducted.

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 defautl, 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.

...

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

ex1model<-'
math ~ c*ME+start(0)*ME + b*HE+start(0.39)*HE
HE ~ a*ME+start(0.39)*ME
'

indirect<-'ab:=a*b'

N<-50

## change nrep and nboot to at least 1000 in real analysis
system.time(boot.non.normal<-power.boot(ex1model, indirect, N, 
 nrep=100, nboot=100, skewness=c(-.3, -.7, 1.3), 
 kurtosis=c(1.5, 0, 5), ovnames=c('ME', 'HE', 'math'),  ci='percent', boot.type='simple'))
summary(boot.non.normal)

Generate a power curve

Description

Generate a power curve either based on Sobel test or bootstrap

Usage

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

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, 200, by=100)

## change nrep and nboot to at least 1000 in real analysis
power.curve(model=ex2model, indirect=indirect, nobs=nobs, 
type='boot', nrep=30, nboot=30, ci='percent', 
boot.type='simple', interactive=FALSE)

Calculate bootstrap confidence intervals

Description

Calculate bootstrap confidence intervals

Usage

## S3 method for class 'bmem'
summary(object, ci='bc', cl=.95, ...)

Arguments

object

An output object from the function bmem

ci

norm: normal approximation CI, perc: percentile CI, bc: bias-corrected CI, bca: BCa

cl

Confidence level. Can be a vector.

...

other options can be used for the generic summary function.

Details

The other type of confidence intervals can be constructed from the output of the function bmem. Note if the BCa is required, the ci='BCa' should have been specified in the function bmem.

Value

The on-screen output includes the parameter estimates, bootstrap standard errors, and CIs.


Organize the results into a table

Description

This function is adpated from the lavaan summary function to put the results in a table.

Usage

## S3 method for class 'power'
summary(object,...)

Arguments

object

Output from the function either power.basic or power.boot.

...

Other options