1

I'm having issue finding code for calculating standardized loadings for LDA, I wrote a code for it, but I'm not sure is this the correct way to standardize the loadings.

lda.fit <- lda(Species~., data=iris)
print(summary(lda.fit))

loadings <- lda.fit$scaling

print(loadings)
print(colSums(loadings^2))

standardize.loadings <- function(loadings) {
    col.ss <- colSums(loadings^2)
    sweep(loadings,2,sqrt(col.ss),"/")
}
standardized.loadings <- standardize.loadings(loadings)

print(standardized.loadings)
print(colSums(standardized.loadings^2))

In this answer there are shown both unstandardized and standardized loadings, but there is no description how they are calculated and my function is not producing the correct results, instead it is producing the eigenvector values

This is the output

                    LD1         LD2
Sepal.Length  0.8293776  0.02410215
Sepal.Width   1.5344731  2.16452123
Petal.Length -2.2012117 -0.93192121
Petal.Width  -2.8104603  2.83918785

     LD1      LD2 
15.78649 13.61520 

                    LD1          LD2
Sepal.Length  0.2087418  0.006531964
Sepal.Width   0.3862037  0.586610553
Petal.Length -0.5540117 -0.252561540
Petal.Width  -0.7073504  0.769453092

LD1 LD2 
  1   1 

0 Answers0