module Statsample::Shorthand

Module which provide shorthands for many methods.

Module which provide shorthands for many methods.

R like methods

↑ top

Public Class Methods

rnorm(n,mean=0,sd=1) click to toggle source

Random generation for the normal distribution

# File lib/statsample/shorthand.rb, line 53
def rnorm(n,mean=0,sd=1)
  rng=Distribution::Normal.rng(mean,sd)
  Statsample::Vector.new_scale(n) { rng.call}
end
test_u(*args) click to toggle source
# File lib/statsample/shorthand.rb, line 116
def test_u(*args)
  Statsample::Test::UMannWhitney.new(*args)
end

Public Instance Methods

boxplot(*args) click to toggle source

Returns a Statsample::Graph::Boxplot

# File lib/statsample/shorthand.rb, line 65
def boxplot(*args)
  Statsample::Graph::Boxplot.new(*args)
end
cor(ds) click to toggle source

Create a correlation matrix from a dataset

# File lib/statsample/shorthand.rb, line 40
def cor(ds)
  Statsample::Bivariate.correlation_matrix(ds)
end
cov(ds) click to toggle source

Create a variance/covariance matrix from a dataset

# File lib/statsample/shorthand.rb, line 44
def cov(ds)
  Statsample::Bivariate.covariate_matrix(ds)
end
data_frame(vectors=Hash.new)
Alias for: dataset
dataset(vectors=Hash.new) click to toggle source

Creates a new Statsample::Dataset Each key is transformed into string

# File lib/statsample/shorthand.rb, line 59
def dataset(vectors=Hash.new)
  vectors=vectors.inject({}) {|ac,v| ac[v[0].to_s]=v[1];ac}
  Statsample::Dataset.new(vectors)
end
Also aliased as: data_frame, data_frame
dominance_analysis(*args) click to toggle source
# File lib/statsample/shorthand.rb, line 101
def dominance_analysis(*args)
  Statsample::DominanceAnalysis.new(*args)
end
dominance_analysis_bootstrap(*args) click to toggle source
# File lib/statsample/shorthand.rb, line 104
def dominance_analysis_bootstrap(*args)
  Statsample::DominanceAnalysis::Bootstrap.new(*args)
end
histogram(*args) click to toggle source

Returns a Statsample::Graph::Histogram

# File lib/statsample/shorthand.rb, line 69
def histogram(*args)
  Statsample::Graph::Histogram.new(*args)
end
levene(*args) click to toggle source

Returns a Statsample::Test::Levene

# File lib/statsample/shorthand.rb, line 78
def levene(*args)
  Statsample::Test::Levene.new(*args)
end
lr(*args) click to toggle source

Other Shortcuts

# File lib/statsample/shorthand.rb, line 95
def lr(*args)
  Statsample::Regression.multiple(*args)
end
multiscale_analysis(*args,&block) click to toggle source
# File lib/statsample/shorthand.rb, line 113
def multiscale_analysis(*args,&block)
  Statsample::Reliability::MultiScaleAnalysis.new(*args,&block)
end
names(ds) click to toggle source

Retrieve names (fields) from dataset

# File lib/statsample/shorthand.rb, line 36
def names(ds)
  ds.fields
end
pca(ds,opts=Hash.new) click to toggle source
# File lib/statsample/shorthand.rb, line 98
def pca(ds,opts=Hash.new)
  Statsample::Factor::PCA.new(ds,opts)
end
polychoric(*args) click to toggle source
# File lib/statsample/shorthand.rb, line 85
def polychoric(*args)
  Statsample::Bivariate::Polychoric.new(*args)
end
principal_axis(*args) click to toggle source
# File lib/statsample/shorthand.rb, line 81
def principal_axis(*args)
  Statsample::Factor::PrincipalAxis.new(*args)
  
end
read_csv() click to toggle source

Import an CSV file. Cache result by default

# File lib/statsample/shorthand.rb, line 31
def read_csv
  read_with_cache(Statsample::CSV, filename, opts, cache)
end
read_excel(filename, opts=Hash.new, cache=true) click to toggle source

Import an Excel file. Cache result by default

# File lib/statsample/shorthand.rb, line 25
def read_excel(filename, opts=Hash.new, cache=true)
  read_with_cache(Statsample::Excel, filename, opts, cache)

end
read_with_cache(klass, filename,opts=Hash.new, cache=true) click to toggle source
# File lib/statsample/shorthand.rb, line 14
def read_with_cache(klass, filename,opts=Hash.new, cache=true)
  file_ds=filename+".ds"
  if cache and (File.exists? file_ds and File.mtime(file_ds)>File.mtime(filename))
    ds=Statsample.load(file_ds)
  else
    ds=klass.read(filename)
    ds.save(file_ds) if cache
  end
  ds
end
scale_analysis(*args) click to toggle source
# File lib/statsample/shorthand.rb, line 107
def scale_analysis(*args)
  Statsample::Reliability::ScaleAnalysis.new(*args)
end
scatterplot(*args) click to toggle source

Returns a Statsample::Graph::Scatterplot

# File lib/statsample/shorthand.rb, line 74
def scatterplot(*args)
  Statsample::Graph::Scatterplot.new(*args)
end
skill_scale_analysis(*args) click to toggle source
# File lib/statsample/shorthand.rb, line 110
def skill_scale_analysis(*args)
  Statsample::Reliability::SkillScaleAnalysis.new(*args)
end
tetrachoric(*args) click to toggle source
# File lib/statsample/shorthand.rb, line 88
def tetrachoric(*args)
  Statsample::Bivariate::Tetrachoric.new(*args)
end
vector(*args) click to toggle source

Create a Statsample::Vector Analog to R's c

# File lib/statsample/shorthand.rb, line 49
def vector(*args)
  Statsample::Vector[*args]
end