/*
  roccomp

*!  VERSION 1.1.3  18aug2006 (deprecated)

*/

VERSION 9.0

INCLUDE graph_header
INCLUDE header

HELP hlp1, view("help roccomp")
RESET res1

DIALOG main, label("roccomp - Tests equality of two or more ROC areas")	///
	tabtitle("Main")
BEGIN
  TEXT     tx_varr         _lft      _top      _vnwd    .,		/*
		*/label("Reference variable:")
  TEXT     tx_varc         _lft4_2   @         _cwd4_1  .,		/*
  		*/label("Classification variable:")			/*
  		*/
  TEXT     tx_varc2        _lft4_3   @         _cwd1    .,		/*
  		*/label("Additional classification variables:")		/*
  		*/
  VARNAME  vn_varr         _lft      _ss       _vnwd     .,             /*
  		*/label("Reference variable")
  VARNAME  vn_varc         _lft4_2   @         _vnwd     .,             /*
  		*/label("Classification variable:")			/*
  		*/
  VARLIST  vl_varc2        _lft4_3   @         _cwd1     .,		/*
  		*/label("Reference variable")
  GROUPBOX gb_opt          _lft      _ls       _iwd      _ht22,         /*
  		*/label("Options")
  CHECKBOX ck_by           _indent   _ss       _cwd2     .,		/*
  		*/ label("Split into groups by variable:")		/*
  		*/ clickon(program by_on)				/*
		*/ clickoff(script by_off)
DEFINE _x @x
DEFINE _y @y
  VARNAME  vn_by           _indent2  _ss       _vnwd     .,		/*
  		*/option("by")						/*
  		*/label("Split into groups by variable")
  CHECKBOX ck_test         _lft2     _y        _cwd2     .,		/*
  		*/label("Use contrast matrix for comparing ROC areas")  /*
  		*/clickon(gaction main.cb_test.enable)			/*
		*/clickoff(gaction main.cb_test.disable)
  COMBOBOX cb_test         _indent2  _ss       _vnwd     .,		/*
  		*/dropdownlist						/*
  		*/contents(matrix)					/*
  		*/option("test")					/*
		*/label("Contrast matrix for comparing ROC areas")
  CHECKBOX ck_binorm       _x        _ls       _ibwd     .,		/*
  	*/label("Estimate areas using binormal distribution assumption")/*
  		*/ option("binormal")
  DEFINE _y _ls
  DEFINE _cx _sprb
  INCLUDE _sp_level

  CHECKBOX ck_graph        _ilft     +35       _ibwd     _ht7h,		/*
  		*/ groupbox						/*
  		*/ clickon(program graph_on)				/*
		*/ clickoff("program graph_off")			/*
  		*/ label("Graph the ROC curve")				/*
		*/ option("graph")
  CHECKBOX ck_noref        _indent   _ms       _inwd     .,		/*
  		*/label("Suppress plotting the 45-degree reference line")/*
		*/clickon("program check_noref")			/*
		*/clickoff("program check_noref")			/*
  		*/option("norefline")
  CHECKBOX ck_sep          @         _ms       @         .,		/*
		*/label("Place each ROC curve on its own graph ")	/*
  		*/option("separate")
  CHECKBOX ck_summ         @         _ms       @         .,		/*
  		*/label("Report the area under the ROC curve")		/*
  		*/option("summary")

END

PROGRAM check_noref
BEGIN
	if main.ck_graph {
		if ! main.ck_noref {
			call script line_opts_enable
		}
		if !H(main.ck_noref) & main.ck_noref {
			call script line_opts_disable
		}
	}
END

PROGRAM graph_on
BEGIN
	call gaction main.ck_noref.enable
	call gaction main.ck_summ.enable
	if main.ck_by {
    		call gaction main.ck_sep.enable
    	}

	call program check_noref
	call script p1_opts_enable
	call script p2_opts_enable
	call script p3_opts_enable
	call script gr_twoway_enable
END

PROGRAM graph_off
BEGIN
	call gaction main.ck_noref.disable
	call gaction main.ck_sep.disable
	call gaction main.ck_summ.disable

	call script p1_opts_disable
	call script p2_opts_disable
	call script p3_opts_disable
	call script line_opts_disable
	call script gr_twoway_disable
END

PROGRAM by_on
BEGIN
	call gaction main.vn_by.enable
	if main.ck_graph {
		call gaction main.ck_sep.enable
	}
END

SCRIPT by_off
BEGIN
	main.vn_by.disable
	main.ck_sep.disable
END

INCLUDE ifin
INCLUDE weights_f
INCLUDE p1_opts
INCLUDE p2_opts
INCLUDE p3_opts
INCLUDE line_opts
INCLUDE gr_twoway

SCRIPT PREINIT
BEGIN
	script p1_opts_createAsNoRange
	script p1_opts_setDefaultConnected
	script p2_opts_createAsNoRange
	script p2_opts_setDefaultConnected
	script p3_opts_createAsNoRange
	script p3_opts_setDefaultConnected
END

SCRIPT POSTINIT
BEGIN
	p1_opts.settabtitle "Plot 1"
	p2_opts.settabtitle "Plot 2"
	p3_opts.settabtitle "Plot 3"
END

PROGRAM command
BEGIN
	put "roccomp "
	varlist main.vn_varr
	varlist main.vn_varc
	if main.vl_varc2 {
		varlist main.vl_varc2
	}
	INCLUDE _weights_pr
	INCLUDE _ifin_pr
	beginoptions
		if ! main.vl_varc2 & ! main.ck_by {
			stopbox stop /*
	*/ `"On the Main tab, either use "Split into groups by variable""' /*
	*/ `"or fill in "Additional classification variables""'
		}
		if main.ck_by {
			require main.vn_by
			optionarg main.vn_by
		}
		option main.ck_binorm
		if main.ck_test {
			require main.cb_test
			optionarg main.cb_test
		}
		INCLUDE _level_main_pr
		option main.ck_graph
		if main.ck_graph {
			option main.ck_noref
			option main.ck_sep
			option main.ck_summ
			call p1_opts_specialOutput.setstring "plot1opts"
			put " " /program p1_opts_special_output
			call p2_opts_specialOutput.setstring "plot2opts"
			put " " /program p2_opts_special_output
			call p3_opts_specialOutput.setstring "plot3opts"
			put " " /program p3_opts_special_output
		}

		if ! main.ck_noref {
			put " " /program line_opts_rlopts_output
		}
		put " " /program gr_twoway_output
	endoptions
END
