Samples data based on several parameters, mainly used to see how different
sample sizes perform given various parameterizations when simulating from
network models, especially moderated networks. See simNet
for
more details about arguments as well as the warning about simulations that
fail.
mnetPowerSim(
niter = 10,
N = 100,
p = 5,
m = FALSE,
m1 = 0,
m2 = 0.1,
sparsity = 0.5,
lags = NULL,
trueNet = NULL,
threshold = TRUE,
rule = "OR",
avg = TRUE,
maxiter = 100,
saveFits = TRUE,
saveData = FALSE,
intercepts = NULL,
mbinary = FALSE,
select = NULL,
vargs = list(),
type = "g",
gibbs = TRUE,
ordinal = FALSE,
mord = FALSE,
nLevels = 5,
minOrd = 3,
div = 1000,
modType = "none",
m1_range = NULL,
m2_range = c(0.1, 0.3),
time = TRUE,
skewErr = FALSE,
nCores = 1,
cluster = "mclapply",
fixedPar = NULL,
V2 = 1,
...
)
Number of iterations/samples to take for each combination of parameters.
Numeric value, or vector of sample sizes to generate data with.
Numeric value, or vector of network sizes.
If a value is provided then a moderated network will be simulated.
See simNet
for details.
Functions similarly to m2
, except that this argument refers
to the number/probability of main effects of the moderator on any given
node.
Numeric. If m2 >= 1
, then this will determine the number of
interaction effects between the moderator and some node in the network. If
a value between 0 and 1 is provided, then this determines the probability
of any given edge being moderated by the moderator.
Numeric value between 0 and 1. Determines the sparsity of sampled network matrices.
Determines whether the network should be a temporal network or
not. If simulating a temporal network, set to TRUE
or 1.
The adjacency matrix of the data-generating network model, or a list containing the adjacency matrix as the first element, and the interaction matrix as the second element.
See corresponding argument in fitNetwork
.
Automatically set to TRUE
if select
is not NULL
.
Only applies to GGMs (including between-subjects networks) when a
threshold is supplied. The "AND"
rule will only preserve edges when
both corresponding coefficients have p-values below the threshold, while
the "OR"
rule will preserve an edge so long as one of the two
coefficients have a p-value below the supplied threshold.
See corresponding argument of netInts
If a model fails to be fit, this determines the maximum number of iterations to re-try it before giving up. Will also simulate new datasets at each iteration.
Logical. Determines whether to save the models fit to each dataset at each iteration.
Logical. Determines whether to save the datasets generated at each iteration.
A vector of means for sampling node values.
Logical. Determines whether the moderator should be a binary variable.
Identifies a variable selection function -- either
varSelect
or resample
-- to use for introducing
variable selection at each iteration. The usefulness of this is to mimic a
real-world situation, wherein the researcher may be interested in seeing
how well datasets of different sizes afford models that approximate a true
model after employing iterated variable selection. If TRUE
then this
defaults to "varSelect"
. Highly recommended to use the vargs
argument to supply necessary information about the parameters of the
variable selection process, such as sampMethod
, criterion
,
etc.
A named list of arguments relevant to the variable selection
procedure specified by the select
argument.
Can supply a variable selection object, such as the output from
either varSelect
or modSelect
, can be supplied
to choose a specific constrained model to fit on all iterations. This is
essentially an alternative to select
, in that select
performs
variable selection at each iteration, whereas this argument defines a
constrained model that is applied at every iteration.
If TRUE
, then Gibbs sampling will be used. Otherwise,
data are generated from the mvtnorm::rmvnorm
function based on the partial correlation matrix that is created.
Logical. Determines whether to generate ordinal values or not.
Logical. Determines whether the moderator variable should be simulated as ordinal.
Number of levels for the ordinal variables. Only relevant if
ordinal
is not FALSE
.
The minimum number of unique values allowed for each variable.
A value to use as a sign that the sampler diverged. Can be
increased based on expected range of values. If a datapoint is larger than
div
, then the sampler will stop.
Determines the type of moderation to employ, such as
"none", "full", "partial"
. See simNet
for details.
Numeric vector of length 2. The range of values for moderator main effect coefficients.
Numeric vector of length 2. The range of values for moderator interaction effect coefficients.
If TRUE
then the time it takes to simulate the data is
printed to screen at the end of the sampling.
The skewness parameter for the alpha
argument in the
sn::rmsn
function. Only relevant when gibbs =
FALSE
and no moderator is specified.
Numeric value indicating the number of CPU cores to use for the
resampling. If TRUE
, then the
parallel::detectCores
function will be
used to maximize the number of cores available.
Character vector indicating which type of parallelization to
use, if nCores > 1
. Options include "mclapply"
and
"SOCK"
.
Numeric. If provided, then this will be set as the
coefficient value for all edges in the network. Provides a way to
standardize the parameter values while varying the sparsity of the network.
If length(fixedPar) == 1
, then the same value will be used for all
parameters. If length(fixedPar) == 2
, then the first value will be
for pairwise relationships, and the second value will be for interaction
terms.
If V2 = 1
and m2
is between 0 and 1, the number of
interaction terms in the model will be determined by multiplying m2
with the number of elements in the interaction matrix and taking the
ceiling
.
Additional arguments.
Power simulation results
Evaluates how closely an estimated network is with the true network with regards to metrics such as sensitivity, specificity, and precision, among others. Doesn't calculate values for power, but can be used to serve a similar function as a traditional power analysis based on simulated datasets.
# NOT RUN {
x <- mnetPowerSim(niter = 10, N = c(100, 200))
summary(x)
plot(x)
# }
Run the code above in your browser using DataLab