Replication (version 0.1.0)

ppc.step1: Prior predictive check step 1

Description

Samples from the posterior distribution of the data by means of blavaan and simulates data y.s using lavaan simulateData. The data y.s are based on samples from the posterior and represent samples from the predictive distribution.

Usage

ppc.step1(y.o, model,
    sample.cov = NULL, sample.mean = NULL, sample.nobs = NULL,
    group = NULL, n.groups, constraints = "", WLS.V = NULL, NACOV = NULL,
    nchains = 2, nadapt = 1000, nburnin=5000, nsample=5000,
    dp = NULL, convergence= "manual",
    imp = NULL, n.r, nsim=5000, post, pT, free.i)

Arguments

y.o

A data frame containing the original data for the replication test.

model

The (b)lavaan model that is to be fitted to the data.

sample.cov

Numeric matrix. A sample variance-covariance matrix. The rownames and/or colnames must contain the observed variable names. For a multiple group analysis, a list with a variance-covariance matrix for each group. Note that if maximum likelihood estimation is used and likelihood="normal", the user provided covariance matrix is internally rescaled by multiplying it with a factor (N-1)/N, to ensure that the covariance matrix has been divided by N. This can be turned off by setting the sample.cov.rescale argument to FALSE.

sample.mean

A sample mean vector. For a multiple group analysis, a list with a mean vector for each group.

sample.nobs

Number of observations if the full data frame is missing and only sample moments are given. For a multiple group analysis, a list or a vector with the number of observations for each group.

group

A variable name in the data frame defining the groups in a multiple group analysis.

n.groups

If applicable, the number of groups.

constraints

Additional (in)equality constraints not yet included in the model syntax. See model.syntax for more information. Note that the replication hypothesis should not be specified here!

WLS.V

A user provided weight matrix to be used by estimator "WLS"; if the estimator is "DWLS", only the diagonal of this matrix will be used. For a multiple group analysis, a list with a weight matrix for each group. The elements of the weight matrix should be in the following order (if all data is continuous): first the means (if a meanstructure is involved), then the lower triangular elements of the covariance matrix including the diagonal, ordered column by column. In the categorical case: first the thresholds (including the means for continuous variables), then the slopes (if any), the variances of continuous variables (if any), and finally the lower triangular elements of the correlation/covariance matrix excluding the diagonal, ordered column by column.

NACOV

A user provided matrix containing the elements of (N times) the asymptotic variance-covariance matrix of the sample statistics. For a multiple group analysis, a list with an asymptotic variance-covariance matrix for each group. See the WLS.V argument for information about the order of the elements.

nchains

A scalar indicating the number of chains to be used in the Bayesian analysis. Default value = 2.

nadapt

The number of blavaan adaptive iterations to use at the start of the simulation. Default value = 1,000

nburnin

A scalar indicating the number of burnin iterations to be used in the Bayesian analysis. Default value = 5,000

nsample

A scalar indicating the number of samples to be taken from the posterior after burnin. Default value = 5,000

dp

blavaan default prior distributions on different types of parameters, typically the result of a call to dpriors(). See the dpriors() help file for more information.

convergence

Default = "manual". If "auto", parameters will be sampled until convergence is achieved (via autorun.jags). In this case, the arguments burnin and sample are passed to autorun.jags as startburnin and startsample, respectively. Otherwise, parameters are sampled as specified by the user (or by the run.jags defaults).

imp

Default = NULL. If imputed data is present, the imputed object of class mids as generated by mice can be included here.

n.r

Sample size for the new data (y.r).

nsim

Number of datasets y.s to be created. Default value = 5,000.

post

Do not use this argument. Matrix with samples from the posterior distribution for the original data y.o

pT

Do not use this argument. The blavaan parameter table.

free.i

Do not use this argument. A vector with indices for the freely estimated parameters as given in pT.

Value

pT

A data.frame containing the parameter table for the fitted model as given by parTable lavaan

y.s

A list containing all simulated data y.s.

See Also

bsem

Examples

Run this code
# NOT RUN {
#the following example can be used, but takes >10 seconds

#step 1 input
data <- data.frame(y=ChickWeight$weight,x=ChickWeight$Time)

model <- '
y ~ x     #regression
y ~1      #intercept not default in lavaan (but is in blavaan)
'

reg.step1 <- ppc.step1(y.o=data, model=model,n.r=50)
# }

Run the code above in your browser using DataLab