Learn R Programming

lavaSearch2 (version 1.4)

calibrateType1: Simulation Study Assessing Bias and Type 1 Error

Description

Perform a simulation study over one or several sample size to assess the bias of the estimate and the type 1 error of the Wald test and robust Wald test

Usage

calibrateType1(object, null, n.rep, ...)

# S3 method for lvm calibrateType1(object, null, n.rep, n, F.test = FALSE, cluster = NULL, generative.object = NULL, generative.coef = NULL, true.coef = NULL, n.true = 1e+06, round.true = 2, bootstrap = FALSE, n.bootstrap = 1000, checkType1 = FALSE, checkType2 = FALSE, dir.save = NULL, label.file = NULL, seed = NULL, cpus = 1, trace = 2, ...)

# S3 method for lvmfit calibrateType1(object, null, n.rep, F.test = FALSE, bootstrap = FALSE, n.bootstrap = 1000, seed = NULL, trace = 2, cpus = 1, ...)

Arguments

object

a lvm object defining the model to be fitted.

null

[character vector] names of the coefficient whose value will be tested against 0.

n.rep

[integer, >0] number of simulations per sample size.

...

[internal] Only used by the generic method.

n

[integer vector, >0] sample size(s) considered in the simulation study.

F.test

[logical] should a multivariate Wald test be perform testing simultaneously all the null hypotheses?

cluster

[integer vector] the grouping variable relative to which the observations are iid. Will be passed to lava::estimate.

generative.object

[lvm] object defining the statistical model generating the data.

generative.coef

[name numeric vector] values for the parameters of the generative model. Can also be NULL: in such a case the coefficients are set to default values decided by lava (usually 0 or 1).

true.coef

[name numeric vector] expected values for the parameters of the fitted model.

n.true

[integer, >0] sample size at which the estimated coefficients will be a reliable approximation of the true coefficients.

round.true

[integer, >0] the number of decimal places to be used for the true value of the coefficients. No rounding is done if NULL.

bootstrap

[logical] should bootstrap resampling be performed?

n.bootstrap

[integer, >0] the number of bootstrap sample to be used for each bootstrap.

checkType1

[logical] returns an error if the coefficients associated to the null hypotheses do not equal 0.

checkType2

[logical] returns an error if the coefficients associated to the null hypotheses equal 0.

dir.save

[character] path to the directory were the results should be exported. Can also be NULL: in such a case the results are not exported.

label.file

[character] element to include in the file name.

seed

[integer, >0] seed value that will be set at the beginning of the simulation to enable eproducibility of the results. Can also be NULL: in such a case no seed is set.

cpus

[integer >0] the number of processors to use. If greater than 1, the simulations are performed in parallel.

trace

[integer] should the execution of the function be trace. Can be 0, 1 or 2.

Value

An object of class calibrateType1.

See Also

link{autoplot.calibrateType1} for a graphical display of the bias or of the type 1 error.

Examples

Run this code
# NOT RUN {
#### simulate data ####
m.Sim <- lvm(c(Y1[mu1:sigma]~1*eta,
               Y2[mu2:sigma]~1*eta,
               Y3[mu3:sigma]~1*eta,
               eta~beta1*Group+beta2*Gender))
latent(m.Sim) <- ~eta
categorical(m.Sim, labels = c("M","F")) <- ~Gender

d <- lava::sim(m.Sim, 1e2)


#### calibrate type 1 error on the estimated model ####
m <- lvm(Y1~eta,
         Y2~eta,
         Y3~eta,
         eta~Group+Gender)
e <- lava::estimate(m, data = d)
# }
# NOT RUN {
res <- calibrateType1(e, null = "eta~Group", n.rep = 100)
res <- calibrateType1(e, null = "eta~Group", n.rep = 100, cpus = 4)
# }
# NOT RUN {
summary(res)

# }

Run the code above in your browser using DataLab