% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/its.R
\name{mb_its}
\alias{mb_its}
\title{Interrupted time series via segmented regression}
\usage{
mb_its(y, time, intervention_time, lag = 0L, quiet = FALSE)
}
\arguments{
\item{y}{Numeric vector of outcomes ordered by \code{time}.}

\item{time}{Numeric vector of time indices, same length as \code{y}.}

\item{intervention_time}{Numeric scalar. The first time point
considered post-intervention.}

\item{lag}{Integer >= 0. Number of pre-intervention observations
to drop near the intervention (transition period). Default \code{0}.}

\item{quiet}{Logical. If \code{FALSE} (default), the print method
appends a one-line reminder that this is a single-group
segmented regression and points to specialist tooling for
autocorrelation correction. Set to \code{TRUE} to suppress.}
}
\value{
An \code{mb_its} object: a list with \code{coefficients} (named
numeric), \code{se} (named numeric), \code{level_change}, \code{slope_change},
\code{intervention_time}, \code{n}, \code{n_pre}, \code{n_post}, and \code{vintage}.
}
\description{
Fits a single-group interrupted time series model:
\deqn{Y_t = \beta_0 + \beta_1 t + \beta_2 P_t + \beta_3 (t - t^*) P_t + \epsilon_t}
where \code{P_t} is 1 for \verb{t >= t*} and \verb{t*} is the intervention time.
\code{beta_2} is the immediate level change at the intervention;
\code{beta_3} is the change in slope.
}
\details{
Segmented regression assumes residuals are independent. For
autocorrelated series, fit a Newey-West, Prais-Winsten, or
ARIMA-error specification using \pkg{sandwich}, \pkg{nlme}, or
\pkg{forecast}. This function is the canonical baseline.
}
\examples{
set.seed(2)
time <- 1:48
y    <- 10 + 0.05 * time + ifelse(time >= 25, 2 + 0.1 * (time - 25), 0) + rnorm(48, sd = 0.5)
mb_its(y, time, intervention_time = 25)
}
\references{
Bernal, J. L., Cummins, S., Gasparrini, A. (2017). Interrupted
time series regression for the evaluation of public health
interventions: a tutorial. International Journal of
Epidemiology 46(1). \url{doi:10.1093/ije/dyw098}.

Wagner, A. K., Soumerai, S. B., Zhang, F., Ross-Degnan, D.
(2002). Segmented regression analysis of interrupted time series
studies in medication use research. Journal of Clinical Pharmacy
and Therapeutics 27. \url{doi:10.1046/j.1365-2710.2002.00430.x}.
}
\seealso{
\code{\link[=mb_did_2x2]{mb_did_2x2()}}, \code{\link[=mb_event_study]{mb_event_study()}}.

Other estimators: 
\code{\link{mb_did_2x2}()},
\code{\link{mb_event_study}()}
}
\concept{estimators}
