% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/scores_su_tlfb_sui_sdsu.R
\name{compute_ss_use_yn}
\alias{compute_ss_use_yn}
\title{Compute substance use Y/N for a participant}
\usage{
compute_ss_use_yn(
  data,
  name,
  substance,
  algo = "next_existing_fy",
  cumulative = FALSE
)
}
\arguments{
\item{data}{tibble. A dataframe produced by \code{\link[=prepare_data_sdsu]{prepare_data_sdsu()}}.}

\item{name}{character(1). Name of the output score column to validate.}

\item{substance}{character (vector). The substance(s) to compute the score
for. Must be one or several of the following values:
\itemize{
\item \code{"Alcohol (Sipping)"}
\item \code{"Nicotine (Puffing)"}
\item \code{"Marijuana (Puffing)"}
\item \code{"Alcohol"}
\item \code{"Nicotine"}
\item \code{"Marijuana"}
\item \code{"Cocaine or Crack Cocaine"}
\item \code{"Methamphetamine, Meth, or Crystal Meth"}
\item \code{"Ketamine or Special K"}
\item \code{"Heroin, Opium, Junk, Smack, or Dope"}
\item \code{"Cathinones such as Bath Salts, Drone, or Meph"}
\item \code{"Ecstasy, Molly, or MDMA"}
\item \code{"GHB, Liquid G, or Georgia Homeboy"}
\item \code{"Hallucinogen Drugs including LSD, PCP, Peyote, Mescaline, DMT, AMT, or Foxy"}
\item \code{"Psilocybin, Magic Mushrooms, or Shrooms"}
\item \code{"Anabolic Steroids"}
\item \code{"Inhalants"}
\item \code{"Prescription Anxiolytics, Tranquilizers, or Sedatives"}
\item \code{"OTC Cough or Cold Medicine, DXM, 'Lean', or 'Purple Drank'"}
\item \code{"Salvia"}
\item \code{"Prescription Stimulants"}
\item \code{"Prescription Opioids"}
\item \code{"'Fake' Marijuana or Synthetics"}
\item \code{"Other substances"}
\item \code{"Nicotine Vaping Products"}
\item \code{"Tobacco Cigarette"}
\item \code{"Cigars, Little Cigars, or Cigarillos"}
\item \code{"Tobacco in a Pipe"}
\item \code{"Hookah with Tobacco"}
\item \code{"Nicotine Replacements"}
\item \code{"Smokeless Tobacco, Chew, or Snus"}
\item \code{"Flavored Vaping Products"}
\item \code{"Smoking Marijuana Flower"}
\item \code{"Marijuana Edibles"}
\item \code{"Marijuana Infused Alcohol Drinks"}
\item \code{"Marijuana Concentrates"}
\item \code{"Concentrated Marijuana Tinctures"}
\item \code{"Blunts or Combined Tobacco and Marijuana in Joints"}
\item \code{"Vaped Marijuana Flower"}
\item \code{"Vaped Marijuana Oils or Concentrates"}
\item \code{"CBD (Non-Medical Use)"}
\item \code{"Alcohol (Including low-level use)"}
\item \code{"Nicotine (Including low-level use)"}
\item \code{"Marijuana (Including low-level use)"}
\item \code{"Substance use (Not including alcohol, nicotine, and cannabis)"}
\item \code{"Substance use"}
\item \code{"Substance use (Including low-level use)"}
}}

\item{algo}{character. Mapping algorithm to apply to mid‑year
sessions. Allowed values:
\itemize{
\item \code{"next_existing_fy"}: assign a mid year to the next existing full year.
If a participant ends with mid‑year visits, those terminal mid‑year
records are dropped.
\item \code{"next_potential_fy"}: assign a mid year to the next existing full year when
present, otherwise assign to the next forecasted full year
(that may never materialize).
\item \code{"next_immediate_fy"}: assign a mid year to the next full year regardless of
whether that full year record exists or not.
\item \code{"remove_my"}: drop mid-year events and keep only full-year events.
If \code{NULL} (default) no mapping is performed and \code{data} is returned unchanged.
}}

\item{cumulative}{logical(1). If \code{FALSE} (default), returns use at each
session. If \code{TRUE}, returns 1 from the first session where use was
observed onward (i.e. ever used up to and including that session).}
}
\value{
A tibble with columns \code{participant_id}, \code{session_id} and a numeric
column named by \code{name} containing 1 (use) or 0 (no use).
}
\description{
For each participant computes a binary (1/0) indicator indicating any use
of (one of) the given substance(s) at a session (or cumulatively up to and
including that session when \code{cumulative = TRUE}).
Parameter \code{algo} is set to "next_existing_fy".
}
\examples{
\dontrun{
deap_data |>
  prepare_data_sdsu() |>
  compute_ss_use_yn(
    name = "su_y_alc_use_yn",
    substance = "Alcohol"
  )
}
}
\seealso{
\code{\link[=map_mid_years]{map_mid_years()}}
}
