% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/process_data_ampute.R
\name{missing_values}
\alias{missing_values}
\title{Process Data by Generating Missing Values}
\usage{
missing_values(data, ..., prop = 0.5, mech = "MCAR")
}
\arguments{
\item{data}{A data frame.}

\item{...}{Optional arguments to be
passed to \code{\link[mice:ampute]{mice::ampute()}}.}

\item{prop}{The proportion of missingness.
Default is 0.5, about 50\% of the cases
have missing data.}

\item{mech}{The missing data mechanism.
Default is \code{"MCAR"} (missing completely at random).
Other possible values are \code{"MAR"}
(missing at random) and \code{"MNAR"}
(missing not at random). Please refer
to the help of \code{\link[mice:ampute]{mice::ampute()}} for
details.}
}
\value{
It returns a data frame with the
missing values inserted.
}
\description{
For the \code{process_data}
argument. It introduces missing
values in the generated data.
}
\details{
This function is to be used in
the \code{process_data} argument of
\code{\link[=power4test]{power4test()}}.

The missing values are generated by
\code{\link[mice:ampute]{mice::ampute()}}. Please refer to
its help page, the vignette for
this function:
\href{https://rianneschouten.github.io/mice_ampute/vignette/ampute.html}{Generate missing values with ampute},
and Schouten, Lugtig, and Vink (2018).

In addition to \code{data}, only two
arguments are explicitly defined for
\code{\link[=missing_values]{missing_values()}}: \code{prop} and \code{mech}.
The argument \code{prop} is defined to remind
users of the default value for this
argument. The argument \code{mech}, specifying
the missing data mechanism, is
defined because its default value
is different from that of \code{\link[mice:ampute]{mice::ampute()}}.
For \code{\link[=missing_values]{missing_values()}}, the default value
is \code{"MCAR"}, missing completely at
random.

Please refer to the help page of
\code{\link[mice:ampute]{mice::ampute()}} for other available
arguments.
\subsection{Note for \code{patterns} and other arguments with variable names}{

If arguments such as \code{patterns} are
specified, the variable names need to be
those in the generated data. If
indicator scores are generated, the
names need to be the names of the indicators,
not the names of the latent variables.
}
}
\examples{

# Specify the model

mod <-
"
m ~ x
y ~ m + x
"

# Specify the population values

mod_es <-
"
y ~ m: l
m ~ x: m
y ~ x: n
"
# Simulate the data

out <- power4test(
         nrep = 2,
         model = mod,
         pop_es = mod_es,
         n = 200,
         process_data = list(fun = "missing_values",
                             args = list(prop = .75)),
         test_fun = test_parameters,
         test_args = list(op = "~"),
         parallel = FALSE,
         iseed = 1234)

dat <- pool_sim_data(out)
head(dat, 50)

}
\references{
Schouten, R. M., Lugtig, P., & Vink, G.
(2018). Generating missing values for
simulation purposes: A multivariate
amputation procedure.
\emph{Journal of Statistical Computation and Simulation, 88}(15),
2909--2930. \doi{10.1080/00949655.2018.1491577}
}
\seealso{
\code{\link[=power4test]{power4test()}}. See also
\code{\link[mice:ampute]{mice::ampute()}} for the amputation
method.
}
