Perform a post-estimation prediction with uncertainty quantification via parametric bootstrap

cmpredict(
  out,
  newdata = NULL,
  zval = NULL,
  typical = NULL,
  nsim = 1000L,
  seed = NULL,
  draws = FALSE
)

Arguments

out

An output of cmreg.

newdata

A named data frame, list, or vector supplying values for every covariate in the fitted formula. A data frame returns one prediction row per row of `newdata`.

zval

Optional named vector for one covariate to vary. Its name must match a formula variable; all remaining covariates are supplied through `newdata` or `typical`.

typical

Optional named vector or list of fixed covariate values. This is a convenience alternative to `newdata` when used with `zval`.

nsim

Number of parametric-bootstrap draws.

seed

Optional integer seed for reproducible bootstrap draws. When set, the caller's RNG state is restored before returning.

draws

If `TRUE`, attach the raw bootstrap draw matrix as a `"draws"` attribute on the returned data frame.

Value

A data frame with `estimate`, `conf.low`, and `conf.high` columns, with one row for each prediction scenario. When `draws = TRUE`, its `"draws"` attribute contains the raw parametric-bootstrap matrix.

References

Atsusaka, Y. and Stevenson, R. T. (2023). The crosswise model for sensitive survey questions. doi:10.1017/pan.2021.43 .

See also

[cmreg()] to fit the required outcome-model object and [cmpredict_p()] for predictions from a predictor model.

Examples

m <- cmreg(Y ~ female + age, anchor = A, p = 0.1, p.prime = 0.15,
           data = cmdata2)
predictions <- cmpredict(m, typical = c(age = 30),
                          zval = c(female = 0, female = 1))
predictions
#>    estimate  conf.low conf.high
#> 1 0.3381601 0.2951779 0.3833926
#> 2 0.4037116 0.3598563 0.4515946