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

bugs in facm() #157

Closed
githubtomtom opened this issue Jun 29, 2021 · 0 comments
Closed

bugs in facm() #157

githubtomtom opened this issue Jun 29, 2021 · 0 comments

Comments

@githubtomtom
Copy link

calling fit(FactorAnalysis, x) sometimes would get:

ERROR: DomainError with -0.9999999999999778:
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{MultivariateStats.FactorAnalysis}, X::Matrix{Float64}; method::Symbol, maxoutdim::Int64, mean::Int64, tol::Float64, η::Float64, maxiter::Int64)
   @ MultivariateStats ~/.julia/packages/MultivariateStats/HTpHt/src/fa.jl:173

which should be caused by:

        q′ = λ[q] > 0 ? q : findlast(λ .> 0)

        λq = 0.0
        @inbounds for i in 1:q′
            λq += log(λ[i]) - λ[i] + 1.
            V[i] = sqrt(λ[i] - 1.)         # <---  λ is guaranteed to be > 0, but NOT >= 1
        end

inside facm(). In fact, the λ can be smaller than 1, and an error would be triggered.

wildart added a commit to wildart/MultivariateStats.jl that referenced this issue Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant