Giter VIP home page Giter VIP logo

Comments (6)

wildart avatar wildart commented on May 8, 2024

Either the covariance matrix is not positive definite or there is an accumulated floating-point error. If you could provide data sample, I'll look into it.

from multivariatestats.jl.

stelmo avatar stelmo commented on May 8, 2024

Thanks for getting back to me! I just checked, the covariance matrix seems to be positive definite, so it might be accumulated floating point errors. I have attached an example matrix as a jld file but Github doesn't allow uploads of that file type so I added .zip to the file name i.e. don't try to extract it, just remove the .zip from the file name. Thanks!
example_matrix.jld.zip
.

from multivariatestats.jl.

wildart avatar wildart commented on May 8, 2024

It that a 19-dimensioanal data? If it is the case I think you incorrectly passed your data to a fit function.

All functions in this package accept column-major order data. So if you pass your matrix as it is (size 2457x19), you'll get 19 records of 2457 dims which definitely results in a non-positive definite covariance matrix.

If it is not the case just transpose your input.

from multivariatestats.jl.

stelmo avatar stelmo commented on May 8, 2024

Hmm I'm not sure I understand. My input data has 19 samples (as columns) with 2457 features (as rows) and I checked for positive definiteness by doing eigvals(cov(X)) which returned a set of all positive eigenvalues (the smallest one was ~0.002).

from multivariatestats.jl.

wildart avatar wildart commented on May 8, 2024

This package uses data in a column-major order means which means that in a data matrix, each column corresponds to a sample/observation, while each row corresponds to a feature (variable or attribute or dimension).

If the matrix size is 2457x19 then you have a 19 2457-dimensional samples. By default, cov function computes covariance along the matrix dimension 1, cov(X, dims=1), which results in the covariance matrix of size 19x19, because row is first matrix dimension and we compute/fold along this dimension. This is fine if our samples are rows in the data matrix, which is not in our case.

So, you call cov(X, dims=2) for data in column-major order and get proper 2457x2457 covariance matrix, which in your case in not positive definite.

julia> count(eigvals(cov(X, dims = 2)) .< 0)
1223

from multivariatestats.jl.

stelmo avatar stelmo commented on May 8, 2024

Oh dang, I misunderstood! Thanks for your help!!

from multivariatestats.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.