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 |
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>.
Package: | bmem |
Type: | Package |
License: | GPL-2 |
LazyLoad: | yes |
Zhiyong Zhang and Lijuan Wang
Maintainer: Zhiyong Zhang <[email protected]>
Mediation analysis based on bootstrap
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, ...)
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, ...)
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 |
|
ci |
|
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 |
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')
.
The on-screen output includes the parameter estimates, bootstrap standard errors, and CIs.
Zhiyong Zhang and Lijuan Wang
Zhang, Z., & Wang, L. (2013). Methods for mediation analysis with missing data. Psychometrika, 78(1), 154-184.
The same as bmem
but using the Bollen-Stine method
bmem.bs(x, ram, indirect, v, ci='bc', cl=.95, boot=1000, max_it=500, ...)
bmem.bs(x, ram, indirect, v, ci='bc', cl=.95, boot=1000, max_it=500, ...)
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 |
|
cl |
Confidence level. Can be a vector. |
boot |
Number of bootstraps |
max_it |
Maximum number of iterations in EM |
... |
Other options for |
The on-screen output includes the parameter estimates, bootstrap standard errors, and CIs.
Zhiyong Zhang and Lijuan Wang
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.
Bias-corrected confidence intervals
bmem.ci.bc(par.boot, par0, cl=.95)
bmem.ci.bc(par.boot, par0, cl=.95)
par.boot |
A bootstrap object. |
par0 |
Original estimate |
cl |
Confidence level. Default 0.95. |
BC confidence intervals. The output includes - estimates, bootstrap standard errors, and confidence intervals.
Zhiyong Zhang and Lijuan Wang
bmem.ci.norm
, bmem.ci.p
, bmem.ci.bca
Bias-corrected confidence intervals (for a single variable)
bmem.ci.bc1(x, b, cl = 0.95)
bmem.ci.bc1(x, b, cl = 0.95)
x |
A vector from a bootstrap output. |
b |
Parameter estimate from the original sample |
cl |
Confidence level. Default 0.95. |
Zhiyong Zhang and Lijuan Wang
bmem.ci.norm
, bmem.ci.p
, bmem.ci.bca
Bias-corrected and accelerated confidence intervals
bmem.ci.bca(par.boot, par0, jack, cl = 0.95)
bmem.ci.bca(par.boot, par0, jack, cl = 0.95)
par.boot |
A bootstrap object. |
par0 |
Original estimate |
jack |
A Jackknife object. |
cl |
Confidence level. Default 0.95. |
BCa confidence intervals. The output includes - estimates, bootstrap standard errors, and confidence intervals.
Zhiyong Zhang and Lijuan Wang
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
bmem.ci.bca1(x, b, jack, cl = 0.95)
bmem.ci.bca1(x, b, jack, cl = 0.95)
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
bmem.ci.norm(par.boot, par0, cl = 0.95)
bmem.ci.norm(par.boot, par0, cl = 0.95)
par.boot |
A bootstrap object. |
par0 |
Original estimate |
cl |
Confidence level. Default 0.95. |
Normal confidence intervals. The output includes - estimates, bootstrap standard errors, and confidence intervals.
Zhiyong Zhang and Lijuan Wang
bmem.ci.bca
, bmem.ci.p
, bmem.ci.bc
Percentile confidence interval
bmem.ci.p(par.boot, par0, cl = 0.95)
bmem.ci.p(par.boot, par0, cl = 0.95)
par.boot |
A bootstrap object. |
par0 |
Original estimate |
cl |
Confidence level. Default 0.95. |
Percentile confidence intervals. The output includes - estimates, bootstrap standard errors, and confidence intervals.
Zhiyong Zhang and Lijuan Wang
bmem.ci.bca
, bmem.ci.norm
, bmem.ci.bc
Can be used to simulated data for an SEM model.
bmem.cov(ram,obs.variables,moment=FALSE, debug=FALSE)
bmem.cov(ram,obs.variables,moment=FALSE, debug=FALSE)
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
bmem.em(x, ram, indirect, v, robust = FALSE, varphi = 0.1, st= "i", moment = FALSE, max_it = 500, ...)
bmem.em(x, ram, indirect, v, robust = FALSE, varphi = 0.1, st= "i", moment = FALSE, max_it = 500, ...)
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 |
Bootstrap for EM
bmem.em.boot(x, ram, indirect, v, robust = FALSE, varphi = 0.1, st= "i", boot = 1000, moment = FALSE, max_it = 500, ...)
bmem.em.boot(x, ram, indirect, v, robust = FALSE, varphi = 0.1, st= "i", boot = 1000, moment = FALSE, max_it = 500, ...)
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 |
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')
.
par.boot |
Parameter estimates from bootstrap samples |
par0 |
Parameter estimates from the orignal samples |
Zhiyong Zhang and Lijuan Wang
Covariance matrix from EM
bmem.em.cov(xmis, moment = FALSE, max_it = 500)
bmem.em.cov(xmis, moment = FALSE, max_it = 500)
xmis |
An object from output of |
moment |
Whether estimating mean |
max_it |
Maximum number of iterations |
Jackknife estimate using EM
bmem.em.jack(x, ram, indirect, v, robust = FALSE, varphi = 0.1, st= "i", moment = FALSE, max_it = 500, ...)
bmem.em.jack(x, ram, indirect, v, robust = FALSE, varphi = 0.1, st= "i", moment = FALSE, max_it = 500, ...)
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 |
Estimation of robust covariance matrix
bmem.em.rcov(xmis, varphi=.1, moment=FALSE, max_it=1000, st='i')
bmem.em.rcov(xmis, varphi=.1, moment=FALSE, max_it=1000, st='i')
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 |
An interval function to calculate the robust covaraince matrix
Zhiyong Zhang and Lijuan Wang
Estimate a mediaiton model based on listwise deletion
bmem.list(x, ram, indirect, moment = FALSE, ...)
bmem.list(x, ram, indirect, moment = FALSE, ...)
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 |
Bootstrap for listwise deletion method
bmem.list.boot(x, ram, indirect, boot = 1000, moment = FALSE, ...)
bmem.list.boot(x, ram, indirect, boot = 1000, moment = FALSE, ...)
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 |
Covariance matrix for listwise deletion
bmem.list.cov(x, moment = FALSE)
bmem.list.cov(x, moment = FALSE)
x |
A data set |
moment |
Estimate mean or not |
Jackknife for listwise deletion
bmem.list.jack(x, ram, indirect, moment = FALSE, ...)
bmem.list.jack(x, ram, indirect, moment = FALSE, ...)
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 |
Estimate a mediation model based on multiple imputation
bmem.mi(x, ram, indirect, v, m = 10, moment = FALSE, ...)
bmem.mi(x, ram, indirect, v, m = 10, moment = FALSE, ...)
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 |
Bootstrap for multiple imputation
bmem.mi.boot(x, ram, indirect, v, m = 10, boot = 1000, moment = FALSE, ...)
bmem.mi.boot(x, ram, indirect, v, m = 10, boot = 1000, moment = FALSE, ...)
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 |
Covariance estimation for multiple imputation
bmem.mi.cov(x, m = 10, moment = FALSE)
bmem.mi.cov(x, m = 10, moment = FALSE)
x |
A data set |
m |
Number of imputations |
moment |
Estimate mean or not |
Jackknife for multiple imputation
bmem.mi.jack(x, ram, indirect, v, m = 10, moment = FALSE, ...)
bmem.mi.jack(x, ram, indirect, v, m = 10, moment = FALSE, ...)
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 |
Calculate the moments of a data set using either listwise deletion or pairwise deletion
bmem.moments(x, type=0)
bmem.moments(x, type=0)
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
bmem.pair(x, ram, indirect, moment = FALSE, ...)
bmem.pair(x, ram, indirect, moment = FALSE, ...)
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 |
Bootstrap for pairwise deletion
bmem.pair.boot(x, ram, indirect, boot = 1000, moment = FALSE, ...)
bmem.pair.boot(x, ram, indirect, boot = 1000, moment = FALSE, ...)
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 |
Covariance matrix estimation based on pairwise deletion
bmem.pair.cov(x, moment = FALSE)
bmem.pair.cov(x, moment = FALSE)
x |
A data set |
moment |
Estimate mean or not |
Jackknife for pairwise deletion
bmem.pair.jack(x, ram, indirect, moment = FALSE, ...)
bmem.pair.jack(x, ram, indirect, moment = FALSE, ...)
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 |
Obtain missing data pattern information
bmem.pattern(x)
bmem.pattern(x)
x |
A data set |
Plot of the bootstrap distribution
bmem.plot(x, par,...)
bmem.plot(x, par,...)
x |
A bmem object |
par |
Name of parameter to be plotted. |
... |
Options used for the generic plot function. |
A plot
Zhiyong Zhang and Lijuan Wang
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.
Convert a raw moment matrix to covariance matrix
bmem.raw2cov(x)
bmem.raw2cov(x)
x |
A moment matrix |
A covariance matrix
Zhiyong Zhang and Lijuan Wang
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.
Estimate a mediaiton model using SEM technique
bmem.sem(x, ram, N, indirect, moment=FALSE, ...)
bmem.sem(x, ram, N, indirect, moment=FALSE, ...)
x |
A covariance matrix |
ram |
A path diagram from |
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 |
bmem.list.cov
, bmem.pair.cov
, bmem.mi.cov
, bmem.em.cov
Mediation analysis using sobel test (for complete data only)
bmem.sobel(x, ram, indirect, moment=FALSE, ...)
bmem.sobel(x, ram, indirect, moment=FALSE, ...)
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 |
The on-screen output includes the parameter estimates and sobel standard errors.
Zhiyong Zhang and Lijuan Wang
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.
Internal function
bmem.sobel.ind(sem.object, ind)
bmem.sobel.ind(sem.object, ind)
sem.object |
A sem object |
ind |
Indirect effect |
Internal output
Zhiyong Zhang and Lijuan Wang
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.
Sum square of a matrix
bmem.ssq(x)
bmem.ssq(x)
x |
A matrix |
Select data according to a vector of indices
bmem.v(x, v, moment = FALSE)
bmem.v(x, v, moment = FALSE)
x |
A matrix |
v |
A vector of indices |
moment |
Covariane analysis or mean and covariance analysis |
Plot of the bootstrap distribution
## S3 method for class 'bmem' plot(x, par, ...)
## S3 method for class 'bmem' plot(x, par, ...)
x |
A bmem object |
par |
Name of parameter to be plotted. |
... |
Options used for the generic plot function. |
Generate the bootstrap histogram for a chosen parameter.
Zhiyong Zhang and Lijuan Wang
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.
Get the population parameter values including both direct and indirect effects in a model
popPar(object)
popPar(object)
object |
A |
Different from power.boot
, this function conduct power analysis based on the Sobel test.
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, ...)
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, ...)
model |
A model specified using lavaan notation and above. See 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. |
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 |
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)
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)
Different from power.basic
, this function conduct power analysis based on the bootstrap method.
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, ...)
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, ...)
model |
A model specified using lavaan notation and above. See 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. |
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 |
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)
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 either based on Sobel test or bootstrap
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, ...)
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, ...)
model |
A model specified using lavaan notation and above. See 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. |
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 |
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)
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
## S3 method for class 'bmem' summary(object, ci='bc', cl=.95, ...)
## S3 method for class 'bmem' summary(object, ci='bc', cl=.95, ...)
object |
An output object from the function |
ci |
|
cl |
Confidence level. Can be a vector. |
... |
other options can be used for the generic summary function. |
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
.
The on-screen output includes the parameter estimates, bootstrap standard errors, and CIs.
This function is adpated from the lavaan
summary function to put the results in a table.
## S3 method for class 'power' summary(object,...)
## S3 method for class 'power' summary(object,...)
object |
Output from the function either |
... |
Other options |