/*
  rreg

*!  VERSION 1.1.5  23aug2010

  keyword:  eclass

*/

VERSION 12.0

INCLUDE _std_large
DEFINE _dlght 380
INCLUDE header

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

SCRIPT PREINIT
BEGIN
	program parseMessage
END

PROGRAM parseMessage
BEGIN
	if __MESSAGE.contains("__MI__") {
		call script byifin_set_by_off
	}
END

DIALOG main, label("rreg - Robust regression") tabtitle("Model")
BEGIN

  TEXT tx_dv 		_lft	_top	_vnwd	.,			///
	label("Dependent variable:")
  VARNAME vn_dv		@ 	_ss	@	.,			///
	ts								///
	label("Dependent variable")

  TEXT tx_iv		_vlx	_top	160	.,			///
	label("Independent variables:")
  VARLIST vl_iv		@	_ss	_vlwd	.,			///
	fv ts								///
	allowcat							///
	label("Independent variables")

  GROUPBOX gb_opts   _lft      _xls      _iwd      _ht3,		/*
		*/ label("Options")					/*
		*/

  EDIT     en_tune   _ilft     _ms       _en7wd   .,			/*
		*/ label("Biweight tuning constant")			/*
		*/ numonly						/*
		*/ default(7)						/*
		*/ option("tune")					/*
		*/
  TEXT     tx_tune   _spsep    @        _cwd2     .,			/*
		*/ label("Biweight tuning constant")			/*
		*/
END

INCLUDE byifin

SCRIPT rpt_POSTINIT
BEGIN
	create STRING rpt_bu_fmtcoefResults
	program rpt_bu_fmtcoef_ckResults
END

DIALOG rpt, tabtitle("Reporting")
BEGIN
  DEFINE _x _lft
  DEFINE _cx _spr2b
  DEFINE _y _top
  INCLUDE _sp_level

  GROUPBOX gb_genvar _lft      _ls       _iwd      _ht4h,		/*
  		*/ label("Generate new variables")
  TEXT     tx_genwt  _ilft     _ss       _inwd     .,			/*
		*/ label("Weight variable:")				/*
		*/
  EDIT     ed_genwt  @         _ss       _vnwd     .,			/*
		*/ label("Weight variable")				/*
		*/ max(32)						/*
		*/ option("genwt")
  DEFINE _x _lft
  DEFINE _y _xxls
  DEFINE _cx _iwd
  INCLUDE _noomitted

  DEFINE _x _lft
  DEFINE _y _ms
  DEFINE _cx _iwd
  INCLUDE _vsquish

  DEFINE _x _lft
  DEFINE _y _ms
  DEFINE _cx _iwd
  INCLUDE _factor_vars_reporting

  DEFINE _x _lft
  DEFINE _y _xxxls
  INCLUDE _bu_coef_table_reporting
END

INCLUDE fmt_coef_table_reporting_pr

DIALOG max, tabtitle("Optimization")
BEGIN
  SPINNER  sp_iter   _lft      _top      _spwd     .,			/*
		*/ label("Max iterations")				/*
		*/ min(1)						/*
		*/ max(10000)						/*
		*/ default(1000)					/*
		*/ option("iterate")					/*
		*/
  TEXT     tx_iter   _spsep    @         _spr2b    .,			/*
		*/ label("Maximum iterations")				/*
		*/

  EDIT     en_tol    _lft      _ls       _spwd     .,			/*
		*/ label("Convergence criterion")			/*
		*/ numonly						/*
		*/ default(0.01)					/*
		*/ option("tolerance")					/*
		*/
  TEXT     tx_tol    _spsep    @         _cwd2     .,			/*
		*/ label("Convergence criterion")			/*
		*/
  CHECKBOX ck_nolog  _lft      _ls       _cwd1     .,			/*
		*/ label("Suppress iteration log")			/*
		*/ option("nolog")					/*
		*/
  CHECKBOX ck_graph  @         _ms       @         .,			/*
		*/ label("Graph weights during convergence")		/*
		*/ option("graph")					/*
		*/
END

PROGRAM command
BEGIN
	INCLUDE _by_pr
	put "rreg "
	varlist main.vn_dv [main.vl_iv]
	INCLUDE _ifin_pr
	beginoptions
		optionarg /hidedefault main.en_tune
		optionarg /hidedefault rpt.sp_level
		optionarg rpt.ed_genwt
		INCLUDE _noomitted_pr
		INCLUDE _vsquish_pr
		INCLUDE _factor_vars_reporting_pr
		put " " rpt_bu_fmtcoefResults
		optionarg /hidedefault max.sp_iter
		optionarg /hidedefault max.en_tol
		option max.ck_nolog
		option max.ck_graph
	endoptions
END

