Giter Site home page Giter Site logo

kwstat / nipals Goto Github PK

View Code? Open in Web Editor NEW
7.0 7.0 1.0 3.79 MB

Principal Component Analysis with missing data using NIPALS with Gram-Schmidt orthogonalization

Home Page: https://kwstat.github.io/nipals/

License: Other

R 51.12% Python 39.78% MATLAB 8.61% TeX 0.49%

nipals's People

Contributors

kwstat avatar stanstrup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

stanstrup

nipals's Issues

nipals::predict.nipals

Thank you very much for the package - it does exactly what is on the tin!

Would it be possible or would you consider implementing a predict.nipals function along the lines of stats:::predict.prcomp function?

noLD long double "additional issue"

Reported by CRAN: when checked with noLD (i.e. without support for long doubles):

* checking tests ...
   Running ‘testthat.R’
  ERROR
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
   > library(testthat)
   > library(nipals)
   >
   > test_check("nipals")
   PC 1 starting column: 4...
   PC 2 starting column: 1..
   PC 3 starting column: 3.
   PC 4 starting column: 5.
   PC 5 starting column: 2.
   PC 1 starting column: 4...........
   PC 2 starting column: 1..........
   PC 3 starting column: 3....
   PC 4 starting column: 5.........
   PC 5 starting column: 2..
   PC 1 starting column: 4.....
   PC 2 starting column: 1.......
   PC 3 starting column: 3...
   PC 4 starting column: 5...
   PC 5 starting column: 2..
   PC 1 starting column: 5.....
   PC 2 starting column: 5.........
   PC 3 starting column: 5...
   PC 4 starting column: 5...
   PC 5 starting column: 5..
   PC 1 starting column: 4.....
   PC 2 starting column: 1.......
   PC 3 starting column: 3...
   PC 4 starting column: 5...
   PC 5 starting column: 2..
   ── 1. Failure: Start column function (@test-empca.R#136)
──────────────────────
   `nipals(corn, startcol = function(x) var(x, na.rm = TRUE))` did not
produce any warnings.

   PC 1 starting column: 4...
   PC 2 starting column: 1..
   PC 3 starting column: 3.
   PC 4 starting column: 5.
   PC 5 starting column: 2.
   PC 1 starting column: 4...........
   PC 2 starting column: 1..........
   PC 3 starting column: 3....
   PC 4 starting column: 5.........
   PC 5 starting column: 2..
   PC 1 starting column: 4.....
   PC 2 starting column: 1.......
   PC 3 starting column: 3...
   PC 4 starting column: 5...
   PC 5 starting column: 2..
   PC 1 starting column: 5.....
   PC 2 starting column: 5.........
   PC 3 starting column: 5...
   PC 4 starting column: 5...
   PC 5 starting column: 5..
   PC 1 starting column: 4.....
   PC 2 starting column: 1.......
   PC 3 starting column: 3...
   PC 4 starting column: 5...
   PC 5 starting column: 2..
   ── 2. Failure: Start column function (@test-nipals.R#111)
─────────────────────
   `nipals(corn, startcol = function(x) var(x, na.rm = TRUE))` did not
produce any warnings.

   ══ testthat results
═══════════════════════════════════════════════════════════
   [ OK: 28 | SKIPPED: 2 | WARNINGS: 0 | FAILED: 2 ]
   1. Failure: Start column function (@test-empca.R#136)
   2. Failure: Start column function (@test-nipals.R#111)

Fix R CMD check error on M1mac

From CRAN:

Check: tests
Result: ERROR
     Running ‘testthat.R’ [1s/1s]
    Running the tests in ‘tests/testthat.R’ failed.
    Last 13 lines of output:
     PC 5 starting column: 2..
     ══ Skipped tests ═══════════════════════════════════════════════════════════════
     • empty test (2)
    
     ══ Failed tests ════════════════════════════════════════════════════════════════
     ── Failure (test-uscrime.R:68:3): SVD, NIPALS and EMPCA results match for complete uscrime data ──
     `avg_angle` is not strictly less than `tol`. Difference: NaN
     Backtrace:
     █
     1. └─nipals:::expect_aligned(m1s$u, m1e$scores) test-uscrime.R:68:2
     2. └─testthat::expect_lt(avg_angle, tol) setup-expectations.R:22:2
    
     [ FAIL 1 | WARN 1 | SKIP 2 | PASS 27 ]
     Error: Test failures
     Execution halted
Flavor: r-release-macos-arm64

Note: arm64 (aka 'Apple Silicon' aka 'M1') Mac.

error when using one component

Thank you very much for the package!
I ran into a little error when calculating the fitted x while setting ncomp = 1.
I think the problem is, if there is only a single eigenvalue, diag(eig) leads to an eig×eig identity matrix.

xhat <- tcrossprod(tcrossprod(scores, diag(eig)), loadings)

I encountered this issue trying to implement Wold's cross-validation for PCA, where components get added one after the other, with some steps between each. Easily fixed for my purposes, but thought you might like to know.

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.