A python wrapper for the R function factanal.
Project description
Factanal
Python wrapper replicating the known factor analysis output from the factanal R function. The only supported input is a pandas data frame. Formulas as input are currently not supported. A covariance matrix is always computed from the input data frame. Setting control variables for maximum likelihood estimation is currently not supported.
Further information on R's factanal function for factor analysis: https://www.rdocumentation.org/packages/stats/versions/3.6.2/topics/factanal
More information on the factanal output and examples: https://data.library.virginia.edu/getting-started-with-factor-analysis/
Example
import pandas as pd
import random
from factanal.wrapper import factanal
pdf = pd.DataFrame({"v1": [random.randint(0, 100) for _ in range (30)],
"v2": [random.randint(0, 100) for _ in range (30)],
"v3": [random.randint(0, 100) for _ in range (30)],
"v4": [random.randint(0, 100) for _ in range (30)],
"v5": [random.randint(0, 100) for _ in range (30)],
"v6": [random.randint(0, 100) for _ in range (30)],
"v7": [random.randint(0, 100) for _ in range (30)],
"v8": [random.randint(0, 100) for _ in range (30)]})
fa_res = factanal(pdf, factors=4, scores='regression', rotation='promax',
verbose=True, return_dict=True)
Uniquenesses:
v1 v2 v3 v4 v5 v6 v7 v8
0.861 0.005 0.666 0.005 0.611 0.223 0.812 0.885
Loadings:
Factor1 Factor2 Factor3 Factor4
v1 -0.136 0.326
v2 0.983 0.169 0.104
v3 0.128 0.575
v4 0.999
v5 -0.114 0.199 -0.553
v6 -0.204 -0.825 0.197
v7 -0.264 0.317
v8 0.313 0.106
Factor1 Factor2 Factor3 Factor4
SS loadings 1.127 1.048 0.953 0.807
Proportion Var 0.141 0.131 0.119 0.101
Cumulative Var 0.141 0.272 0.391 0.492
Factor Correlations:
Factor1 Factor2 Factor3 Factor4
Factor1 1.0000 0.0380 -0.0526 0.1918
Factor2 0.0380 1.0000 0.0675 -0.0599
Factor3 -0.0526 0.0675 1.0000 -0.0671
Factor4 0.1918 -0.0599 -0.0671 1.0000
Test of the hypothesis that 4 factors are sufficient.
The chi square statistic is 0.37 on 2 degrees of freedom.
The p-value is 0.833
Installation
pip install factanal
Dependencies
The only dependency is the rpy2 library.
In addition to that, R must be installed on your system and accessible to rpy2.
More information on rpy2: https://rpy2.github.io/doc/latest/html/index.html
Download R here: https://www.r-project.org/
Misc
Factanal for python is MIT licensed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file factanal-0.2.0.tar.gz
.
File metadata
- Download URL: factanal-0.2.0.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eaa8292980654c3db9839716c67c42b5e4fb97fab971be461810510831953a14 |
|
MD5 | 1b88abb756ea7e052f5593a270ad60f8 |
|
BLAKE2b-256 | 591a0ac64022091e25479f53b5d671b3e6cd9624a069fc2cd71ac4e65d29d110 |
File details
Details for the file factanal-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: factanal-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 442e282dddfcf431e9370eca030c79dba468c976ec8e0079002a0e6b9670b6c5 |
|
MD5 | 70f1a815f41b247374e17d295e163ef1 |
|
BLAKE2b-256 | e93ab96b31d7668edf8e78334443a1fa68b53c04aa133dab853b1a037942f302 |