/*
  xtintreg

*!  VERSION 1.3.4  23aug2010

  keyword:  eclass

*/

VERSION 12.0

INCLUDE _std_large
DEFINE _dlght 400
INCLUDE header

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

SCRIPT PREINIT
BEGIN
	script se_createAsOIMJknifeBstrap
END

SCRIPT POSTINIT
BEGIN
	script se_setCluster_off
	script se_setTitleSE
END

SCRIPT show_xtset
BEGIN
	create CHILD xtset
END

DIALOG main, tabtitle("Model")	///
	label("xtintreg - Random-effects interval-data regression models")
BEGIN
  BUTTON   bu_xtset	_xsetbu	_top	_setbuwd .,		///
	onpush(script show_xtset)				///
	label("Panel settings...")

  TEXT     tx_dv1    _lft      _top      _vnwd     .,			/*
		*/ label("Dependent variable 1:")			/*
		*/
  VARNAME  vn_dv1    @         _ss       _vnwd     .,			/*
		*/ label("Dependent variable 1")			/*
		*/ ts

  TEXT     tx_dv2    _vlx      _top      _vnwd     .,			/*
		*/ label("Dependent variable 2:")			/*
		*/ 
  VARNAME  vn_dv2    @         _ss       _vnwd     .,			/*
		*/ label("Dependent variable 2")			/*
		*/ ts

  TEXT     tx_iv     _lft      _ls       _iwd      .,			/*
		*/ label("Independent variables:")			/*
		*/
  VARLIST  vl_iv     @         _ss       @         .,			/*
		*/ label("Independent variables")			/*
		*/ allowcat						/*
		*/ ts fv
  CHECKBOX ck_nocons @         _ms       _cwd1     .,			/*
		*/ label("Suppress constant term")			/*
		*/ option("noconstant")					/*
		*/

  GROUPBOX gb_output _lft      _ls       _iwd      _ht12,		/*
		*/ label("Options")					/*
		*/

  TEXT     tx_offset _ilft     _ss       _cwd2     .,			/*
		*/ label("Offset variable:")				/*
		*/
  VARNAME  vn_offset @         _ss       _vnwd     .,			/*
		*/ label("Offset variable")				/*
		*/ option("offset")					/*
		*/

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

  DEFINE _x _ilft
  DEFINE _xw _ibwd
  INCLUDE _ck_collinear
END

INCLUDE _constraints_sc
INCLUDE byifin
INCLUDE weights_i
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 _spr2b
  DEFINE _y _top
  INCLUDE _sp_level

  GROUPBOX gb_tests  _lft      +35      _iwd       _ht4h,		/*
  		*/ label("Additional test statistics")
  CHECKBOX ck_noskip _ilft     _ss      _inwd      .,			/*
		*/ label("Perform likelihood-ratio test")		/*
		*/ option("noskip")					/*
		*/
  CHECKBOX ck_intreg @         _ms       @         .,			/*
  		*/ option("intreg")					/*
		*/ label("Perform likelihood-ratio test comparing model with pooled intreg model")

  DEFINE _x _lft
  DEFINE _y _xls
  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 intopts_re
INCLUDE max_ml

PROGRAM command
BEGIN
	put /program by_output " "
	put "xtintreg "
	varlist main.vn_dv1 main.vn_dv2 [main.vl_iv]
	if !main.vl_iv & main.ck_nocons {
	  stopbox stop `""Suppress constant term" is selected without independent variables."'
	}
	put " " /program ifin_output
	put " " /program weights_output
	beginoptions
		option main.ck_nocons
		optionarg main.vn_offset
		INCLUDE _constraints_main_pr
		option main.ck_collinear
		put " " /program se_output
		optionarg /hidedefault rpt.sp_level
		option rpt.ck_noskip
		option rpt.ck_intreg
		INCLUDE _nocnsreport_pr
		INCLUDE _noomitted_pr
		INCLUDE _vsquish_pr
		INCLUDE _factor_vars_reporting_pr
		put " " rpt_bu_fmtcoefResults
		put " " /program intopts_re_output
		put " " /program max_output
	endoptions
END
