R: Prediction for a 'PLNmixturefit' object

predict.PLNmixturefit {PLNmodels} | R Documentation

## Prediction for a `PLNmixturefit` object

### Description

Predict either posterior probabilities for each group or latent positions based on new samples

### Usage

    ## S3 method for class 'PLNmixturefit'
    predict(
      object,
      newdata,
      type = c("posterior", "response", "position"),
      prior = matrix(rep(1/object$k, object$k), nrow(newdata), object$k, byrow = TRUE),
      control = list(),
      ...
    )

### Arguments

`object` | an R6 object with class `PLNmixturefit`
`newdata` | A data frame in which to look for variables, offsets and counts with which to predict.
`type` | The type of prediction required. The default `posterior` are posterior probabilities for each group , `response` is the group with maximal posterior probability and `latent` is the averaged latent in the latent space, with weights equal to the posterior probabilities.
`prior` | User-specified prior group probabilities in the new data. The default uses a uniform prior.
`control` | a list for controlling the optimization. See `PLN()` for details.
`...` | additional parameters for S3 compatibility. Not used

### Value

A matrix of posterior probabilities for each group (if type = "posterior"), a matrix of (average) position in the latent space (if type = "position") or a vector of predicted groups (if type = "response").

### Examples

    data(trichoptera)
    trichoptera <- prepare_data(trichoptera$Abundance, trichoptera$Covariate)
    myPLN <- PLNmixture(Abundance ~ 1 + offset(log(Offset)),
               data = trichoptera, control_main = list(iterates = 0))  %>% getBestModel()
    predict(myPLN, trichoptera, "posterior")
    predict(myPLN, trichoptera, "position")
    predict(myPLN, trichoptera, "response")

[Package PLNmodels version 0.11.4 Index]