/*
 *  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/>.
 */

package com.approximatrix.draco.fit;

import org.junit.Test;

public class RunLSTest extends RegressionTestSkeleton {

	@Test
	public void testRunLSNorris() {
		String[] indep = new String[1]; indep[0] = "x";
		RunLS analysis = new RunLS(indep,"y",norris,RunLS.VAR_OLS,true);
		analysis.perform();
		
		double[] coef = analysis.getCoef();
		assertCloseTo(-0.262323073774029,coef[0],DELTA);
		assertCloseTo(1.00211681802045,coef[1],DELTA);
		
		double[] var = analysis.getCoefVariances();
		assertCloseTo(0.232818234301152*0.232818234301152,var[0],DELTA);
		assertCloseTo( 0.429796848199937E-03* 0.429796848199937E-03,var[1],DELTA);
	}

	@Test
	public void testRunLSNoInt1() {
		String[] indep = new String[1]; indep[0] = "x";
		RunLS analysis = new RunLS(indep,"y",noint1,RunLS.VAR_OLS,false);
		analysis.perform();
		
		double[] coef = analysis.getCoef();
		assertCloseTo(2.07438016528926,coef[0],DELTA);
		
		double[] var = analysis.getCoefVariances();
		assertCloseTo(0.165289256198347E-01*0.165289256198347E-01,var[0],DELTA);
	}
	
	@Test
	public void testRunLSNoInt2() {
		String[] indep = new String[1]; indep[0] = "x";
		RunLS analysis = new RunLS(indep,"y",noint2,RunLS.VAR_OLS,false);
		analysis.perform();
		
		double[] coef = analysis.getCoef();
		assertCloseTo(0.727272727272727,coef[0],DELTA);
		
		double[] var = analysis.getCoefVariances();
		assertCloseTo(0.420827318078432E-01*0.420827318078432E-01,var[0],DELTA);
	}
	
}
