You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because the n_factors function got moved (and improved) to the parameters package, some of you realized that the figure featured here, showing the eigenvalues, the percentage of variance explained etc. was not available.
It turns out that this plot wasn't the best way to represent the results of n_factors; as the explained variance and the eigenvalues that is shows are extracted from one particular "dimension-reduction technique" (such as PCA or FA). But n_factors actually tries to estimate the optimal number of factors across different dimension reduction methods, so the two aren't really part of the same "step".
That said, here's a way of plotting them together with ggplot with multiple y axes:
library(dplyr)
library(ggplot2)
library(parameters)
library(effectsize)
library(see)
data<- summary(parameters::n_factors(attitude))
rez_pca<- summary(parameters::principal_components(attitude, n=4))
data$Eigenvalues<- as.numeric(rez_pca[1, -1]) # First rowdata$VarianceExplained<- as.numeric(rez_pca[3, -1]) # Third row# Rescale everything to eigenvalue scale - as this will our principal y-axisnewrange<- c(min(data$Eigenvalues), max(data$Eigenvalues))
data$Z_VarianceExplained<-effectsize::change_scale(data$VarianceExplained, to=newrange, range= c(0, 1))
data$Z_n_Methods<-effectsize::change_scale(data$n_Methods, to=newrange)
# Plotdata %>%
ggplot(aes(x=n_Factors, y=Eigenvalues)) +
geom_area(aes(y=Z_n_Methods), fill="orange", alpha=0.5) +
geom_line(aes(y=Z_VarianceExplained), color="red") +
geom_line(aes(y=Eigenvalues), color="blue") +
geom_hline(aes(yintercept=1), linetype="dotted") +
scale_y_continuous("Eingenvalue (blue)",
sec.axis= sec_axis(~./ max(data$Eigenvalues),
name="Proportion of Explained Variance (red)",
labels=scales::percent,)) +see::theme_modern()
Because the
n_factors
function got moved (and improved) to the parameters package, some of you realized that the figure featured here, showing the eigenvalues, the percentage of variance explained etc. was not available.It turns out that this plot wasn't the best way to represent the results of n_factors; as the explained variance and the eigenvalues that is shows are extracted from one particular "dimension-reduction technique" (such as PCA or FA). But n_factors actually tries to estimate the optimal number of factors across different dimension reduction methods, so the two aren't really part of the same "step".
That said, here's a way of plotting them together with ggplot with multiple y axes:
Created on 2021-02-21 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: