% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/causalsim_draw.R
\name{causalsim_draw}
\alias{causalsim_draw}
\title{Draw a dataset from a causal DGP}
\usage{
causalsim_draw(dgp, seed = NULL)
}
\arguments{
\item{dgp}{A \code{causalsim_dgp} object created by \code{\link[=causalsim_dgp]{causalsim_dgp()}}.}

\item{seed}{Integer or \code{NULL}. If non-null, passed to \code{\link[=set.seed]{set.seed()}} before
generating any random values, making the draw reproducible. Default \code{NULL}.}
}
\value{
A data frame with \code{dgp$n} rows and the following columns:
\describe{
\item{Covariate columns}{One column per covariate in \code{dgp$covar_spec},
named to match the spec (e.g. \code{W}, \code{W1}, \code{Z}).}
\item{\code{A}}{Binary treatment indicator (0/1).}
\item{\code{Y}}{Observed outcome.}
\item{\code{.tau}}{Individual treatment effect (CATE). Ground truth.}
\item{\code{.p}}{Individual propensity score. Ground truth.}
}

The \code{.tau} and \code{.p} columns carry individual-level ground truth and are
prefixed with \code{.} to distinguish them from observed variables.
\code{causalsim_eval()} uses them directly without re-estimation.
}
\description{
Simulates one dataset from a \code{\link[=causalsim_dgp]{causalsim_dgp()}} object using the structural
model:
}
\details{
\if{html}{\out{<div class="sourceCode">}}\preformatted{W ~ covariate_spec
A ~ Bernoulli(propensity(W))
Y  = baseline(W) + effect(W) * A + N(0, sigma^2)
}\if{html}{\out{</div>}}
}
\examples{
dgp <- causalsim_dgp(n = 500, n_confounders = 1, effect = 2)
d   <- causalsim_draw(dgp, seed = 1)
head(d)

# Reproducible draws
d1 <- causalsim_draw(dgp, seed = 42)
d2 <- causalsim_draw(dgp, seed = 42)
identical(d1, d2)  # TRUE

}
