set_dv_probs {xpose.xtras} | R Documentation |
Set probability columns for categorical endpoints
Description
For categorical DVs or similar endpoints (such as censoring
flag columns, like BLQ
), this function allows probability
columns to be defined for each level.
Usage
set_dv_probs(
xpdb,
.problem = NULL,
...,
.dv_var = NULL,
.handle_missing = c("quiet", "warn", "error")
)
Arguments
xpdb |
< |
.problem |
< |
... |
Formulas where LHS are levels or pseudo-functions (see Details), and RHS are columns with probabilities of those levels. |
.dv_var |
< |
.handle_missing |
< |
Details
The same probability cannot be assigned to multiple values. Pseudo-functions can be used, or
new columns can be created to overcome this limitation. The available pseudo-functions should
be written like ge(value)
(for >=
), gt(value)
(for >
), etc. These comparison names
are those used in Perl, Fortran and many other languages. The function eq()
should not be used,
but it will be ignored either way; equivalence is implied with the base syntax.
Value
<xp_xtras
> object with updated probabilities
Examples
pkpd_m3 %>%
# Not necessary, but correct to set var type before using this
set_var_types(.problem=1, catdv=BLQ, dvprobs=LIKE) %>%
# Set var type. Warnings can be helpful unless an inverse likelihood column is available
set_dv_probs(.problem=1, 1~LIKE, .dv_var = BLQ, .handle_missing = "warn") %>%
list_vars()
# Same as above with demo of inverse column
pkpd_m3 %>%
xpose::mutate(INVLIKE = 1-LIKE) %>%
set_var_types(.problem=1, catdv=BLQ, dvprobs=c(LIKE,INVLIKE)) %>%
# Note no warning
set_dv_probs(.problem=1, 1~LIKE, 0~INVLIKE, .dv_var = BLQ, .handle_missing = "warn")%>%
list_vars()
# With categorical model
vismo_pomod %>%
# Update var types
set_var_types(.problem=1, catdv=DV, dvprobs=matches("^P\\d+$")) %>%
# Warning (as noted), does not recognize 3 is covered implicitly. That's ok!
set_dv_probs(.problem=1, 0~P0,1~P1,ge(2)~P23, .handle_missing = "warn")%>%
list_vars()
# Same as above, but...
vismo_pomod %>%
set_var_types(.problem=1, catdv=DV, dvprobs=matches("^P\\d+$")) %>%
# Default is to not bother users with a warning
set_dv_probs(.problem=1, 0~P0,1~P1,ge(2)~P23)%>%
list_vars()