# Is there a way to calculate conditional probability for linear discriminant analyses in R?

I am performing a canonial variates analysis (i.e., a linear discriminant analysis with 3 or more categories) using the lda() funtion in the MASS package in R. I had been reporting the likelihood of a particular observation pertaining to a particular category as a posterior probability, but my supervisor said they would like the conditional probability to be included as well similar to some of their previous work. When I asked how they did it, they said that used JMP or SPSS and it just automatically returned the values for them.

I do not have access to either of these programs, and trying to export the dataset and re-running the CVA (which is analyzed beforehand in R and those results are what go into the CVA) seems counterintuitive. I was wondering if there was any way to calculate conditional probability for a canonical variates analysis in R, preferably a method that can be applied to the MASS package. I looked around online and on StackOverflow and I couldn't find anything about calculating conditional probabilities in lda() using MASS.

• Is the predict.lda method provided by MASS not sufficient? It provides posterior probabilities already. – Neal Fultz Jun 29 '20 at 21:10
• @NealFultz The person I am working under wants both posterior probabilities AND conditional probabilities, mostly because when they performed similar analyses they had access to JMP and thus both values were provided as part of the built-in function of that program. I am not even sure if conditional probabilities are appropriate for a CVA. – user2352714 Jun 30 '20 at 1:35
• I see. You could edit the predict.lda function and edit out the one line where it does the normalizing constant, and also pass it 1 as the prior. – Neal Fultz Jun 30 '20 at 3:37