Class/Module Index [+]

Quicksearch

Statsample::Regression::Multiple

Module for OLS Multiple Regression Analysis.

Use:.

require 'statsample'
a=1000.times.collect {rand}.to_scale
b=1000.times.collect {rand}.to_scale
c=1000.times.collect {rand}.to_scale
ds={'a'=>a,'b'=>b,'c'=>c}.to_dataset
ds['y']=ds.collect{|row| row['a']*5+row['b']*3+row['c']*2+rand()}
lr=Statsample::Regression.multiple(ds,'y')
puts lr.summary
Summary for regression of a,b,c over y
*************************************************************
Engine: Statsample::Regression::Multiple::AlglibEngine
Cases(listwise)=1000(1000)
r=0.986
r2=0.973
Equation=0.504+5.011a + 2.995b + 1.988c
----------------------------
ANOVA TABLE
--------------------------------------------------------------
|  source     | ss       | df  | ms      | f         | s     |
--------------------------------------------------------------
|  Regression | 2979.321 | 3   | 993.107 | 12040.067 | 0.000 |
|  Error      | 82.154   | 996 | 0.082   |           |       |
|  Total      | 3061.475 | 999 |         |           |       |
--------------------------------------------------------------
Beta coefficientes
-----------------------------------------------
|  coeff    | b     | beta  | se    | t       |
-----------------------------------------------
|  Constant | 0.504 | -     | 0.030 | 16.968  |
|  a        | 5.011 | 0.832 | 0.031 | 159.486 |
|  b        | 2.995 | 0.492 | 0.032 | 94.367  |
|  c        | 1.988 | 0.323 | 0.032 | 62.132  |
-----------------------------------------------

Public Class Methods

r2_from_matrices(rxx,rxy) click to toggle source

Obtain r2 for regressors

# File lib/statsample/regression/multiple.rb, line 44
def self.r2_from_matrices(rxx,rxy)
  matrix=(rxy.transpose*rxx.inverse*rxy)
  matrix[0,0]
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.