ramhiser / sparsediscrim

Sparse and Regularized Discriminant Analysis in R
Other
15 stars 5 forks source link

Error calculating Q and W_inv #17

Closed ramhiser closed 11 years ago

ramhiser commented 11 years ago

Copied from previous regdiscrim package

In the below email @steincaleb pointed out that there is a mistake in the code to calculate Q and W_inv. This mistake occurs in both the grda.default and update_grda functions.

In equation 14, W sub k inverse has a second term with (1- lambda) and Q sub k also has a (1- lambda) component. However, in your GRDA code, Q and W_inv include lambda instead of (1-lambda) while maintaining all other things the same from your paper. Q <- diag(nk) + alpha[k] * lambda * XU %% tcrossprod(diag(Gamma_inv), XU) W_inv <- alpha[k] * lambda * diag(Gammainv) %% crossprod(XU, solve(Q, XU)) %*% diag(Gamma_inv)

Is this correct, or should your code reflect the paper?