Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add orthomax factor rotations #130

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e271af6
Add orthomax factor rotations
cyianor Oct 21, 2020
40067c6
Make backwards-compatible with Julia 1.0
cyianor Oct 21, 2020
b7a067e
Add documentation for `miniter`
cyianor Oct 21, 2020
caead01
Fixed small mistake
cyianor Oct 21, 2020
afbb5a4
Adjusted indent
cyianor Oct 21, 2020
80e7316
Better exception use/getters for loadings/rotation
cyianor Oct 21, 2020
c0e2389
Created some tests
cyianor Oct 21, 2020
2e0bfc3
Convenience functions for common rotations
cyianor Oct 22, 2020
855ee0e
Corrected name of test set for factor rotations
cyianor Oct 22, 2020
275d34a
Convenience wrappers for common Orthomax rotations
cyianor Oct 22, 2020
e51ede1
added vscode
cyianor Oct 14, 2021
da3ea9b
Merge branch 'master' of https://github.com/JuliaStats/MultivariateSt…
cyianor Dec 21, 2021
2f37efd
Merge branch 'JuliaStats-master'
cyianor Dec 21, 2021
9327d9b
Remove vscode
cyianor Dec 21, 2021
cbb0687
Add orthomax factor rotations
cyianor Mar 2, 2022
c266980
Make backwards-compatible with Julia 1.0
cyianor Oct 21, 2020
764512e
Add documentation for `miniter`
cyianor Oct 21, 2020
c3c8bd9
Fixed small mistake
cyianor Oct 21, 2020
3dcfb22
Adjusted indent
cyianor Oct 21, 2020
d00ceb5
Better exception use/getters for loadings/rotation
cyianor Oct 21, 2020
5f20392
Created some tests
cyianor Mar 2, 2022
975782f
Convenience functions for common rotations
cyianor Oct 22, 2020
3c5cd0c
Corrected name of test set for factor rotations
cyianor Oct 22, 2020
0d84841
Convenience wrappers for common Orthomax rotations
cyianor Oct 22, 2020
4d060dd
Merge branch 'master' of https://github.com/Cyianor/MultivariateStats.jl
cyianor Mar 3, 2022
f468367
Commit to merge upstream changes
cyianor Jul 4, 2022
93e6825
Merge branch 'master' of github.com:JuliaStats/MultivariateStats.jl
cyianor Jul 4, 2022
5f95246
Translation of GPA ortho rotations from R code
cyianor Jul 4, 2022
588be72
First translation of GPA oblique rotations from R code
cyianor Jul 4, 2022
434d484
Improved interface using dispatch on types
cyianor Jul 5, 2022
0211a3a
Add interface for statistical models
cyianor Jul 5, 2022
8c206d9
Adress code review
cyianor Jul 25, 2022
10f6949
latest changes
cyianor Jan 19, 2024
2129eba
Merge remote-tracking branch 'upstream/master'
cyianor Jan 19, 2024
fc49ff7
version dependent import
cyianor Jan 19, 2024
9eca2dc
convert to old style keyword arguments
cyianor Jan 19, 2024
21c6a3a
improved documentation
cyianor Jan 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@ if Base.HOME_PROJECT[] !== nothing
end

makedocs(
sitename = "MultivariateStats.jl",
modules = [MultivariateStats],
pages = ["Home"=>"index.md",
"whiten.md",
"lreg.md",
"lda.md",
"pca.md",
"ica.md",
"cca.md",
"fa.md",
"mds.md",
"Development"=>"api.md"]
sitename="MultivariateStats.jl",
modules=[MultivariateStats],
pages=["Home" => "index.md",
"whiten.md",
"lreg.md",
"lda.md",
"pca.md",
"ica.md",
"cca.md",
"fa.md",
"facrot.md",
"mds.md",
"Development" => "api.md"]
)

deploydocs(
repo = "github.com/JuliaStats/MultivariateStats.jl.git"
repo="github.com/JuliaStats/MultivariateStats.jl.git"
)
85 changes: 85 additions & 0 deletions docs/src/facrot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Factor Rotation

