Statsample

Homepage :: github.com/clbustos/statsample

DESCRIPTION

A suite for basic and advanced statistics on Ruby. Tested on Ruby 2.1.1p76 (June 2014), 1.8.7, 1.9.1, 1.9.2 (April, 2010), ruby-head(June, 2011) and JRuby 1.4 (Ruby 1.8.7 compatible).

Include: * Descriptive statistics: frequencies, median, mean, standard error, skew, kurtosis (and many others). * Imports and exports datasets from and to Excel, CSV and plain text files. * Correlations: Pearson's r, Spearman's rank correlation (rho), point biserial, tau a, tau b and gamma. Tetrachoric and Polychoric correlation provides by statsample-bivariate-extension gem. * Intra-class correlation * Anova: generic and vector-based One-way ANOVA and Two-way ANOVA, with contrasts for One-way ANOVA. * Tests: F, T, Levene, U-Mannwhitney. * Regression: Simple, Multiple (OLS), Probit and Logit * Factorial Analysis: Extraction (PCA and Principal Axis), Rotation (Varimax, Equimax, Quartimax) and Parallel Analysis and Velicer's MAP test, for estimation of number of factors. * Reliability analysis for simple scale and a DSL to easily analyze multiple scales using factor analysis and correlations, if you want it. * Basic time series support * Dominance Analysis, with multivariate dependent and bootstrap (Azen & Budescu) * Sample calculation related formulas * Structural Equation Modeling (SEM), using R libraries sem and OpenMx * Creates reports on text, html and rtf, using ReportBuilder gem * Graphics: Histogram, Boxplot and Scatterplot

Principles

Features

Examples of use:

See the examples folder too.

Boxplot

require 'statsample'

ss_analysis(Statsample::Graph::Boxplot) do 
  n=30
  a=rnorm(n-1,50,10)
  b=rnorm(n, 30,5)
  c=rnorm(n,5,1)
  a.push(2)
  boxplot(:vectors=>[a,b,c], :width=>300, :height=>300, :groups=>%w{first first second}, :minimum=>0)
end
Statsample::Analysis.run # Open svg file on *nix application defined

Correlation matrix

require 'statsample'
# Note R like generation of random gaussian variable
# and correlation matrix

ss_analysis("Statsample::Bivariate.correlation_matrix") do
  samples=1000
  ds=data_frame(
    'a'=>rnorm(samples), 
    'b'=>rnorm(samples),
    'c'=>rnorm(samples),
    'd'=>rnorm(samples))
  cm=cor(ds) 
  summary(cm)
end

Statsample::Analysis.run_batch # Echo output to console

Requirements

Optional:

Note: Use gsl 1.12.109 or later.

Resources

Installation

$ sudo gem install statsample

On *nix, you should install statsample-optimization to retrieve gems gsl, statistics2 and a C extension to speed some methods.

There are available precompiled version for Ruby 1.9 on x86, x86_64 and mingw32 archs.

$ sudo gem install statsample-optimization

If you use Ruby 1.8, you should compile statsample-optimization, usign parameter --platform ruby

$ sudo gem install statsample-optimization --platform ruby

If you need to work on Structural Equation Modeling, you could see statsample-sem. You need R with sem or OpenMx [openmx.psyc.virginia.edu/] libraries installed

$ sudo gem install statsample-sem

Available setup.rb file

sudo gem ruby setup.rb

License

GPL-2 (See LICENSE.txt)