% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/update-design.R
\name{update_design}
\alias{update_design}
\title{Update Design Variables on an Existing Survey Object}
\usage{
update_design(
  x,
  ids = NULL,
  weights = NULL,
  strata = NULL,
  fpc = NULL,
  repweights = NULL,
  validate = TRUE
)
}
\arguments{
\item{x}{A \code{survey_taylor} or \code{survey_replicate} object. \code{survey_twophase}
is not supported; create a new design with \code{\link[=as_survey_twophase]{as_survey_twophase()}}.}

\item{ids}{<\code{\link[tidyselect:language]{tidy-select}}> New cluster (PSU) ID
column(s). \code{NULL} (default) means no change. Only used for
\code{survey_taylor} objects.}

\item{weights}{<\code{\link[tidyselect:language]{tidy-select}}> New weight column
(a single column, values strictly > 0). \code{NULL} (default) means no change.}

\item{strata}{<\code{\link[tidyselect:language]{tidy-select}}> New stratification
column (a single column). \code{NULL} (default) means no change. Only used
for \code{survey_taylor} objects.}

\item{fpc}{<\code{\link[tidyselect:language]{tidy-select}}> New finite population
correction column (a single column). \code{NULL} (default) means no change.
Only used for \code{survey_taylor} objects.}

\item{repweights}{<\code{\link[tidyselect:language]{tidy-select}}> New replicate
weight columns (one or more). \code{NULL} (default) means no change. Only
used for \code{survey_replicate} objects.}

\item{validate}{Logical. If \code{TRUE} (default), re-runs the S7 class
validator after updating, which checks structural invariants (column
existence, weight column type and positivity, etc.).}
}
\value{
The modified survey object, invisibly.
}
\description{
Updates one or more design variables (weights, cluster IDs, strata, FPC,
or replicate weights) on an existing survey design object. Use this after
modifying the underlying data — for example, after recalibrating weights or
adding a stratification variable. Emits an informational message listing
changed variables.
}
\examples{
# NHANES has two weight columns for different analysis types;
# start with the MEC examination weight for exam participants
exam <- nhanes_2017[nhanes_2017$ridstatr == 2, ]
d <- as_survey(exam, ids = sdmvpsu, weights = wtmec2yr,
               strata = sdmvstra, nest = TRUE)

# Switch to interview weight for interview-based variables
d_updated <- update_design(d, weights = wtint2yr)

}
\seealso{
\code{\link[=as_survey]{as_survey()}} to create a \code{survey_taylor} object,
\code{\link[=as_survey_replicate]{as_survey_replicate()}} to create a \code{survey_replicate} object
}
\concept{update}