[Factor rotations](https://en.wikipedia.org/wiki/Factor_analysis#Rotation_methods)
are used for post-processing of a factor matrix obtained by
[`FactorAnalysis`](@ref) or [`PCA`](@ref).

Let ``L`` be a matrix of factor loadings. Two common methods of factor rotation[^1]
are typically considered:
- A matrix ``\Lambda`` is an *orthogonal rotation*[^2] of ``L`` if
``\Lambda = L R`` for some orthogonal matrix ``R``, i.e. ``R^{-1} = R^\top``.
- A matrix ``\Lambda`` is an *oblique rotation*[^3] of ``L`` if
``\Lambda = L (R')^{-1}`` for some matrix ``R`` that has columns of length 1.

The matrix ``R`` is chosen by minimizing a factor rotation criterion
``Q(\Lambda)``. This package uses a gradient projection algorithm[^1]
to minimize the criterion ``Q``.

## Applying factor rotations

This package defines the function [`rotate`](@ref) which can be used to rotate
a matrix of loadings.

```@docs
rotate(::AbstractMatrix, ::FactorRotationCriterion{T}) where {T<:FactorRotationMethod}
FactorRotation
loadings
rotation
```

[`rotate!`](@ref) modifies the supplied model in place.

```@docs
rotate!(::FactorAnalysis, ::FactorRotationCriterion{T}) where {T<:FactorRotationMethod}
rotate!(::PCA, ::FactorRotationCriterion{T}) where {T<:FactorRotationMethod}
```

## Factor rotation methods

There are two types of factor rotations: *orthogonal* and *oblique*.
Which type of rotation method should be used can be chosen by setting the
appropriate subtype of [`FactorRotationMethod`](@ref).

```@docs
FactorRotationMethod
Orthogonal
Oblique
```

## Factor rotation criteria

The actual factor rotation criteria are described by subtypes of
[`FactorRotationCriterion`](@ref) and many parametrized forms of standard
rotation methods are provided.

```@docs
FactorRotationCriterion{T} where {T<:FactorRotationMethod}
```

Sometimes, factor rotation criteria can be used as orthogonal and oblique methods.

```@docs
CrawfordFerguson{T} where {T<:FactorRotationMethod}
Oblimin{T} where {T<:FactorRotationMethod}
```

### Orthogonal factor rotation criteria

```@docs
Varimax
Quartimax
MinimumEntropy
```

### Oblique factor rotation criteria

```@docs
Quartimin
```

## References

[^1] Bernaards, C.A. and Jennrich, R.I. (2005) Gradient Projection Algorithms and Software for Arbitrary Rotation Criteria in Factor Analysis. Educational and Psychological Measurement, 65, 676-696. doi [10.1177/0013164404272507](https://doi.org/10.1177/0013164404272507)
[^2] Jennrich, R. I. (2001). A simple general procedure for orthogonal rotation. Psychometrika, 66, 289-306. doi [10.1007/BF02294840](https://doi.org/10.1007/BF02294840)
[^3] Jennrich, R. I. (2002). A simple general method for oblique rotation. Psychometrika, 67, 7-19. doi [10.1007/BF02294706](https://doi.org/10.1007/BF02294706)

2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ end
[MultivariateStats.jl](https://github.com/JuliaStats/MultivariateStats.jl) is a Julia package for multivariate statistical analysis. It provides a rich set of useful analysis techniques, such as PCA, CCA, LDA, ICA, etc.

```@contents
Pages = ["whiten.md", "lreg.md", "lda.md", "pca.md", "ica.md", "cca.md", "fa.md", "mds.md", "api.md"]
Pages = ["whiten.md", "lreg.md", "lda.md", "pca.md", "ica.md", "cca.md", "fa.md", "facrot.md", "mds.md", "api.md"]
Depth = 2
```

Expand Down
26 changes: 25 additions & 1 deletion src/MultivariateStats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ module MultivariateStats
import Base: length, size, show
import StatsAPI: fit, predict, coef, weights, dof, r2
import LinearAlgebra: eigvals, eigvecs

@static if VERSION ≥ v"1.5"
import LinearAlgebra: rotate!
end

export

Expand Down Expand Up @@ -105,7 +109,26 @@ module MultivariateStats
FactorAnalysis, # Type: the Factor Analysis model

faem, # EM algorithm for factor analysis
facm # CM algorithm for factor analysis
facm, # CM algorithm for factor analysis

## facrot
FactorRotationMethod, # Type: a factor rotation method
Orthogonal, # Type: Orthogonal factor rotation method
Oblique, # Type: Oblique factor rotation method

FactorRotationCriterion, # Type: a factor rotation criterion
CrawfordFerguson, # Type: Crawford-Fergusion rotation criteria
Varimax, # Type: Varimax rotation criterion
Quartimax, # Type: Quartimax rotation criterion
MinimumEntropy, # Type: MinimumEntropy rotation criterion
Oblimin, # Type: Oblimin rotation criteria
Quartimin, # Type: Quartimin rotation criterion

FactorRotation, # Type: Result of a general factor rotation
rotation, # Extract rotation matrix

rotate, # Rotate factors
rotate! # Rotate in-place

## source files
include("types.jl")
Expand All @@ -121,6 +144,7 @@ module MultivariateStats
include("lda.jl")
include("ica.jl")
include("fa.jl")
include("facrot.jl")

## deprecations
@deprecate indim(f) size(f,1)
Expand Down
Loading
Loading