impute_model() wraps the model for a predictor used inside mi(). A bare
formula in impute, such as impute = list(x = x ~ z), is still treated as
a Gaussian model for a numeric missing predictor. Use impute_model() when
the missing predictor needs an explicit non-Gaussian predictor family. The
first non-Gaussian fitted routes are fixed-effect Bernoulli/logit models for
one binary predictor, fixed-effect cumulative-logit models for one ordered
categorical predictor, fixed-effect baseline-category softmax models for one
unordered categorical predictor, fixed-effect beta models for one strict
proportion predictor in (0, 1), fixed-effect zero-one beta models for one
boundary proportion predictor in [0, 1], fixed-effect beta-binomial
models for one denominator-aware success/trial proportion predictor,
fixed-effect Poisson, negative-binomial, or zero-truncated
negative-binomial models for one count predictor, fixed-effect lognormal or
Gamma models for one positive continuous predictor, and fixed-effect
Tweedie models for one non-negative semi-continuous predictor with exact
zeros. Most current non-Gaussian predictor families are fitted inside a
Gaussian response location model; Poisson, binomial, negative-binomial, and
beta responses are currently supported for one binary missing predictor.
Usage
impute_model(formula, family = stats::gaussian(), trials = NULL)Arguments
- formula
Two-sided predictor-model formula. For most families, the left-hand side must be the same variable used inside
mi(). Forfamily = beta_binomial(), the left-hand side is the success-count column, while themi()variable is the success proportion used in the response model.- family
Predictor-model family.
gaussian()keeps the existing continuous predictor route.binomial(link = "logit")fits the binary missing-predictor route.cumulative_logit()fits the ordered categorical missing-predictor route.categorical()fits the unordered categorical missing-predictor route.beta()fits the strict beta/proportion missing-predictor route.zero_one_beta()fits the boundary-proportion missing-predictor route.beta_binomial()fits a denominator-aware success/trial proportion route and requirestrials.poisson(link = "log"),nbinom2(), andtruncated_nbinom2()fit count missing-predictor routes.lognormal()andGamma(link = "log")fit positive continuous missing-predictor routes.tweedie()fits a semi-continuous non-negative missing-predictor route with exact zeros.- trials
Optional trial-count column for
family = beta_binomial(). The formula left-hand side is the success count andtrialsis the known denominator for each row.
Value
A drm_impute_model object for the impute argument of drmTMB().
Examples
impute_model(x ~ z)
#> $formula
#> x ~ z
#> <environment: 0x556a9b1d15d8>
#>
#> $family
#>
#> Family: gaussian
#> Link function: identity
#>
#>
#> $family_type
#> [1] "gaussian"
#>
#> $trials
#> NULL
#>
#> attr(,"class")
#> [1] "drm_impute_model"
impute_model(treatment ~ z, family = binomial())
#> $formula
#> treatment ~ z
#> <environment: 0x556a9b1d15d8>
#>
#> $family
#>
#> Family: binomial
#> Link function: logit
#>
#>
#> $family_type
#> [1] "bernoulli"
#>
#> $trials
#> NULL
#>
#> attr(,"class")
#> [1] "drm_impute_model"
impute_model(score ~ z, family = cumulative_logit())
#> $formula
#> score ~ z
#> <environment: 0x556a9b1d15d8>
#>
#> $family
#> $name
#> [1] "cumulative_logit"
#>
#> $family
#> [1] "cumulative_logit"
#>
#> $n_response
#> [1] 1
#>
#> $dpars
#> [1] "mu"
#>
#> $links
#> mu
#> "identity"
#>
#> attr(,"class")
#> [1] "drm_family"
#>
#> $family_type
#> [1] "ordinal"
#>
#> $trials
#> NULL
#>
#> attr(,"class")
#> [1] "drm_impute_model"
impute_model(habitat ~ z, family = categorical())
#> $formula
#> habitat ~ z
#> <environment: 0x556a9b1d15d8>
#>
#> $family
#> $name
#> [1] "categorical"
#>
#> $family
#> [1] "categorical"
#>
#> $link
#> [1] "baseline_softmax"
#>
#> attr(,"class")
#> [1] "drm_impute_family"
#>
#> $family_type
#> [1] "categorical"
#>
#> $trials
#> NULL
#>
#> attr(,"class")
#> [1] "drm_impute_model"
impute_model(cover ~ z, family = beta())
#> $formula
#> cover ~ z
#> <environment: 0x556a9b1d15d8>
#>
#> $family
#> $name
#> [1] "beta"
#>
#> $family
#> [1] "beta"
#>
#> $n_response
#> [1] 1
#>
#> $dpars
#> [1] "mu" "sigma"
#>
#> $links
#> mu sigma
#> "logit" "log"
#>
#> attr(,"class")
#> [1] "drm_family"
#>
#> $family_type
#> [1] "beta"
#>
#> $trials
#> NULL
#>
#> attr(,"class")
#> [1] "drm_impute_model"
impute_model(cover ~ z, family = zero_one_beta())
#> $formula
#> cover ~ z
#> <environment: 0x556a9b1d15d8>
#>
#> $family
#> $name
#> [1] "zero_one_beta"
#>
#> $family
#> [1] "zero_one_beta"
#>
#> $n_response
#> [1] 1
#>
#> $dpars
#> [1] "mu" "sigma" "zoi" "coi"
#>
#> $links
#> mu sigma zoi coi
#> "logit" "log" "logit" "logit"
#>
#> attr(,"class")
#> [1] "drm_family"
#>
#> $family_type
#> [1] "zero_one_beta"
#>
#> $trials
#> NULL
#>
#> attr(,"class")
#> [1] "drm_impute_model"
impute_model(success ~ z, family = beta_binomial(), trials = trials)
#> $formula
#> success ~ z
#> <environment: 0x556a9b1d15d8>
#>
#> $family
#> $name
#> [1] "beta_binomial"
#>
#> $family
#> [1] "beta_binomial"
#>
#> $n_response
#> [1] 1
#>
#> $dpars
#> [1] "mu" "sigma"
#>
#> $links
#> mu sigma
#> "logit" "log"
#>
#> attr(,"class")
#> [1] "drm_family"
#>
#> $family_type
#> [1] "beta_binomial"
#>
#> $trials
#> trials
#>
#> attr(,"class")
#> [1] "drm_impute_model"
impute_model(abundance ~ z, family = poisson())
#> $formula
#> abundance ~ z
#> <environment: 0x556a9b1d15d8>
#>
#> $family
#>
#> Family: poisson
#> Link function: log
#>
#>
#> $family_type
#> [1] "poisson"
#>
#> $trials
#> NULL
#>
#> attr(,"class")
#> [1] "drm_impute_model"
impute_model(abundance ~ z, family = nbinom2())
#> $formula
#> abundance ~ z
#> <environment: 0x556a9b1d15d8>
#>
#> $family
#> $name
#> [1] "nbinom2"
#>
#> $family
#> [1] "nbinom2"
#>
#> $n_response
#> [1] 1
#>
#> $dpars
#> [1] "mu" "sigma"
#>
#> $links
#> mu sigma
#> "log" "log"
#>
#> attr(,"class")
#> [1] "drm_family"
#>
#> $family_type
#> [1] "nbinom2"
#>
#> $trials
#> NULL
#>
#> attr(,"class")
#> [1] "drm_impute_model"
impute_model(abundance ~ z, family = truncated_nbinom2())
#> $formula
#> abundance ~ z
#> <environment: 0x556a9b1d15d8>
#>
#> $family
#> $name
#> [1] "truncated_nbinom2"
#>
#> $family
#> [1] "truncated_nbinom2"
#>
#> $n_response
#> [1] 1
#>
#> $dpars
#> [1] "mu" "sigma"
#>
#> $links
#> mu sigma
#> "log" "log"
#>
#> attr(,"class")
#> [1] "drm_family"
#>
#> $family_type
#> [1] "truncated_nbinom2"
#>
#> $trials
#> NULL
#>
#> attr(,"class")
#> [1] "drm_impute_model"
impute_model(biomass ~ z, family = lognormal())
#> $formula
#> biomass ~ z
#> <environment: 0x556a9b1d15d8>
#>
#> $family
#> $name
#> [1] "lognormal"
#>
#> $family
#> [1] "lognormal"
#>
#> $n_response
#> [1] 1
#>
#> $dpars
#> [1] "mu" "sigma"
#>
#> $links
#> mu sigma
#> "identity" "log"
#>
#> attr(,"class")
#> [1] "drm_family"
#>
#> $family_type
#> [1] "lognormal"
#>
#> $trials
#> NULL
#>
#> attr(,"class")
#> [1] "drm_impute_model"
impute_model(biomass ~ z, family = Gamma(link = "log"))
#> $formula
#> biomass ~ z
#> <environment: 0x556a9b1d15d8>
#>
#> $family
#>
#> Family: Gamma
#> Link function: log
#>
#>
#> $family_type
#> [1] "gamma"
#>
#> $trials
#> NULL
#>
#> attr(,"class")
#> [1] "drm_impute_model"
impute_model(biomass ~ z, family = tweedie())
#> $formula
#> biomass ~ z
#> <environment: 0x556a9b1d15d8>
#>
#> $family
#> $name
#> [1] "tweedie"
#>
#> $family
#> [1] "tweedie"
#>
#> $n_response
#> [1] 1
#>
#> $dpars
#> [1] "mu" "sigma" "nu"
#>
#> $links
#> mu sigma nu
#> "log" "log" "logit12"
#>
#> attr(,"class")
#> [1] "drm_family"
#>
#> $family_type
#> [1] "tweedie"
#>
#> $trials
#> NULL
#>
#> attr(,"class")
#> [1] "drm_impute_model"