% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gimme.R
\name{build_gimme}
\alias{build_gimme}
\title{GIMME: Group Iterative Multiple Model Estimation}
\usage{
build_gimme(
  data,
  vars,
  id,
  time = NULL,
  ar = TRUE,
  standardize = FALSE,
  groupcutoff = 0.75,
  subcutoff = 0.5,
  paths = NULL,
  exogenous = NULL,
  hybrid = FALSE,
  rmsea_cutoff = 0.05,
  srmr_cutoff = 0.05,
  nnfi_cutoff = 0.95,
  cfi_cutoff = 0.95,
  n_excellent = 2L,
  seed = NULL
)
}
\arguments{
\item{data}{A \code{data.frame} in long format with columns for person ID,
time-varying variables, and optionally a time/beep column.}

\item{vars}{Character vector of variable names to model.}

\item{id}{Character string naming the person-ID column.}

\item{time}{Character string naming the time/order column, or \code{NULL}.
When provided, data is sorted by \code{id} then \code{time} before lagging.}

\item{ar}{Logical. If \code{TRUE} (default), autoregressive paths
(each variable predicting itself at lag 1) are included as fixed paths.}

\item{standardize}{Logical. If \code{TRUE} (default \code{FALSE}),
variables are standardized per person before estimation.}

\item{groupcutoff}{Numeric between 0 and 1. Proportion of individuals for
whom a path must be significant to be added at group level.
Default \code{0.75}.}

\item{subcutoff}{Numeric. Not used (reserved for future subgrouping).}

\item{paths}{Character vector of lavaan-syntax paths to force into the model
(e.g., \code{"V2~V1lag"}). Default \code{NULL}.}

\item{exogenous}{Character vector of variable names to treat as exogenous.
Default \code{NULL}.}

\item{hybrid}{Logical. If \code{TRUE}, also searches residual covariances.
Default \code{FALSE}.}

\item{rmsea_cutoff}{Numeric. RMSEA threshold for excellent fit (default 0.05).}

\item{srmr_cutoff}{Numeric. SRMR threshold for excellent fit (default 0.05).}

\item{nnfi_cutoff}{Numeric. NNFI/TLI threshold for excellent fit (default 0.95).}

\item{cfi_cutoff}{Numeric. CFI threshold for excellent fit (default 0.95).}

\item{n_excellent}{Integer. Number of fit indices that must be excellent to
stop individual search. Default \code{2}.}

\item{seed}{Integer or \code{NULL}. Random seed for reproducibility.}
}
\value{
An S3 object of class \code{"net_gimme"} containing:
\describe{
\item{\code{temporal}}{p x p matrix of group-level temporal (lagged)
path counts -- entry \code{[i,j]} = number of individuals with path j(t-1)->i(t).}
\item{\code{contemporaneous}}{p x p matrix of group-level contemporaneous
path counts -- entry \code{[i,j]} = number of individuals with path j(t)->i(t).}
\item{\code{coefs}}{List of per-person p x 2p coefficient matrices
(rows = endogenous, cols = \code{[lagged, contemporaneous]}).}
\item{\code{psi}}{List of per-person residual covariance matrices.}
\item{\code{fit}}{Data frame of per-person fit indices (chisq, df, pvalue,
rmsea, srmr, nnfi, cfi, bic, aic, logl, status).}
\item{\code{path_counts}}{p x 2p matrix: how many individuals have each path.}
\item{\code{paths}}{List of per-person character vectors of lavaan path syntax.}
\item{\code{group_paths}}{Character vector of group-level paths found.}
\item{\code{individual_paths}}{List of per-person character vectors of
individual-level paths (beyond group).}
\item{\code{syntax}}{List of per-person full lavaan syntax strings.}
\item{\code{labels}}{Character vector of variable names.}
\item{\code{n_subjects}}{Integer. Number of individuals.}
\item{\code{n_obs}}{Integer vector. Time points per individual.}
\item{\code{config}}{List of configuration parameters.}
}
}
\description{
Estimates person-specific directed networks from intensive longitudinal data
using the unified Structural Equation Modeling (uSEM) framework. Implements
a data-driven search that identifies:
\enumerate{
\item \strong{Group-level paths}: Directed edges present for a majority
(default 75\\%) of individuals.
\item \strong{Individual-level paths}: Additional edges specific to each
person, found after group paths are established.
}

Uses \code{lavaan} for SEM estimation and modification indices.
Accepts a single data frame with an ID column (not CSV directories).
}
\examples{
\donttest{
if (requireNamespace("gimme", quietly = TRUE)) {
  # Create simple panel data (3 subjects, 4 variables, 50 time points)
  set.seed(42)
  n_sub <- 3; n_t <- 50; vars <- paste0("V", 1:4)
  rows <- lapply(seq_len(n_sub), function(i) {
    d <- as.data.frame(matrix(rnorm(n_t * 4), ncol = 4))
    names(d) <- vars; d$id <- i; d
  })
  panel <- do.call(rbind, rows)
  res <- build_gimme(panel, vars = vars, id = "id")
  print(res)
}
}

}
\seealso{
\code{\link{build_network}}
}
