npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-seasonal

v1.0.2

Published

A simple Node.js wrapper for X-13-ARIMA-SEATS, the seasonal adjustment software by the U.S. Census Bureau

Downloads

15

Readme

node-seasonal

A simple Node.js wrapper for X-13-ARIMA-SEATS, the seasonal adjustment software by the U.S. Census Bureau

Installation and usage

Install:

npm install --save node-seasonal

Use:

const seasonal = require('node-seasonal');

// Your input data must be an array of objects with the requred fields
const input_data = [
  {
    month: "1998-01",
    shoe_sales: 100343,
    shirt_sales: 35991
  },
  // { ... } etc etc
];

const options = {
  date_field: "month", // Dates must be formatted YYYY-MM
  value_fields: ["shoe_sales", "shirt_sales"], // All values in data to adjust
  table_ids: ["d11"], // d11 is standard seasonal adjustment
  output_dir: `${__dirname}/output`, // x13 files deleted if left empty
  log: true // Whether to log output of x13 command
};

const adjusted_data = seasonal.adjust(input_data, options);

The above will auto-adjust the input data and append the adjusted numbers to it. The output will include the original data, with new fields for the adjusted numbers which include the requested table IDs. That is, in the example above, adjusted_data would look like this:

[
  {
    month: "1998-01",
    shoe_sales: 100343,
    shirt_sales: 35991,
    shoe_sales_d11: 90443,
    shirt_sales_d11: 38002
  },
  // { ... } etc etc
]

Each valid table ID specified in the options will append a new field for each value field specified.

Options

Required properties:

date_field (String) Date format must be YYYY-MM; (seasonal.adjust() only supports monthly adjustments)

value_fields (Array of strings) Should include all fields in input data that should be seasonally adjusted

table_ids (Array of strings) Refer to the x13ashtml reference manual for a listing of codes (d11 is final seasonally adjusted numbers)

Optional properties:

output_dir (String) Where to output x13ashtml files. If empty or null, output files are deleted.

log (Boolean) Whether to log output of x13ashtml command, which is useful for debugging. (Default is false.)

Use a custom .spc file

seasonal.custom({
  input_file_path: `${__dirname}/input_filename`, // Required
  log: true // Optional (default is false)
});

This simply runs a .spc file you create on your own and saves the x13ashtml output files. The files will be saved to the same directory where the input spec file is. Refer to the x13ashtml reference manual for the specifications of the input files.