% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/longBMed.R
\name{longBMed}
\alias{longBMed}
\title{Select time-varying mediators using the longitudinal Bayesian mediation selection model}
\usage{
longBMed(model = NULL, data, n.burnin = 3000, n.iter = 6000, thin = 1)
}
\arguments{
\item{model}{Specifies how variables are assigned to the outcome(Y),
  predictor(s)(X), and candidate mediator(s) (M).
  The format depends on the type of \code{data}:

  \strong{Named list or data frame:} A character string of the form
  \code{"Y ~ X1 + X2 | M1 + M2"}, where \code{Y}, \code{X1},
  \code{X2}, \code{M1}, and \code{M2} should be replaced by the names of the
  corresponding variables in the named list or data frame.

  \strong{3-D array:} A character string of the form \code{"Y ~ X | M"},
  where Y, X, and M are specified using slice numbers. For example,
  \code{"10 ~ 1+2 | 3:9"} uses slice 10 as the outcome,
  slices 1 and 2 as predictors, and slices 3 through 9 as candidate mediators.
  If \code{model = NULL}, the first slice is used as the predictor, the
  last slice as the outcome, and all remaining slices as candidate mediators.}

\item{data}{One of:
\describe{
  \item{3-D numeric array \code{[N, T, K]}}{ N represents number of
  observations, T represents number of measurement occasions,
  and K represents a concatenated dimension of X, M, Y. Slice assignments are
    controlled by \code{model} (index expression string) or defaulted
    automatically when \code{model = NULL} as mentioned above in the
    \code{model} section.}
  \item{Named list of \code{N x T} matrices}{Each element is a
    subject-by-time matrix. Names must match the variable names in
    \code{model}.}
  \item{Long-format data frame}{The original longitudinal data in long
  format, where each row represents one measurement for one observational
  unit at one measurement occasion. The data frame must contain columns
  named \code{id} and \code{time}, together with one column for each
  variable specified in \code{model}. Here, \code{id} identifies each
  observational unit and \code{time} identifies the measurement occasion.}
}}

\item{n.burnin}{Integer. Number of burn-in iterations. Default \code{3000}.}

\item{n.iter}{Integer. Number of posterior samples after burn-in.
Default \code{6000}.}

\item{thin}{Integer. Thinning interval. Default \code{1}.}
}
\value{
A matrix of posterior summary statistics from
  \code{summary(output)$statistics}, including posterior means, standard
  deviations, and standard errors for \code{ind.joint} and \code{ind.p}.
}
\description{
This function selects time-varying mediators using the longitudinal
Bayesian mediation selection model.
}
\details{
The model supports one or more predictor variables (X), one or more
candidate mediators (M), and exactly one outcome variable (Y). Data may be
supplied as an \eqn{N \times T \times K} numeric array, a named list
of \eqn{N \times T} matrices, or a data frame in long format.


For a named list or long-format data frame, the model can be specified using
variable names, such as \code{"Y ~ X1 + X2 | M1 + M2"}.

For a 3-D array, the model can be specified using integer slice indices,
such as \code{"21 ~ 1 | 2:20"}, where the left side specifies the outcome,
the expression before \code{|} specifies the predictor(s), and the
expression after \code{|} specifies the mediator(s).
}
