/*
 *  Draco Econometrics
 *  Copyright (C) 2006-2007 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/>.
 */

package com.approximatrix.draco.fit;


import java.util.List;

import com.approximatrix.draco.datamodel.StatTableModel;
import com.approximatrix.draco.fit.statistics.ExtendedStatistic;
import com.approximatrix.draco.io.XMLio.AnalysisLoadStore;

public interface LSFit {

	/** Performs the analysis
	 * 
	 */
	public void perform();
	
	/** Provides results of the fit in String form for display
	 *
	 * @return text outlining the results of the fit
	 */
	public String getResults();
	
	/** Returns the Covariance matrix resulting from the fit
	 *
	 * @return a square array of doubles containing the covariance matrix
	 */
	public double[][] getCovarianceMatrix();

	/** Returns the residuals from the fit
	 *
	 * @return a vector containing the residuals
	 */
	public double[] getResiduals();
	
	/** Returns the sum of the squares of the residuals
	 *
	 * @return the sum of the squares of the residuals
	 */
	public double getResidualSumSqared();
	
	/** Returns the total sum of the squares
	 *
	 * @return the sum of the squares
	 */
	public double getTotalSumSqared();
	
	/** Returns the coefficients from the fit
	 *
	 * @return a vector containing the coefficients from the fit
	 */
	public double[] getCoef();
	
	/** Returns labels, if any, associated with each coeficient
	 * 
	 * @return a vector of Strings containing labels for each coef, or null if not applicable
	 */
	public String[] getCoefLabels();
	
	/** Returns the variance of each coefficient
	 * 
	 * @return a vector containing the variances of the coefficients
	 */
	public double[] getCoefVariances();
	
	/** Returns the names of the independent variables
	 * 
	 * @return an array of Strings contianing the variable names
	 */
	public String[] getIndependentVariables();
	
	/** Returns the name of the dependent variable
	 *
	 * @return a String containing the name of the dependent variable
	 */
	public String getDependentVariable();
	
	/** Returns whether the fit was successful
	 * 
	 * @return true if successful
	 */
	public boolean isSuccessful();
	
	/** Returns a vector of Doubles containing the estimated data
	 *
	 * @return a vector of Doubles containing the estimates
	 */
	public Double[] getFittedData();
	
	/** Returns a vector of Doubles containing the rresiduals suitable for
	 * inclusion in a StatTableModel
	 *
	 * @return a vector of Doubles containing the residuals
	 */
	public Double[] getResidualData();
	
	/** Returns the original model used in the fit
	 * 
	 * @return the unmodified StatTableModel
	 */
	public StatTableModel getModel();

	/** Sets all data in the fit to the information loaded from
	 * a file
	 * 
	 * @param data a valid AnalysisLoadStore object that has been properly filled
	 * @param model the model with which this fit is associated
	 */
	public void setLoadedAnalysis(AnalysisLoadStore data, StatTableModel model);
	
	/** Sets the list of extended statistics to be computed for results
	 * 
	 * @param statistics a list of extendedstatistics
	 */
	public void setExtendedStatistics(List<ExtendedStatistic> statistics);
	
	/** Returns a list of computed extended statistics
	 * 
	 * @return a list of extended statistics, or possibly null.
	 */
	public List<ExtendedStatistic> getExtendedStatistics();
	
}

