#  Draco Econometrics
#  Copyright (C) 2006-2008 Approximatrix, LLC
#  http://www.approximatrix.com
#  
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.

include Java

import com.approximatrix.draco.application.plugin.PluginType

require 'pengine/model/plugin'
require 'pengine/results/regression_results_helper'

# Here you need to define your plugin
#register(Plugin::PluginSkeleton) # For example

module Plugin
  
  class RegressionPluginSkeleton < PluginSkeleton
  
    @@TYPE = PluginType.regression
    
    attr_reader :covariance, :x, :failure, :statistics, :stderr, :tscores, :coef_names
    
    def standard_errors
      sqrt(@covariance.diagonal)
    end
    
    # Override this when appropriate
    def has_constant?
      false
    end
    
    def generate_coef_names(independent)
      @coef_names = []
      @coef_names << "Constant" if has_constant?
      independent.each do |one|
        @coef_names << "Coef (#{one})"
      end
    end
    
    def statistic(name,value)
      @statistics = [] if(@statistics.nil?)
      @statistics << [name,value]
    end
    
    def results
      RegregressionResultsHelper.new(self).to_s      
    end
    
  end
  
end # module Plugin
    

