# predict.lcda: Predict method for Latent Class Discriminant Analysis (LCDA) In lcda: Latent Class Discriminant Analysis

## Description

Classifies new observations using the parameters determined by the `lcda`-function.

## Usage

 ```1 2``` ```## S3 method for class 'lcda' predict(object, newdata, ...) ```

## Arguments

 `object` Object of class `lcda2`. `newdata` Data frame of cases to be classified. `...` Further arguments are ignored.

## Details

Posterior probabilities for new observations using parameters determined by the `lcda`-function are computed. The classification of the new data is done by the Bayes decision function.

## Value

A list with components:

 `class` Vector (of class `factor`) of classifications. `posterior` Posterior probabilities for the classes. For details of computation see `lcda`.

## Author(s)

Michael B\"ucker

`lcda`, `cclcda`, `predict.cclcda`, `cclcda2`, `predict.cclcda2`, `poLCA`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42``` ```# response probabilites for class 1 probs1 <- list() probs1[] <- matrix(c(0.7,0.1,0.1,0.1,0.1,0.7,0.1,0.1), nrow=2, byrow=TRUE) probs1[] <- matrix(c(0.1,0.7,0.1,0.1,0.1,0.1,0.7,0.1), nrow=2, byrow=TRUE) probs1[] <- matrix(c(0.1,0.1,0.7,0.1,0.1,0.1,0.1,0.7), nrow=2, byrow=TRUE) probs1[] <- matrix(c(0.1,0.1,0.1,0.7,0.7,0.1,0.1,0.1), nrow=2, byrow=TRUE) # response probabilites for class 2 probs2 <- list() probs2[] <- matrix(c(0.1,0.1,0.7,0.1,0.1,0.1,0.1,0.7), nrow=2, byrow=TRUE) probs2[] <- matrix(c(0.1,0.1,0.1,0.7,0.7,0.1,0.1,0.1), nrow=2, byrow=TRUE) probs2[] <- matrix(c(0.7,0.1,0.1,0.1,0.1,0.7,0.1,0.1), nrow=2, byrow=TRUE) probs2[] <- matrix(c(0.1,0.7,0.1,0.1,0.1,0.1,0.7,0.1), nrow=2, byrow=TRUE) # generation of data simdata1 <- poLCA.simdata(N = 500, probs = probs1, nclass = 2, ndv = 4, nresp = 4, missval = FALSE) simdata2 <- poLCA.simdata(N = 500, probs = probs2, nclass = 2, ndv = 4, nresp = 4, missval = FALSE) data1 <- simdata1\$dat data2 <- simdata2\$dat data <- cbind(rbind(data1, data2), rep(c(1,2), each=500)) names(data) <- "grouping" data <- data[sample(1:1000),] grouping <- data[] data <- data[,1:4] # lcda-procedure object <- lcda(data, grouping=grouping, m=2) pred.class <- predict(object, newdata=data)\$class sum(pred.class==grouping)/length(pred.class) ```