predict.opsr {OPSR} | R Documentation |
Obtains predictions for the selection process (probabilities), the outcome process, or returns the inverse mills ratio. Handles also log-transformed outcomes.
## S3 method for class 'opsr'
predict(
object,
newdata,
group,
counterfact = NULL,
type = c("response", "unlog-response", "prob", "mills"),
...
)
object |
an object of class |
newdata |
an optional data frame in which to look for variables used in
|
group |
predict outcome of this group (regime). |
counterfact |
counterfactual group. |
type |
type of prediction. Can be abbreviated. See 'Details' section for more information. |
... |
further arguments passed to or from other methods. |
Elements are NA_real_
if the group
does not correspond to the observed
regime (selection outcome). This ensures consistent output length.
If the type
argument is "response"
then the continuous outcome is predicted.
Use "unlog-response"
if the outcome response was log-transformed during estimation.
"prob"
returns the probability vector of belonging to group
and "mills"
returns the inverse mills ratio.
a vector of length nrow(newdata)
(or data used during estimation).
sim_dat <- opsr_simulate()
dat <- sim_dat$data
model <- ys | yo ~ xs1 + xs2 | xo1 + xo2
fit <- opsr(model, dat)
p <- predict(fit, group = 1, type = "response")
fit_log <- update(fit, . | log(yo) ~ .)
p_unlog <- predict(fit, group = 1, type = "unlog-response")