I am doing a factor analysis and I’ve noticed that the method :em works in all cases but not the :cm (default). Why this?
This works for example:
using MultivariateStats
X = [0.635098 0.548183 0.211851 0.171408 0.877398;
0.348466 0.498276 0.00646129 0.374103 0.21937;
0.172254 0.593525 0.319492 0.706334 0.51062;
0.994453 0.542042 0.155406 0.165663 0.196073]
M = fit(FactorAnalysis, X; maxoutdim=4, method=:em)
Factor Analysis(indim = 4, outdim = 4)
But this one does not:
M = fit(FactorAnalysis, X; maxoutdim=4, method=:cm)
ERROR: DomainError with -0.9992656414512631:
sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).
Stacktrace:
[1] throw_complex_domainerror(f::Symbol, x::Float64)
@ Base.Math ./math.jl:33
[2] sqrt(x::Float64)
@ Base.Math ./math.jl:582
[3] facm(S::Matrix{Float64}, mv::Vector{Float64}, n::Int64; maxoutdim::Int64, tol::Float64, η::Float64, maxiter::Int64)
@ MultivariateStats ~/.julia/packages/MultivariateStats/HTpHt/src/fa.jl:119
[4] fit(::Type{FactorAnalysis}, X::Matrix{Float64}; method::Symbol, maxoutdim::Int64, mean::Nothing, tol::Float64, η::Float64, maxiter::Int64)
@ MultivariateStats ~/.julia/packages/MultivariateStats/HTpHt/src/fa.jl:173
[5] top-level scope
@ REPL[10]:1