public void refineTree() throws Exception
	{
		int nniCount = 0;
		switch( ntype )
	    {      
	    	case OLS:
	    		if ( btype != balance.OLS )
	    			T.assignAllSizeFields();
	    		T.makeOLSAveragesTable(D,A);
	    		nniCount = T.NNI(A,nniCount);
	    		T.assignOLSWeights(A);
	    		break;
	    	case BAL:	
	    		if ( btype != balance.BAL )
	    			T.makeBMEAveragesTable(D,A);
	    		nniCount = T.bNNI( A, nniCount );
	    		T.assignBMEWeights(A);
	    		break;
	    	case NONE:
	    		switch( wtype )
	    		{
	    			case OLS:	// default
	    				if ( balance.OLS != btype)
	    					T.assignAllSizeFields();
	    				T.makeOLSAveragesTable(D,A);
	    				T.assignOLSWeights(A);
	    				break;
	    			case BAL:
	    				if ( balance.BAL != btype )
	    					T.makeBMEAveragesTable(D,A);
	    				T.assignBMEWeights(A);
	    				break;
	    			default:
	    				throw new Exception(
	    					"Error in program: variable 'btype' has illegal value "
	    					+btype);
	    		}
	    		break;
	    	default:
	    		throw new Exception(
    				"Error in program: variable 'ntype' has illegal value "
	    			+ntype);
	    }
	}