predict.FactorHet {FactorHet} | R Documentation |
Predict after using FactorHet
Description
Predicted values for choosing particular profiles based on
FactorHet
.
Usage
## S3 method for class 'FactorHet'
predict(
object,
newdata = NULL,
type = "posterior",
by_group = FALSE,
return = "prediction",
...
)
Arguments
object |
A model estimated using |
newdata |
A dataset on which to generate predictions. The default,
|
type |
An argument that specifies how to deal with group-membership
probabilities when making predictions. The default is |
by_group |
A logical value as to whether the predictions should be
returned for each group or whether a weighted averaged based on the group
membership probabilities (specified by |
return |
A character value that determines the type of prediction
return. The default is |
... |
Miscellaneous options used internally and not documented. |
Value
Returns an estimate of the predicted probability of choosing a profile for each observation. "Arguments" outlines different behavior if certain options are chosen.
Examples
data(immigration)
set.seed(1)
# Fit a model once for simplicity
fit <- FactorHet(Chosen_Immigrant ~ Plans + Ed + Country,
design = immigration, lambda = 1e-4,
# Randomly initialize, do only one iteration for speed
init = FactorHet_init(nrep = 1),
control = FactorHet_control(init = 'random_member'),
K = 2, group = ~ CaseID, task = ~ contest_no,
choice_order = ~ choice_id)
immigration$pred_FH <- predict(fit)