Skip to contents

Refits a "copreg" model with a changed formula and/or other arguments, the way update does for lm. Multi- part formulas need Formula's own update method, since stats::update.formula does not understand the "|" separator; update(fit, . ~ . | . + z) is handled correctly here. Passing method = switches the estimator entirely, routing the refit through copreg(); arguments that the new estimator's function does not declare are dropped, with a message naming them.

Usage

# S3 method for class 'copreg'
update(object, formula., ..., evaluate = TRUE)

Arguments

object

a fitted model of class "copreg", created with a stored call (see call in the estimator functions).

formula.

an updated formula, passed to update for the stored Formula. If missing, the original formula is reused.

...

additional arguments to override in the call, or method to switch estimator.

evaluate

if TRUE (the default) the updated call is evaluated and the refitted object returned; if FALSE the unevaluated call is returned instead.

Value

If evaluate = TRUE, a refitted object of class "copreg". If evaluate = FALSE, the unevaluated call.

References

Qian, Y., A. Koschmann, and H. Xie (2025). A practical guide to endogeneity correction using copulas. Journal of Marketing.

Examples

set.seed(1)
n  <- 150
w  <- rnorm(n)
p  <- 0.4 * w + rt(n, df = 3)
xi <- 0.5 * p + rnorm(n)
y  <- 1 + 2 * p + 1.5 * w + xi
dat <- data.frame(y = y, p = p, w = w)

fit <- endogCopula:::.copreg_fit(
  formula = y ~ p | w, data = dat,
  ctor = endogCopula:::.ctor_twostage(TRUE),
  method = "2sCOPE", cdf = "rank.n", ties = "max",
  nboots = 25, verbose = FALSE)
fit$call <- quote(endogCopula:::.copreg_fit(
  formula = y ~ p | w, data = dat,
  ctor = endogCopula:::.ctor_twostage(TRUE),
  method = "2sCOPE", cdf = "rank.n", ties = "max",
  nboots = 25, verbose = FALSE))

fit2 <- update(fit, nboots = 30)
coef(fit2)
#> (Intercept)           p           w       p_cop 
#>   0.8776032   2.8387045   1.4293344  -0.5092000