# predict.cclcda2: Predict method for Common Components Latent Class... In lcda: Latent Class Discriminant Analysis

## Description

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

## Usage

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

## Arguments

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

## Details

Posterior probabilities for new observations using parameters determined by the `cclcda2`-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 `cclcda2`.

## Author(s)

Michael B\"ucker

`cclcda2`, `lcda`, `predict.lcda`, `cclcda`, `predict.cclcda`, `poLCA`

## Examples

 ``` 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 43 44 45 46 47 48 49``` ```# response probabilites probs1 <- list() probs1[[1]] <- matrix(c(0.7,0.1,0.1,0.1,0.1,0.7,0.1,0.1, 0.1,0.1,0.7,0.1,0.1,0.1,0.1,0.7), nrow=4, byrow=TRUE) probs1[[2]] <- matrix(c(0.1,0.7,0.1,0.1,0.1,0.1,0.7,0.1, 0.1,0.1,0.1,0.7,0.7,0.1,0.1,0.1), nrow=4, byrow=TRUE) probs1[[3]] <- matrix(c(0.1,0.1,0.7,0.1,0.1,0.1,0.1,0.7, 0.7,0.1,0.1,0.1,0.1,0.7,0.1,0.1), nrow=4, byrow=TRUE) probs1[[4]] <- matrix(c(0.1,0.1,0.1,0.7,0.7,0.1,0.1,0.1, 0.1,0.7,0.1,0.1,0.1,0.1,0.7,0.1), nrow=4, byrow=TRUE) prior <- c(0.5,0.5) wmk <- matrix(c(0.45,0.45,0.05,0.05,0.05,0.05,0.45,0.45), ncol=4, nrow=2, byrow=TRUE) wkm <- apply(wmk*prior, 2, function(x) x/sum(x)) # generation of training data data_temp <- poLCA.simdata(N = 1000, probs = probs1, nclass = 2, ndv = 4, nresp = 4, P=rep(0.25,4)) data <- data_temp\$dat lclass <- data_temp\$trueclass grouping <- numeric() for (i in 1:length(lclass)) { grouping[i] <- sample(c(1,2),1, prob=wkm[,lclass[i]]) } # generation of test data data_temp <- poLCA.simdata(N = 500, probs = probs1, nclass = 2, ndv = 4, nresp = 4, P=rep(0.25,4)) data.test <- data_temp\$dat lclass <- data_temp\$trueclass grouping.test <- numeric() for (i in 1:length(lclass)) { grouping.test[i] <- sample(c(1,2),1, prob=wkm[,lclass[i]]) } # cclcda2-procedure object <- cclcda2(data, grouping, m=4) pred <- predict(object, data.test)\$class 1-(sum(pred==grouping.test)/500) ```

lcda documentation built on May 2, 2019, 8:50 a.m.