I thought they use discriminant analysis as discribed e.g. in chapter 4.4. in James et. al. "An Introduction to Statistical Learning with Applications in R". But after input from this article and this SO-question including reproducible examples it seems that
- a matrix model is calculated in
ans <- .External2(C_modelmatrix, t, data)(inmodel.matrix.default) - the matrix model goes into
z <- .Call(C_Cdqrls, x, y, tol, FALSE)and I did not expect, that linear regression and discriminant analysis are the same on the maths level.
From here it seems, R can always use the standard algorithm based on qr-factorization.
Is that true?
Comment: R's help ?lm references Chambers, J. M. (1992) Linear models. Chapter 4 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole. But I do not have access to the book.
lmcallslm.fit(line 68), thenlm.fitcalls.Call(C_Cdqrls, ...)in line 114. Thus "the work" is done in a C function calledCdqrls. There I could not check, as I could not find the code. However, as stated in the links above, this function seems to use qr-decomposition, which I did not expect in the case of factors present. – Christoph Jul 10 '19 at 15:50