/*
  slogit

*!  VERSION 1.1.6  23aug2010

  keyword:  eclass

*/

VERSION 11.0

INCLUDE _std_wide
DEFINE _dlght 420  // min 420 for max_setOptionSlogit
INCLUDE header

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

SCRIPT PREINIT
BEGIN
	script se_createAsSvyJknifeBstrapML
	program svy_check_title
END

SCRIPT POSTINIT
BEGIN
	script max_setOptionSlogit
	script sub_set_by_on
	program se_setFinalInitState
END

SCRIPT svy_is_on
BEGIN
	script max_setDefaultNoLog
END
SCRIPT svy_is_off
BEGIN
	script max_setDefaultLog
END
PROGRAM svy_check_title
BEGIN
	if __MESSAGE.contains("-svy-") {
		call settitle "svy: slogit - Stereotype logistic regression for survey data"
	}
END

DIALOG main, tabtitle("Model")					///
	/// **** has svy title ****				///
	title("slogit - Stereotype logistic regression")
BEGIN
  TEXT tx_dv 		_lft	_top	_vnwd	.,			///
	label("Dependent variable:")
  VARNAME vn_dv		@ 	_ss	@	.,			///
	label("Dependent variable")

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

  GROUPBOX gb_output	_lft	+35	_iwd	_ht13h,		///
	label("Options")

  EDIT     en_dimension	_ilft	_ms	_en7wd	.,		///
	numonly option(dimension)
  TEXT     tx_dimension	_en7sep @	120	.,		///
	label("Dimension")

  EDIT     en_base	_lft2	@	_en14wd	.,		///
	label("Base outcome") 					///
	option(baseoutcome)
  TEXT     tx_base	_en14sep @	120	.,		///
	label("Base outcome")

  DEFINE _x _ilft
  DEFINE _y _ls
  DEFINE _cx _ilw80
  DEFINE _bux _islw80
  INCLUDE _constraints

  DEFINE _x _ilft
  DEFINE _xw _ibwd
  INCLUDE _ck_collinear

  CHECKBOX ck_nocorner	_ilft	_ms	_ibwd	.,		///
	label("Do not generate the corner constraints")		///
	option(nocorner)
END

INCLUDE _constraints_sc 
INCLUDE sub_by_ifin_over_subpop
INCLUDE weights_fpi
INCLUDE se

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 _spr
  DEFINE _y _top
  INCLUDE _sp_level

  DEFINE _x _lft
  DEFINE _y _ls
  DEFINE _cx _iwd
  INCLUDE _nocnsreport

  DEFINE _x _lft
  DEFINE _y _ms
  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

INCLUDE max_ml

PROGRAM command
BEGIN
	put /program by_output " "
	put /program se_prefix_output " "
	put "slogit "
	varlist main.vn_dv main.vl_iv
	put " " /program ifin_output
	put " " /program weights_output
	beginoptions
		optionarg main.en_dimension
		optionarg main.en_base
		optionarg main.cb_constr
		option main.ck_collinear
		option main.ck_nocorner
		put " " /program se_output
		optionarg /hidedefault rpt.sp_level
		INCLUDE _nocnsreport_pr
		INCLUDE _noomitted_pr
		INCLUDE _vsquish_pr
		INCLUDE _factor_vars_reporting_pr
		put " " rpt_bu_fmtcoefResults
		put " " /program max_output
END
