/*
	xtgee_estat

*!  VERSION 1.1.2  01jun2009

	***
	USE EXTREME CARE WHEN CHANGING CONTROL NAMES. The names used
	in this file have multiple external dependencies.
*/

VERSION 11.0

INCLUDE _std_large
DEFINE _dlght 400	//dialog length for bootstrap options
INCLUDE header

HELP hlp1, view("help xtgee postestimation")
RESET res1

SCRIPT PREINIT
BEGIN
	create BOOLEAN has_FactorVars
	has_FactorVars.settrue
	program sum_bu_facvars_ckResults
	program vce_bu_facvars_ckResults
END

DIALOG main, label("estat - Postestimation tools for xtgee") tabtitle("Main")
BEGIN
  TEXT     tx_subcmd		_lft	_top	_iwd	.,		///
  	label("Reports and statistics: (subcommand)")
  LISTBOX  lb_subcmd		@	_ss	@	70,		///
  	contents(main_subcommand_contents)				///
  	values(main_subcommand_values)					///
  	onselchangelist(main_subcommand_scripts)

  DEFINE holdy 110

  // wcorrelation
  CHECKBOX ck_compact		_lft	holdy	_iwd	.,		///
  	option(compact)							///
  	label("Display only the parameters of the estimated matrix of within-group correlations")
  CHECKBOX ck_format_1		_lft	_ms	_iwd	.,		///
  	label("Override display format") 				///
  	onclickon(script main_format_on)				///
  	onclickoff(script main_format_off)
  EDIT     ed_format_1		+20	_ss	200	.,		///
  	option(format) label("Display format")
  BUTTON   bn_format_1		+205	@      	80	.,		///
	label("Create...") onpush(script main_GetFormat)		///
	tooltip("Create display format")

  INCLUDE estat_sum
  INCLUDE estat_vce
  INCLUDE _estat_bootstrap
END

SCRIPT main_GetFormat
BEGIN
	create STRING mainFormat
	create CHILD format_chooser
	format_chooser.setExitString mainFormat
	format_chooser.setExitAction "main.ed_format_1.setvalue class mainFormat.value"
END

INCLUDE estat_sum_pr
INCLUDE _estat_bootstrap_pr
INCLUDE estat_vce_pr

SCRIPT main_group_on
BEGIN
	main.sp_group.enable
	main.tx_group.enable
END
SCRIPT main_group_off
BEGIN
	main.sp_group.disable
	main.tx_group.disable
END

LIST main_subcommand_contents
BEGIN
	"Estimated matrix of within-group correlations (wcorrelation)"
	"Summarize estimation sample (summarize)"
	"Covariance matrix estimates (vce)"
END

LIST main_subcommand_values
BEGIN
	wcorrelation
	summarize
	vce
END

LIST main_subcommand_scripts
BEGIN
	script sel_wcorrelation
	script sel_summarize
	script sel_vce
END

SCRIPT sel_wcorrelation
BEGIN
	script main_hide_all
	main.ck_compact.show
	main.ck_format_1.show
	main.ed_format_1.show
	main.bn_format_1.show
END

SCRIPT sel_summarize
BEGIN
	script main_hide_all
	program main_summ_on
END

SCRIPT sel_vce
BEGIN
	script main_hide_all
	program vce_on
END

SCRIPT main_hide_all  // MUST BE IMPLEMENTED FOR BOOTSTRAP
BEGIN
	main.ck_compact.hide
	main.ck_format_1.hide
	main.ed_format_1.hide
	main.bn_format_1.hide
	script main_summ_off
	program vce_off
	script main_bootstrap_hide
END

SCRIPT main_format_on
BEGIN
	main.ed_format_1.enable
	main.bn_format_1.enable
END
SCRIPT main_format_off
BEGIN
	main.ed_format_1.disable
	main.bn_format_1.disable
END

PROGRAM vl_output
BEGIN
	put main.vl_spec
END

PROGRAM vl_eq_output
BEGIN
	put main.vl_eq
END


PROGRAM command
BEGIN
	put "estat "
	put main.lb_subcmd
	put " " /program summarize_output
	beginoptions
		// wcorrelation
  		option main.ck_compact
		if main.ck_format_1 {
			require main.ed_format_1
			optionarg main.ed_format_1
		}
		// Summarize options
		put " " /program summarize_opts_output

		put " " /program vce_output
		put " " /program bootstrap_output
	endoptions
END
