Documentation
¶
Overview ¶
fa/GPArotation_GPFoblq.go
fa/GPArotation_GPForth.go
fa/GPArotation_vgQ_bentler.go
fa/GPArotation_vgQ_geomin.go
fa/GPArotation_vgQ_oblimin.go
fa/GPArotation_vgQ_quartimax.go
fa/GPArotation_vgQ_quartimin.go
fa/GPArotation_vgQ_simplimax.go
fa/GPArotation_vgQ_target.go
fa/GPArotation_vgQ_varimax.go
fa/fa.go
fa/factor2cluster.go
fa/kaiser_varimax.go
fa/psych_Promax.go
fa/psych_faRotations.go
fa/psych_fac.go
fa/psych_pinv.go
fa/psych_smc.go
fa/psych_target_rot.go
Index ¶
- func BentlerQ(loadings *mat.Dense, normalize bool, eps float64, maxIter int) map[string]any
- func BentlerT(loadings *mat.Dense, normalize bool, eps float64, maxIter int) map[string]any
- func CorrelationMatrix(data *mat.Dense) *mat.Dense
- func CorrelationMatrixPairwise(data *mat.Dense) *mat.Dense
- func CovarianceMatrix(data *mat.Dense) *mat.Dense
- func CovarianceMatrixPairwise(data *mat.Dense) *mat.Dense
- func FaRotations(loadings *mat.Dense, r *mat.Dense, rotate string, hyper float64, ...) any
- func Factor2Cluster(loadings *mat.Dense, opts *Factor2ClusterOptions) *mat.Dense
- func Factor2ClusterSimple(loadings *mat.Dense) *mat.Dense
- func GPFoblq(A *mat.Dense, Tmat *mat.Dense, normalize bool, eps float64, maxit int, ...) (map[string]any, error)
- func GPForth(A *mat.Dense, Tmat *mat.Dense, normalize bool, eps float64, maxit int, ...) (map[string]any, error)
- func GeominQ(loadings *mat.Dense, normalize bool, eps float64, maxIter int, delta float64) map[string]any
- func GeominT(loadings *mat.Dense, normalize bool, eps float64, maxIter int, delta float64) map[string]any
- func KaiserVarimax(A *mat.Dense, normalize bool, maxIter int, epsilon float64) (*mat.Dense, error)
- func KaiserVarimaxWithRotationMatrix(A *mat.Dense, normalize bool, maxIter int, epsilon float64) (*mat.Dense, *mat.Dense, error)
- func NormalizingWeight(A *mat.Dense, normalize bool) *mat.VecDense
- func Oblimin(loadings *mat.Dense, normalize bool, eps float64, maxIter int, gamma float64) map[string]any
- func ParseRotationResult(res any) (loadings, rotmat, phi *mat.Dense, f float64, ok bool)
- func Pinv(X *mat.Dense, tol float64) (*mat.Dense, error)
- func Promax(x *mat.Dense, m int, normalize bool) map[string]any
- func Quartimax(loadings *mat.Dense, normalize bool, eps float64, maxIter int) map[string]any
- func Quartimin(loadings *mat.Dense, normalize bool, eps float64, maxIter int) map[string]any
- func Rotate(loadings *mat.Dense, method string, opts *RotOpts) (*mat.Dense, *mat.Dense, *mat.Dense, bool, error)
- func RotateWithDiagnostics(loadings *mat.Dense, method string, opts *RotOpts) (*mat.Dense, *mat.Dense, *mat.Dense, bool, map[string]interface{}, error)
- func SMC(r *mat.Dense, isCorr bool) (*mat.VecDense, error)
- func Simplimax(loadings *mat.Dense, normalize bool, eps float64, maxIter int, k int) map[string]any
- func Smc(r *mat.Dense, opts *SmcOptions) (*mat.VecDense, map[string]interface{})
- func TargetRot(x *mat.Dense, keys *mat.Dense) (loadings, rotmat, Phi *mat.Dense, err error)
- func TargetRotWithMask(x *mat.Dense, keys *mat.Dense, mask *mat.Dense) (loadings, rotmat, Phi *mat.Dense, diagnostics map[string]interface{}, ...)
- func Varimax(loadings *mat.Dense, normalize bool, eps float64, maxIter int) map[string]any
- func VgQOblimin(L *mat.Dense, gamma float64) (*mat.Dense, float64, error)
- type FacOptions
- type FacResult
- type Factor2ClusterOptions
- type RotOpts
- type SmcOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BentlerQ ¶
BentlerQ performs Bentler's criterion rotation (oblique). Mirrors GPArotation::bentlerQ
func CorrelationMatrix ¶
CorrelationMatrix computes correlation matrix from data matrix This is a simplified version - full implementation would handle NAs
func CorrelationMatrixPairwise ¶
CorrelationMatrixPairwise computes correlation matrix using pairwise complete observations
func CovarianceMatrix ¶
CovarianceMatrix computes covariance matrix from data matrix
func CovarianceMatrixPairwise ¶
CovarianceMatrixPairwise computes covariance matrix using pairwise complete observations
func FaRotations ¶
func FaRotations(loadings *mat.Dense, r *mat.Dense, rotate string, hyper float64, nRotations int) any
FaRotations performs rotation selection with optional random restarts.
func Factor2Cluster ¶
func Factor2Cluster(loadings *mat.Dense, opts *Factor2ClusterOptions) *mat.Dense
Factor2Cluster creates a cluster structure from factor loadings. Mirrors GPArotation::factor2cluster exactly
For each variable, assign it to the factor with the highest absolute loading if that loading exceeds the cut threshold. Otherwise, assign to no cluster (0).
func Factor2ClusterSimple ¶
Factor2ClusterSimple is a backward-compatible wrapper for Factor2Cluster
func GPFoblq ¶
func GPFoblq(A *mat.Dense, Tmat *mat.Dense, normalize bool, eps float64, maxit int, method string, gamma float64) (map[string]any, error)
GPFoblq performs oblique GPA rotation. Transliteration of GPArotation::GPFoblq from R.
func GPForth ¶
func GPForth(A *mat.Dense, Tmat *mat.Dense, normalize bool, eps float64, maxit int, method string) (map[string]any, error)
GPForth performs orthogonal rotation using GPA. Mirrors GPArotation::GPForth exactly
func GeominQ ¶
func GeominQ(loadings *mat.Dense, normalize bool, eps float64, maxIter int, delta float64) map[string]any
GeominQ performs geomin rotation (oblique). Mirrors GPArotation::geominQ
func GeominT ¶
func GeominT(loadings *mat.Dense, normalize bool, eps float64, maxIter int, delta float64) map[string]any
GeominT performs geomin rotation. Mirrors GPArotation::geominT
func KaiserVarimax ¶
KaiserVarimax performs Varimax rotation using the classic Jacobi rotation method as described in Kaiser (1958) and implemented in SPSS.
This method differs from GPArotation's gradient-based approach: - Uses pairwise Givens rotations instead of gradient projection - Iterates through all factor pairs until convergence - More closely matches SPSS output
References: Kaiser, H. F. (1958). The varimax criterion for analytic rotation in factor analysis. Psychometrika, 23(3), 187-200.
Algorithm: 1. Apply Kaiser normalization (row normalize by sqrt of communality) 2. For each pair of factors (p, q):
- Compute optimal rotation angle θ that maximizes variance of squared loadings
- Apply Givens rotation to factors p and q
3. Repeat until convergence 4. Denormalize by multiplying back by sqrt of communality
func KaiserVarimaxWithRotationMatrix ¶
func KaiserVarimaxWithRotationMatrix(A *mat.Dense, normalize bool, maxIter int, epsilon float64) (*mat.Dense, *mat.Dense, error)
KaiserVarimaxWithRotationMatrix returns both the rotated loadings and the rotation matrix
func NormalizingWeight ¶
NormalizingWeight computes normalizing weights for GPA rotation. Mirrors GPArotation::NormalizingWeight for Kaiser normalization.
func Oblimin ¶
func Oblimin(loadings *mat.Dense, normalize bool, eps float64, maxIter int, gamma float64) map[string]any
Oblimin performs oblimin rotation. Mirrors GPArotation::oblimin
func ParseRotationResult ¶
ParseRotationResult accepts the opaque result value returned by FaRotations (or individual rotation functions) and returns typed pointers to the rotated loadings, rotation matrix (rotmat), Phi (may be nil for orthogonal rotations), the objective f and a bool indicating success. This helper centralizes key extraction so callers can programmatically compare matrices (e.g. against SPSS reference).
func Rotate ¶
func Rotate(loadings *mat.Dense, method string, opts *RotOpts) (*mat.Dense, *mat.Dense, *mat.Dense, bool, error)
Rotate performs factor rotation on loadings. This is a wrapper around FaRotations for compatibility.
func RotateWithDiagnostics ¶
func RotateWithDiagnostics(loadings *mat.Dense, method string, opts *RotOpts) (*mat.Dense, *mat.Dense, *mat.Dense, bool, map[string]interface{}, error)
RotateWithDiagnostics performs factor rotation on loadings with diagnostics. Returns rotated loadings, rotation matrix, Phi matrix, convergence status, and diagnostics map.
func SMC ¶
SMC computes the squared multiple correlations for a correlation matrix. This is a wrapper around Smc for compatibility.
func Smc ¶
Smc computes the squared multiple correlations (SMC) for a correlation matrix. Mirrors psych::smc with complete NA handling and covar/pairwise options
func TargetRot ¶
TargetRot performs target rotation on an unrotated loading matrix x. Mirrors psych::target.rot exactly
func TargetRotWithMask ¶
func TargetRotWithMask(x *mat.Dense, keys *mat.Dense, mask *mat.Dense) (loadings, rotmat, Phi *mat.Dense, diagnostics map[string]interface{}, err error)
TargetRotWithMask performs target rotation with optional mask for target matrix elements. Elements marked with NaN in the mask are excluded from the alignment process.
Types ¶
type FacOptions ¶
type FacOptions struct {
NFactors int
NObs float64
Rotate string
Scores string
Residuals bool
SMC interface{} // bool or []float64
Covar bool
Missing bool
Impute string
MinErr float64
MaxIter int
Symmetric bool
Warnings bool
Fm string
Alpha float64
ObliqueScores bool
NpObs *mat.Dense
Use string
Cor string
Correct float64
Weight []float64
NRotations int
Hyper float64
Smooth bool
}
FacOptions represents options for the Fac function
type FacResult ¶
type FacResult struct {
Values []float64
Rotation string
NObs float64
NpObs *mat.Dense
Communality []float64
Loadings *mat.Dense
Fit float64
Residual *mat.Dense
R *mat.Dense
Communalities []float64
Uniquenesses []float64
EValues []float64
Model *mat.Dense
Fm string
RotMat *mat.Dense
Phi *mat.Dense
Structure *mat.Dense
Method string
Scores *mat.Dense
R2Scores []float64
Weights *mat.Dense
Factors int
Hyperplane []float64
Vaccounted *mat.Dense
ECV []float64
}
FacResult represents the result of factor analysis
type Factor2ClusterOptions ¶
type Factor2ClusterOptions struct {
Cut float64 // Loading threshold below which variables are not assigned to any cluster
UseRLikePipeline bool // If true, use R-like pipeline: varimax -> target.rot -> cluster
}
Factor2ClusterOptions represents options for Factor2Cluster
type RotOpts ¶
type RotOpts struct {
Eps float64
MaxIter int
Alpha0 float64
Gamma float64
PromaxPower int
Restarts int
}
RotOpts represents rotation options
type SmcOptions ¶
type SmcOptions struct {
Covar bool // If true, use covariance matrix instead of correlation
Pairwise bool // If true, use pairwise correlations for NA handling
Tol float64 // Tolerance for matrix inversion
}
SmcOptions represents options for Smc function
Source Files
¶
- GPArotation_GPFoblq.go
- GPArotation_GPForth.go
- GPArotation_vgQ_bentler.go
- GPArotation_vgQ_geomin.go
- GPArotation_vgQ_oblimin.go
- GPArotation_vgQ_quartimax.go
- GPArotation_vgQ_quartimin.go
- GPArotation_vgQ_simplimax.go
- GPArotation_vgQ_target.go
- GPArotation_vgQ_varimax.go
- fa.go
- factor2cluster.go
- kaiser_varimax.go
- psych_Promax.go
- psych_faRotations.go
- psych_fac.go
- psych_pinv.go
- psych_smc.go
- psych_target_rot.go