EducationalTestingService / EducationalTestingService/factor_analyzer

random initial values for rotation matrix in GPA rotations

Đang mở
#116 2 bình luận 2 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
6
Fork
1
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Hi all. First, thanks so much to the devs of `factor_analyzer`. It's a fantastic and much needed package!

**Is your feature request related to a problem? Please describe.**

As has been pointed out, the GPA rotation methods often converge to local minima ([Browne, 2001](https://doi.org/10.1207/S15327906MBR3601_05); [Bernaards & Jennrich, 2005](https://doi.org/10.1177/0013164404272507); [Nguyen & Waller, 2022](https://doi.org/10.1177/0013164404272507)). As such, it's been recommended researchers initialize the GPA from many starting values when searching for a global minimum. I'm wondering if the `Rotator` class could be amended in order to allow initializing the GPA from different starting values.

**Describe the solution you'd like**

One simple solution would be for the `Rotator` class to accept a new argument, `random_state`, which defaults to `None`. When `random_state = None`, the rotation matrix is initialized with `np.eye(n_cols)` as is currently implemented ([L326](https://github.com/EducationalTestingService/factor_analyzer/blob/main/factor_analyzer/rotator.py#L326), [L416](https://github.com/EducationalTestingService/factor_analyzer/blob/main/factor_analyzer/rotator.py#L416), [L493](https://github.com/EducationalTestingService/factor_analyzer/blob/main/factor_analyzer/rotator.py#L493)). When a user specifies a seed, however, the rotation matrix is initialized as a random orthogonal matrix from [`scipy.stats.ortho_group`](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.ortho_group.html). That is,:

```python
# initialize the rotation matrix
_, n_cols = loadings.shape
if self.random_state == None:
rotation_matrix = np.eye(n_cols)
else:
rotation_matrix = sp.stats.ortho_group(dim=n_cols, seed=self.random_state).rvs()
```

A solution like the above could be added to the [`Rotator._oblique`](https://github.com/EducationalTestingService/factor_analyzer/blob/main/factor_analyzer/rotator.py#L293), [`Rotator._orthogonal`](https://github.com/EducationalTestingService/factor_analyzer/blob/main/factor_analyzer/rotator.py#L382), [`Rotator._varimax`](https://github.com/EducationalTestingService/factor_analyzer/blob/main/factor_analyzer/rotator.py#L462) methods (and any others that I missed).

Apologies in advance if the above is already possible and I've simply missed how. If the above sounds like it may be useful, I'd be happy to attempt a PR.

All the best,
Sam (@szorowi1)

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.