{"_id":"@dominicdayta/nodestat","_rev":"4-c944e4827d4039cb665c7d788abdea17","name":"@dominicdayta/nodestat","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@dominicdayta/nodestat","version":"1.0.0","keywords":["stat","nodestat","dataframes","data"],"license":"MIT","_id":"@dominicdayta/nodestat@1.0.0","maintainers":[{"name":"dominicdayta","email":"domdayta@gmail.com"}],"dist":{"shasum":"da74e18b863bba1ee4deb7524d3c1727fbc47448","tarball":"https://registry.npmjs.org/@dominicdayta/nodestat/-/nodestat-1.0.0.tgz","fileCount":11,"integrity":"sha512-u5AgW/R4B99TNn8bBsXwdehxZuiY1VHDFEX/flrmmUvoSTmMQUkP58LTFv6a8ZGceWRLW1novpYZ7YMNNSbWtA==","signatures":[{"sig":"MEYCIQDBfip4uad3fAMoyc9UE+QZ98d45caRlR8o5ZQxv+8IWQIhAODTyADmJq3hNH3TtLinl+hD0z+ViM4cSeXXQeg2IqMS","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33059,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg5xY/CRA9TVsSAnZWagAAV8EP/08Ptt8KrO8AF9QwXbUA\nDoh1UlceL2bbRKiv5z87rUI0emYzFs9eNaELb9qaZvXFDMZh9I1Zoepd5YIi\n3eS5Rhe9kXbC/qHAcdJgW9/66pmX8QMILXCD4UEjqQguSeu0YrmTU5YNni4m\ncmjEEwKhNThzSbqzJtoN0WlxdYPHWtsbmiZrq+lyzBV+SbuxmihReh1IDMcB\nNSewHoFDBxEzTYCTUW3Qf5nirhP4IcASGnZkoFAJjFjmPgud6xc6Jtq/s2OG\nt6EtzDhO12VYf4U+j/btsgyePh3pqaEL/YMKiVnxqJRu8EWLOU3jCzHwppel\n1CFXw/nvoWAaxaG3nYQGc+vpwfsxfSZHINAs2n3+jv27cJ0sz39ksRxx9R2+\nLdmxo1hcuDkKXAttnf5Y3O66L4mm9Q9X18NHWu9U109w72xMT06R/chuKh87\nDzTEHoUw4jR4lxQwfYPCMSHu96lr6xehibR0p6pBI6OeQ+fld423rB4NwQEm\nopYJcw+86XhwHiMv803o0nCaSrWaz/TWpg5oDBXDzf1UcXVgPVW3mfLZLSoa\nBAoEz8Xce+4LZI0sgiuGvGgyB5kNpTMh4MjMqSHm8YMyuruqDsdC7qeqrXts\nJFgb77tICRPZuYrLvYmg8CnvJtrbAs5UEJuQLvQs/jxcDBBgAWrcIzTjSwnj\n90tS\r\n=hsCu\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","gitHead":"2a665ae95c3f10a6ca16e2ab93e4eedbe0d5f970","_npmUser":{"name":"dominicdayta","email":"domdayta@gmail.com"},"_npmVersion":"6.14.6","description":"A lightweight library for data wrangling and analysis","directories":{},"_nodeVersion":"12.18.3","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/nodestat_1.0.0_1625757246985_0.8989673114835954","host":"s3://npm-registry-packages"}},"0.0.1":{"name":"@dominicdayta/nodestat","version":"0.0.1","keywords":["stat","nodestat","dataframes","data"],"license":"MIT","_id":"@dominicdayta/nodestat@0.0.1","maintainers":[{"name":"dominicdayta","email":"domdayta@gmail.com"}],"dist":{"shasum":"8e483385163421ddf8715f35cf046a7782591f24","tarball":"https://registry.npmjs.org/@dominicdayta/nodestat/-/nodestat-0.0.1.tgz","fileCount":11,"integrity":"sha512-bKCRhlHVUuVgiUd1vJusgCt072i0mdqB16vQOmt6s+AGTW+DkHY4lRpMYkq0Q89k0DzeRHMxjQ6hWF3u5MFpVg==","signatures":[{"sig":"MEUCIGdsUQNojl3ryZgWx8VXT2/Xru3L6UIC5mRvDETKkyoBAiEAtGJ13YK2xVVJAfMyKX8YmofQZs8zM5l2wc5Nc/I9NCk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33609,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg5xgXCRA9TVsSAnZWagAA0A0P/jbpELyw6gKZNlvJo9Fe\nD9Ht7ZacGUUqo2pTlwWmGuZSM+N16PVah8z8xuUiJUV5jY3M2RRQAqSsUrwB\naJtIVq6IYOpUXrd6TQniWpQkO5ybQCh22WwaKjk5V5Lip6hrCyDgO1WTN89U\nmPft5ziT57dvj8tc4ggrK9RQ9n8qKnc4p5w9aQHPqaH2Wt2bIhtRUN/DVfFh\neiA10iVRmyoXr7LGMqQjVqAKmBmYmLbFegpPZRUB6oc0YeQJjyRsTXR0qn2g\nKdUxigcSml41EpL5S2H8IuJqJjGGVYAvsFQ5Ln5M1Z2Wo5WYAbnSP1COyF2o\nyJ+96d+yl3XiybBKSgQu2U5acygPNj3Rv6o5x45L04ZmDJK9sx4E7vxkB/SR\nZAjphexlMbi0cLU2JicYDmv7WDjVprqbkcopPi/j3TUm2wcpnnfMq9iWtAar\nQgzwn3uA8QwMGwidTR8Bt3pIuc+ATDMWdJFtjlrdgn25sJPP6tVfjZIcuehg\nnucUNBk9lC9ulufWypcx5tIwrH4ls9uv2xIy1o8OQ73Hcnekgxxf9ylXGbey\nd4Qxv18oqZCn0cR9YLLQNZD+GsNP3kMPAPoAaf5HdJL+Qms0aQnC+DB0P7Xh\nqHeOndubRApi/mEh/Ycw21ndkAjRojI2CslPjlUIv9BXSHPMgvkuNwpPyn32\nRyHM\r\n=jQu2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","gitHead":"362ea072a1e097d54e01f7cb310ec1a727469f34","_npmUser":{"name":"dominicdayta","email":"domdayta@gmail.com"},"_npmVersion":"6.14.6","description":"A lightweight library for data wrangling and analysis","directories":{},"_nodeVersion":"12.18.3","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/nodestat_0.0.1_1625757719536_0.9706333419726811","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"@dominicdayta/nodestat","version":"1.1.0","description":"A lightweight library for data wrangling and analysis","license":"MIT","main":"index.js","scripts":{"test":"node --test"},"keywords":["stat","nodestat","dataframes","data"],"gitHead":"3349fcea123ccbebf7e2289fc4be17a69671547b","_id":"@dominicdayta/nodestat@1.1.0","_nodeVersion":"24.14.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-+wZnlV4Zh2lcDTnBX7XM1NbLbhxGllMEdGO4ohgX/wi9/TzY2IU2MPXiInrWLZ/gV0c4xJpl9SG6NEGEvLFATw==","shasum":"3146cebf4630481bdb34d3520ee23bed3bafeb5d","tarball":"https://registry.npmjs.org/@dominicdayta/nodestat/-/nodestat-1.1.0.tgz","fileCount":70,"unpackedSize":144312,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIG0y/FzfEgav4f3grz/OyEnV/v3HJeFSVZxT3r6HGevgAiBoYXWPTjP6sAWGVK6j0cbvz7IAC5i7Y0DgIgVOrsyLWg=="}]},"_npmUser":{"name":"dominicdayta","email":"domdayta@gmail.com"},"directories":{},"maintainers":[{"name":"dominicdayta","email":"domdayta@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nodestat_1.1.0_1783651211447_0.016104342315827802"},"_hasShrinkwrap":false}},"time":{"created":"2021-07-08T15:14:06.941Z","modified":"2026-07-10T02:40:11.706Z","1.0.0":"2021-07-08T15:14:07.151Z","0.0.1":"2021-07-08T15:21:59.677Z","1.1.0":"2026-07-10T02:40:11.595Z"},"license":"MIT","keywords":["stat","nodestat","dataframes","data"],"description":"A lightweight library for data wrangling and analysis","maintainers":[{"name":"dominicdayta","email":"domdayta@gmail.com"}],"readme":"# Nodestat\r\n\r\nA Node JS package for data wrangling and analysis\r\n\r\n[![GitHub license](https://img.shields.io/github/license/dominicdayta/nodestat)](https://github.com/dominicdayta/nodestat/blob/main/LICENSE)\r\n[![GitHub issues](https://img.shields.io/github/issues/dominicdayta/nodestat)](https://github.com/dominicdayta/nodestat/issues)\r\n\r\n## Project Goals\r\n\r\nBoth Javascript and Node already have a variety of packages that deal with dataframes and statistical computation. The goal with Nodestat is to demonstrate a unified grammar of data analysis that can transform Javascript into a fully capable language for data analysis. Specific design goals are as follows:\r\n\r\n- An Intuitive Grammar. Even without a third party package, Javascript already contains some functionality for handling data using Javascript Objects and JSON. In fact, many of the base functions that Nodestat implements through its `Dataframe` module are hardly novel and can be written by any experienced Javascript developer. With Nodestat, however, the aim is to create a grammar for data analysis that is intuitive and efficient, allowing the same split-apply-combine strategy for data wrangling that the `plyr`/`dplyr` package provides for the R language, and that `pandas` provides for the Python language.\r\n\r\n- Close Integration with Statistical Packages. The `Dataframe` module isn't just another package for handling data in Javascript. It's designed to play well with packages for data analysis and statistical computation. The `Stats` module demonstrates this capability. In the future, hopefully additional modules and independent packages will be developed following the `Dataframe` grammar for more advanced data analysis and machine learning.\r\n\r\nIf you are interested in contributing to this project, please see our [contribution guidelines](contributing.md) for more information.\r\n## Usage\r\n### Install\r\n\r\nInstall using NPM as\r\n\r\n```properties\r\n$ npm install @dominicdayta/nodestat\r\n```\r\n\r\n### API Documentation\r\n\r\nThe package currently contains three primary modules:\r\n\r\n`stat`: Contains basic statistical formulas, tests, datasets, and linear models (`stat.lm` / `nstat.lm`).\r\n\r\n`df`: Contains useful functions for creating and managing dataframes.\r\n\r\n`random`: Seedable random number generation and object-oriented probability distributions.\r\n\r\n```javascript\r\nconst nstat = require('@dominicdayta/nodestat');\r\n\r\nlet stats = nstat.stat; // for shorthand\r\n\r\n// initiate the titanic dataset\r\nlet titanic = stats.dataset(\"Titanic\");\r\n\r\n// get the subset containing only survivors\r\nlet titanicSurvivors = titanic.subset(col = \"Survived\", \r\n    function(x){\r\n        return(x == \"Yes\")\r\n    }\r\n);\r\nconsole.log(titanicSurvivors.data);\r\n\r\n// aggregate the total number of survivors by sex and class\r\nlet freqSurvivedBySexClass = titanic\r\n    .select([\"Class\",\"Sex\",\"Freq\"])\r\n    .aggregate(by = [\"Class\",\"Sex\"], stats.sum);\r\nconsole.log(freqSurvivedBySexClass.data);\r\n\r\n// aggregate the total number of non-survivors by sex and age\r\nlet freqDiedSexAge = titanic\r\n    .subset(col = \"Survived\", function(x){return(x == \"No\")})\r\n    .select([\"Sex\",\"Age\",\"Freq\"])\r\n    .aggregate(by = [\"Sex\",\"Age\"], stats.sum)\r\n    .data;\r\nconsole.log(freqDiedSexAge);\r\n\r\n// sort using helper syntax (similar to dplyr::arrange)\r\nlet sorted = titanic.order([\"Class\", nstat.desc(\"Freq\")]);\r\nconsole.log(sorted.head(5).data);\r\n```\r\n\r\n### Random module\r\n\r\nNodestat provides a seedable random API with distribution objects similar to NumPy and PyTorch. Create a distribution, then call `pdf`, `cdf`, and `sample`:\r\n\r\n```javascript\r\nconst nstat = require('@dominicdayta/nodestat');\r\n\r\n// reproducible sampling\r\nnstat.random.set_global_seed(2026);\r\n\r\nconst normal = nstat.random.normal(0, 1);\r\nconsole.log(normal.pdf(0));\r\nconsole.log(normal.cdf(1.96));\r\nconsole.log(normal.sample(5));\r\n\r\nconst pois = nstat.random.poisson(3);\r\nconsole.log(pois.pmf(2));\r\nconsole.log(pois.sample());\r\n```\r\n\r\nSupported distributions include normal, exponential, gamma, geometric, uniform, poisson, binomial, chi-square, Student's t, and hypergeometric. See [random module docs](docs/random/introduction.md) for the full reference.\r\n\r\n### Statistical tests\r\n\r\nNodestat includes R-style hypothesis testing under `stat.tests`:\r\n\r\n```javascript\r\nconst nstat = require('@dominicdayta/nodestat');\r\nconst sleep = nstat.stat.dataset('sleep');\r\n\r\n// one-way ANOVA\r\nconst model = nstat.stat.tests.aov('extra ~ group', sleep);\r\nconsole.log(model.statistic, model.p_value);\r\n\r\n// Tukey HSD pairwise comparisons\r\nconsole.log(nstat.stat.tests.tukeyHSD(model).comparisons);\r\n\r\n// multiple-comparison p-value adjustment\r\nconsole.log(nstat.stat.tests.p_adjust([0.01, 0.04, 0.03], 'holm'));\r\n```\r\n\r\nSupported procedures include one- and two-sample t-tests, Wilcoxon tests, ANOVA with Tukey HSD, and Bonferroni/Holm/Hochberg/BY p-value adjustment. See [statistical tests docs](docs/stats/tests.md).\r\n\r\n### Linear models\r\n\r\nFit object-oriented linear models with formula syntax similar to R's `lm()`:\r\n\r\n```javascript\r\nconst nstat = require('@dominicdayta/nodestat');\r\nconst women = nstat.stat.dataset('women');\r\n\r\nconst model = nstat.lm('weight ~ height', women);\r\nconsole.log(model.coef());\r\nconsole.log(model.summary());\r\nconsole.log(model.coeftable().print());\r\n```\r\n\r\nFormulas support interactions (`x * group`), transforms (`log(y) ~ sqrt(x)`), and as-is terms (`I(x^2)`). Categorical predictors are automatically dummy-coded. See [linear models docs](docs/stats/lm.md).\r\n\r\nYou can look into sample runnable use cases in the `./examples` directory (legacy examples are in `./demo`). For full documentation on how to use the API, please look into the `./docs` directory.\r\n\r\n# License\r\n\r\nThis package is licensed under the MIT License.","readmeFilename":"readme.md"}