% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/matching_interop.R
\name{as_matchit}
\alias{as_matchit}
\title{Convert couplr Result to matchit Object}
\usage{
as_matchit(
  result,
  left,
  right,
  formula = NULL,
  left_id = "id",
  right_id = "id",
  ...
)
}
\arguments{
\item{result}{A couplr result object (matching_result, full_matching_result,
cem_result, or subclass_result)}

\item{left}{Data frame of left (treated) units}

\item{right}{Data frame of right (control) units}

\item{formula}{Optional formula used for matching. If not provided, a
default formula is constructed from \code{result$info$vars}.}

\item{left_id}{Name of ID column in left (default: \code{"id"})}

\item{right_id}{Name of ID column in right (default: \code{"id"})}

\item{...}{Additional arguments (ignored)}
}
\value{
An S3 object of class \code{"matchit"} with fields:
\describe{
\item{match.matrix}{Match matrix (treated x controls)}
\item{treat}{Named treatment vector (1/0)}
\item{weights}{Matching weights}
\item{X}{Covariate matrix}
\item{call}{Original call}
\item{info}{Metadata from couplr}
}
}
\description{
Constructs a \code{matchit}-class S3 object from a couplr result, enabling
use with any function that accepts \pkg{MatchIt} objects (e.g.,
\pkg{cobalt}, \pkg{marginaleffects}).
}
\examples{
\dontrun{
left <- data.frame(id = 1:5, age = c(25, 35, 45, 55, 65))
right <- data.frame(id = 6:15, age = runif(10, 20, 70))
result <- match_couples(left, right, vars = "age")
mi <- as_matchit(result, left, right)
# Now use with cobalt:
cobalt::bal.tab(mi)
}

}
