| predict.multilpa | R Documentation |
Evaluates the fitted mixture on new rows: the E-step of the fit, at its estimates, applied to data it has not seen. Rows go through the fit's own preparation – the same categorical levels, the same centering, the same missing-data handling – so a prediction on the training data reproduces the fit's own posteriors exactly.
## S3 method for class 'multilpa'
predict(object, newdata = NULL, type = c("class", "posterior", "density"), ...)
object |
A fit from |
newdata |
|
type |
|
... |
Unused. |
A base data.frame with one row per row of newdata: row (its
position in newdata), the id column for a two-level fit, and
for "class": profile (0 is the noise component of a
noise = TRUE fit) and its posterior, and for two-level fits
group_class and group_posterior;
for "posterior": those columns and one probability_profile_k
column per profile (and probability_noise);
for "density": log_density.
A two-level model classifies a row using its group: the group class is
inferred from all of that group's rows, and it shifts the row's profile
probabilities. The groups in newdata (the fit's id column) are treated
as new groups, each classified from its own rows alone, which is the case
of applying a model to a new cohort. A single-level fit, or a fit given
id = NULL, treats every row as its own unit.
latents_bad_data when newdata lacks an indicator or the id column,
has a missing value the fit cannot handle (missing = "error"), a
category the fit never saw, or a non-numeric continuous indicator.
activity <- c("browse", "lectures", "forum_read")
training <- subset(course_engagement, student <= 60)
fit <- multilpa(training, activity, id = "student", n_profiles = 2,
n_group_classes = 2, n_starts = 2, seed = 1)
new_students <- subset(course_engagement, student > 100)
head(predict(fit, new_students))
head(predict(fit, new_students, type = "density"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.