Parent

Class/Module Index [+]

Quicksearch

Statsample::Regression::Binomial::BaseEngine

Base Engine for binomial regression analysis. Use Statsample::Regression.logit and Statsample::Regression.probit for fast access methods.

Usage:

dataset=Statsample::CSV.read("data.csv")
y="y"
model=Statsample::MLE::Logit.new
lr=Statsample::Regression::Binomial::BaseEngine(dataset, y, model)

Attributes

log_likehood[R]
iterations[R]

Public Class Methods

new(ds,y_var,model) click to toggle source

Parameters

# File lib/statsample/regression/binomial.rb, line 19
def initialize(ds,y_var,model)
  @ds=ds
  @y_var=y_var
  @dy=@ds[@y_var]
  @ds_indep=ds.dup(ds.fields-[y_var])
  constant=([1.0]*ds.cases).to_vector(:scale)
  @ds_indep.add_vector("_constant",constant)
  mat_x=@ds_indep.to_matrix
  mat_y=@dy.to_matrix(:vertical)
  @fields=@ds_indep.fields
  @model=model
  coeffs=model.newton_raphson(mat_x, mat_y)
  @coeffs=assign_names(coeffs.column(0).to_a)
  @iterations=model.iterations
  @var_cov_matrix=model.var_cov_matrix
  @log_likehood=model.log_likehood(mat_x, mat_y, coeffs)
end

Public Instance Methods

coeffs() click to toggle source

Regression coefficients

# File lib/statsample/regression/binomial.rb, line 56
def coeffs
  c=@coeffs.dup
  c.delete("_constant")
  c
end
coeffs_se() click to toggle source

Coefficients standard error

# File lib/statsample/regression/binomial.rb, line 37
def coeffs_se
  out={}
  @fields.each_index{|i|
    f=@fields[i]
    out[f]=Math::sqrt(@var_cov_matrix[i,i])
  }
  out.delete("_constant")
  out
end
constant() click to toggle source

Value of constant on regression

# File lib/statsample/regression/binomial.rb, line 47
def constant
  @coeffs['_constant']
end
constant_se() click to toggle source

Constant standard error

# File lib/statsample/regression/binomial.rb, line 51
def constant_se
  i=@fields.index "_constant"
  Math::sqrt(@var_cov_matrix[i,i])
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.