3
$\begingroup$

I have a pandas data frame with 50 columns and 10 rows. The columns represent events and the rows are days. If an event occurs in a day, then the corresponding cell is a "1", else, is a "0".

Since monitoring 50 events is expensive, I have tried to use Factor analysis to find if I can stop monitoring any of the events. I have used the following code:

import pandas as pd
import numpy as np
from sklearn.decomposition import FactorAnalysis

np.random.seed(0)

df = pd.DataFrame(np.random.choice([0, 1], size=(10, 50), p=[0.8, 0.2]))
fa = FactorAnalysis(n_components=10)

df_fa = fa.fit_transform(df)
loadings = fa.components_


print(loadings)
np.savetxt("loadings.csv", loadings, delimiter=";")

Then, if I have understood propperly, now I have to check the 50 columns of loadings and if one has small values in all of its columns, then, that event can be discarted as:

threshold = 0.1

redundant_columns = np.where(np.all(np.abs(loadings) < threshold, axis=0))

Have I understood the process correctly?

$\endgroup$
1
  • $\begingroup$ Several people have correctly pointed out the limitations of FA when there are many more metrics than observations. One suggestion from the literature is to use Partial Least Squares as a workaround. Developed by Wold in 1982 specifically for chemical engineering problems with many, many more metrics than data, there are lots of references out there detailing this technique. $\endgroup$
    – user78229
    Commented Feb 24 at 2:28

2 Answers 2

3
$\begingroup$

Your approach is correct, but it's important to consider the size of your dataset. The results and interpretations you obtain from your data can be greatly influenced by the number of samples you have. With a small amount of data, there's a higher chance that the observed outcomes are due to random chance rather than the actual impact of the variables themselves. These differences tend to diminish as you collect more data.

Regarding setting a threshold for the absolute value of the loadings, it's a useful technique. This threshold helps identify which variables are considered significant and which ones are less influential or redundant. However, it's essential to understand that the choice of threshold, such as 0.1, is somewhat arbitrary.

In Factor Analysis, the absolute value of 0.1 is commonly used as a threshold for determining the significance of factor loadings. Factor loadings represent the relationships between variables and factors, ranging from -1 to 1. These values indicate the strength and direction of the association between variables and factors.

$\endgroup$
3
  • $\begingroup$ Regarding your terminology: in statistics, we typically have a sample of size $n$, not $n$ samples of size 1 (though that is a possibility). $\endgroup$ Commented Feb 23 at 20:24
  • $\begingroup$ Good to know! Thanks for the note Richard! So it would be rephrased as 'the number of datapoints in your sample?' or 'the number of rows in your sample?' $\endgroup$ Commented Feb 23 at 20:29
  • $\begingroup$ Sample size is the most direct name, number of observations or no. of data points or no. of rows are also fine. $\endgroup$ Commented Feb 23 at 20:33
1
$\begingroup$

Several things. First, as @Oscar Flores correctly points out, your sample size of $n = 10$ is very small by factor analysis (FA) standards. For example, Beavers et al. (2019) review commonly cited rules of thumb for exploratory FA (EFA), and the smallest recommended sample size is 150$^1$. Also, by confirmatory FA (CFA) standards, your sample is small as well. For instance, in a review of published studies using CFA, Jackson et al. (2009) found the smallest sample size to be $n = 58$.

Second, sample size issues aside, I would not recommend using a threshold of $\lambda < 0.1$ to select factor loadings, and would instead test whether the loadings' 95% confidence interval (CI) contains the threshold instead, as this approach incorporates sampling variability into the decision process.

Finally, and sample size issues aside again, I would suggest you fit your FA model using tetrachoric correlations, which treat you data as categorical (as opposed to continuous). I say this because, while arguments can be made to treat items as continuous when there are more than two (ordinal) levels (e.g., see Robitzsch, 2020 for more information), seldom do you see it recommended to treat dichotomous data as continuous.

$^1$ Note that these recommendations are not just based on the sample size, but also the subjects-to-variables (STV) ratio (or rows-to-columns ratio), and all STV ratios recommend you have more subjects than columns. Of course, it is still "possible" to obtain results when the ratio is less than 1, I just would not trust them.

References

Beavers, A. S., Lounsbury, J. W., Richards, J. K., Huck, S. W., Skolits, G. J., & Esquivel, S. L. (2019). Practical considerations for using exploratory factor analysis in educational research. Practical Assessment, Research, and Evaluation, 18(1), 6.

Jackson, D. L., Gillaspy Jr, J. A., & Purc-Stephenson, R. (2009). Reporting practices in confirmatory factor analysis: an overview and some recommendations. Psychological methods, 14(1), 6.

Robitzsch, A. (2020, October). Why ordinal variables can (almost) always be treated as continuous variables: Clarifying assumptions of robust continuous and ordinal factor analysis estimation methods. In Frontiers in education (Vol. 5, p. 589965). Frontiers Media SA.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.